Skip to content

Commit

Permalink
Merge branch 'master' into allow-redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
davecap authored Aug 13, 2024
2 parents bcbcd21 + 917814f commit 7679a63
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/r-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ on: push

jobs:
solvebio-R:
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
env:
SOLVEBIO_API_KEY: ${{ secrets.SOLVEBIO_API_KEY }}
SOLVEBIO_API_HOST: ${{ secrets.QUARTZBIO_API_HOST }}
SOLVEBIO_API_KEY: ${{ secrets.QUARTZBIO_API_KEY }}
steps:
- uses: actions/checkout@v2
- uses: r-lib/actions/setup-r@v1
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Collate:
utils.R
vault.R
zzz.R
RoxygenNote: 7.1.2
RoxygenNote: 7.3.2
Encoding: UTF-8
Suggests:
testthat,
Expand Down
12 changes: 8 additions & 4 deletions tests/testthat/test_env.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@ bad_env <- solvebio::createEnv("bad")
# NOTE: good_env only works if assert_api_key()
good_env <- solvebio::createEnv(solvebio:::.solveEnv$token)

is_valid_email <- function(email) {
grepl("\\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,}\\b", email, ignore.case = TRUE)
}


test_that("createEnv properly sets defaults", {
env <- solvebio::createEnv("token")
expect_equal(env$token, "token")
expect_equal(env$token_type, "Token")
expect_equal(env$host, "https://api.solvebio.com")
expect_type(env$host, "character")
})

test_that("A default env is created", {
Expand All @@ -27,14 +31,14 @@ test_that("Simple functions work with global and local envs", {

# Global env should work
user <- User.retrieve()
expect_equal(user$email, "[email protected]")
expect_true(is_valid_email(user$email))

# Local env should error
expect_error(User.retrieve(env=bad_env), ".*401.*")

# Local env with global's token should work
user <- User.retrieve(env=good_env)
expect_equal(user$email, "[email protected]")
expect_true(is_valid_email(user$email))
})

test_that("Functions with ellipsis work with global and local envs", {
Expand Down Expand Up @@ -84,7 +88,7 @@ test_that("do.call works with env argument", {

# Simple functions
user <- do.call(User.retrieve, c(good_env))
expect_equal(user$email, "[email protected]")
expect_true(is_valid_email(user$email))
expect_error(do.call(User.retrieve, c(bad_env)), ".*401.*")

# Functions with ellipsis
Expand Down
7 changes: 2 additions & 5 deletions tests/testthat/test_query.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@ source("./helpers.R", local=T)
# NOTE: good_env only works if assert_api_key()
env <- solvebio::createEnv(solvebio:::.solveEnv$token)

TEST_DATASET_FULL_PATH_2 <- 'solvebio:public:/ClinVar/5.1.0-20200720/Variants-GRCH38'
TEST_DATASET_FULL_PATH_2 <- 'quartzbio:public:/ClinVar/5.3.0-20231007/Variants-GRCH38'

test_that("Query the dataset and check that titles are colnames in df", {
assert_api_key()

user <- User.retrieve(env=env)
expect_equal(user$email, "[email protected]")

ds <- Dataset.get_by_full_path(TEST_DATASET_FULL_PATH_2)
query <- Dataset.query(ds$id, fields=list("variant", "_id", "disease", "allele"), use_field_titles=TRUE)
expect_true('_id' %in% colnames(query))

})
})

0 comments on commit 7679a63

Please sign in to comment.