-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a simple unit test which queries laminlabs/lamindata (#27)
* Add a simple unit test which queries laminlabs/lamindata * update changelog * Add `skip_if_offline` * use text figures * add newline
- Loading branch information
Showing
7 changed files
with
83 additions
and
3 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
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# This file is part of the standard setup for testthat. | ||
# It is recommended that you do not modify it. | ||
# | ||
# Where should you do additional test configuration? | ||
# Learn more about the roles of various files in: | ||
# * https://r-pkgs.org/testing-design.html#sec-tests-files-overview | ||
# * https://testthat.r-lib.org/articles/special-files.html | ||
|
||
library(testthat) | ||
library(laminr) | ||
|
||
test_check("laminr") |
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
local_setup_lamindata_instance <- function(env = parent.frame()) { | ||
root_dir <- withr::local_file(tempfile(), .local_envir = env) | ||
withr::local_envvar(c(LAMIN_SETTINGS_DIR = root_dir), .local_envir = env) | ||
|
||
# create a temporary directory for the settings | ||
lamin_dir <- file.path(root_dir, ".lamin") | ||
dir.create(lamin_dir, recursive = TRUE, showWarnings = FALSE) | ||
|
||
# generate user settings | ||
user_settings <- list( | ||
email = "null", | ||
password = "null", | ||
access_token = "null", | ||
api_key = "null", | ||
uid = "00000000", | ||
uuid = "null", | ||
handle = "anonymous", | ||
name = "null" | ||
) | ||
user_lines <- paste0("lamin_user_", names(user_settings), "=", unlist(user_settings)) | ||
writeLines(user_lines, file.path(lamin_dir, "current_user.env")) | ||
|
||
# generate instance settings | ||
instance_settings <- list( | ||
owner = "laminlabs", | ||
name = "lamindata", | ||
api_url = "https://us-east-1.api.lamin.ai", | ||
storage_root = "s3://lamindata", | ||
storage_region = "us-east-1", | ||
db = "null", | ||
schema_str = "bionty,wetlab", | ||
schema_id = "097186c3e91c01ced47aa3e01a3c1515", | ||
id = "037ba1e08d804f91a90275a47735076a", | ||
git_repo = "null", | ||
keep_artifacts_local = "False" | ||
) | ||
instance_lines <- paste0("lamindb_instance_", names(instance_settings), "=", unlist(instance_settings)) | ||
writeLines(instance_lines, file.path(lamin_dir, "current_instance.env")) | ||
writeLines(instance_lines, file.path(lamin_dir, "instance--laminlabs--lamindata.env")) | ||
|
||
root_dir | ||
} |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
skip_if_offline() | ||
|
||
test_that("Connecting to lamindata works", { | ||
local_setup_lamindata_instance() | ||
|
||
# try to connect to lamindata | ||
db <- connect("laminlabs/lamindata") | ||
|
||
# check whether schema was parsed and classes were created | ||
expect_equal(db$Artifact$name, "artifact") | ||
|
||
# try to fetch a record | ||
artifact <- db$Artifact$get("mePviem4DGM4SFzvLXf3") | ||
|
||
expect_equal(artifact$uid, "mePviem4DGM4SFzvLXf3") | ||
expect_equal(artifact$suffix, ".csv") | ||
|
||
# try to fetch linked records | ||
created_by <- artifact$created_by | ||
expect_equal(created_by$handle, "sunnyosun") | ||
}) |