-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Function to test database structure (#135)
* Function to test database structure * Adding new test function where appropriate * Rebuilt embedded lite data layers so that they have the proper class attached to them --------- Co-authored-by: Daniel Falster <[email protected]>
- Loading branch information
Showing
8 changed files
with
50 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
|
||
|
||
test_database_structure <- function(database, taxa = NA, dataset_id = NA, n_row = NA) { | ||
|
||
table_names <- c("traits", "locations", "contexts", "methods", "excluded_data", "taxonomic_updates", "taxa", "contributors", | ||
"sources", "definitions", "schema", "metadata", "build_info") | ||
|
||
expect_type(database, "list") | ||
# should this be "traits.build or austraits?? | ||
#expect_equal(class(database), "austraits") | ||
expect_equal(class(database), "traits.build") | ||
|
||
expect_equal(names(database), table_names) | ||
|
||
expect_contains(database$traits$taxon_name |> unique(), database$taxa$taxon_name |> unique()) | ||
expect_contains(database$traits$dataset_id |> unique(), database$methods$dataset_id |> unique()) | ||
expect_contains(paste(database$traits$dataset_id, database$traits$trait_name) |> unique(), paste(database$methods$dataset_id, database$methods$trait_name) |> unique()) | ||
|
||
if(!is.na(taxa)) { | ||
expect_contains(database$traits$taxon_name |> unique(), taxa |> unique()) | ||
} | ||
|
||
if(!is.na(dataset_id)) { | ||
expect_contains(database$traits$dataset_id |> unique(), dataset_id |> unique()) | ||
} | ||
|
||
if(!is.na(n_row)) { | ||
expect_equal(database$traits |> nrow(), n_row) | ||
} | ||
} |
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 |
---|---|---|
|
@@ -51,7 +51,7 @@ join_location_coordinates <- function(database) { | |
`longitude (deg)` = NA_character_, | ||
) | ||
} | ||
|
||
database | ||
} | ||
|
||
|
Binary file not shown.
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