Skip to content

Commit

Permalink
Validations and tests RE: #149 #146
Browse files Browse the repository at this point in the history
  • Loading branch information
brownag committed Jan 4, 2021
1 parent e655a7d commit 370ea0b
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 1 deletion.
67 changes: 67 additions & 0 deletions misc/validate-NASIS-results.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
## validation of NASIS-functionality for nasisDBI PR
## git shell command to list files changed in the PR

# git diff --name-only master...nasisDBI | grep -E get\\|NASIS\\|fetch

f <- read.table(text = "R/fetchNASIS.R
R/fetchNASIS_pedons.R
R/getHzErrorsNASIS.R
R/get_RMF_from_NASIS_db.R
R/get_colors_from_NASIS_db.R
R/get_component_data_from_NASIS_db.R
R/get_concentrations_from_NASIS_db.R
R/get_cosoilmoist_from_NASIS.R
R/get_extended_data_from_NASIS_db.R
R/get_hz_data_from_NASIS_db.R
R/get_lablayer_data_from_NASIS_db.R
R/get_labpedon_data_from_NASIS_db.R
R/get_phfmp_from_NASIS_db.R
R/get_phlabresults_data_from_NASIS_db.R
R/get_projectmapunit_from_NASIS.R
R/get_site_data_from_NASIS_db.R
R/get_text_notes_from_NASIS_db.R
R/get_veg_data_from_NASIS_db.R
R/get_vegplot_data_from_NASIS_db.R
R/openNASISchannel.R")$V1
# R/dbQueryNASIS.R
# R/get_soilseries_from_NASIS.R
# man/dbConnectNASIS.Rd
# man/dbQueryNASIS.Rd
# man/fetchNASIS.Rd
# man/getHzErrorsNASIS.Rd
# misc/man-deprecated/fetchNASIS.Rd
#
library(soilDB)

fnames <- sapply(f, function(x) {
spv <- evalSource(x, package = "soilDB")
# source(x)
names(as.list(spv))
})

test <- lapply(fnames, function(fname) {
lapply(fname, function(FUN) {
message(sprintf("Testing: %s", FUN))
try(get(FUN, envir = as.environment("package:soilDB"))())
})
})

res <- unlist(lapply(names(test), function(x) lapply(seq_along(test[[x]]), function(y) {
res <- inherits(test[[x]][[y]], 'try-error')
names(res) <- fnames[[x]][y]
res
})))

res[which(res)]

# Fixed: Text fields must come at end of query per MSSQL specs
# get_text_notes_from_NASIS_db()

# Fixed: same as above
# get_vegplot_location_from_NASIS_db()

# Fixed:
# get_vegplot_textnote_from_NASIS_db()

# Relatively rare data update soon with input from Jay
# get_vegplot_transpecies_from_NASIS_db()
2 changes: 1 addition & 1 deletion tests/testthat/test-getHzErrorsNASIS.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
test_that("getHzErrorsNASIS works", {
expect_silent({test <- getHzErrorsNASIS()})
expect_silent({suppressMessages(getHzErrorsNASIS())})
})
3 changes: 3 additions & 0 deletions tests/testthat/test-get_text_notes_from_NASIS_db.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
test_that("get_text_notes_from_NASIS_db works", {
expect_silent({get_text_notes_from_NASIS_db()})
})

0 comments on commit 370ea0b

Please sign in to comment.