Skip to content

Commit

Permalink
fetchLDM: expect aqp depth logic warning for Typic Argialbolls used i…
Browse files Browse the repository at this point in the history
…n tests
  • Loading branch information
brownag committed Dec 12, 2024
1 parent 71cb072 commit 73b7c40
Showing 1 changed file with 37 additions and 17 deletions.
54 changes: 37 additions & 17 deletions tests/testthat/test-fetchLDM.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,58 @@ test_that("fetchLDM works", {
skip_on_cran()

# physical and chemical properties tables are 1:1 with lab_layer
res <- fetchLDM("Typic Argialbolls",
what = "corr_taxsubgrp",
tables = c("lab_physical_properties",
"lab_chemical_properties"))
res <- expect_warning(
fetchLDM(
"Typic Argialbolls",
what = "corr_taxsubgrp",
tables = c("lab_physical_properties",
"lab_chemical_properties")
),
"horizon bottom depths are shallower than top depth"
)
skip_if(inherits(res, 'try-error') || is.null(res))

expect_true(inherits(res, 'SoilProfileCollection'))

# xray/thermal table allows for different prep_code and analyzed_size_frac
# w/ default prep_code = "S" and analyzed_size_frac = "<2 mm"
res2 <- expect_message(fetchLDM("Typic Argialbolls",
what = "corr_taxsubgrp",
tables = c("lab_physical_properties",
"lab_chemical_properties",
"lab_xray_and_thermal")))
res2 <- expect_warning(expect_message(
fetchLDM(
"Typic Argialbolls",
what = "corr_taxsubgrp",
tables = c(
"lab_physical_properties",
"lab_chemical_properties",
"lab_xray_and_thermal"
)
)
),
"horizon bottom depths are shallower than top depth")

skip_if(inherits(res2, 'try-error') || is.null(res2))

# parameters an all-NA table of XRD data is joined
expect_true(inherits(res2, 'SoilProfileCollection') &&
all(is.na(res2$analyzed_size_frac)))

# specifying a size fraction will join in just that subset of data
# so number of profiles and horizons matches that of the query without xray data
res3 <- fetchLDM("Typic Argialbolls",
what = "corr_taxsubgrp",
tables = c("lab_physical_properties",
"lab_chemical_properties",
"lab_xray_and_thermal"),
analyzed_size_frac = "0.02-0.05 mm")
res3 <- expect_warning(
fetchLDM(
"Typic Argialbolls",
what = "corr_taxsubgrp",
tables = c(
"lab_physical_properties",
"lab_chemical_properties",
"lab_xray_and_thermal"
),
analyzed_size_frac = "0.02-0.05 mm"
),
"horizon bottom depths are shallower than top depth"
)

skip_if(inherits(res3, 'try-error') || is.null(res3))

expect_true(inherits(res3, 'SoilProfileCollection') &&
length(res) == length(res3) &&
nrow(res) == nrow(res3))
Expand Down

0 comments on commit 73b7c40

Please sign in to comment.