-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into allow-redirects
- Loading branch information
Showing
4 changed files
with
14 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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", { | ||
|
@@ -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", { | ||
|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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)) | ||
|
||
}) | ||
}) |