Skip to content
Snippets Groups Projects
Commit 7eb25296 authored by Fisher, Jason C.'s avatar Fisher, Jason C.
Browse files

more changes to make pipeline run offline

parent c219b9d6
No related branches found
No related tags found
2 merge requests!260Merge in develop and bump version,!259Allow pipeline to run offline
......@@ -23,19 +23,6 @@ if (test_file_exists(Sys.which("mp"), access = "x")) {
unlink(dir, recursive = TRUE)
}
# test URL assertion
expect_silent(assert_url("https://www.usa.gov/"))
expect_error(assert_url("https://fail/on/bad/url/"))
expect_error(assert_url("https://anyapi.io/api/v1/exchange/rates?base=NAN&apiKey=123"))
# test downloading file
if (curl::has_internet()) {
url <- "https://code.usgs.gov/inl/inldata/-/raw/main/CODE_OF_CONDUCT.md"
file <- download_file(url, cachedir = tempdir(), quiet = TRUE)
expect_file_exists(file, access = "rw")
unlink(file)
}
# test cleaning simple feature
x <- clean_sf(cities,
cols = c("key" = "id", "geometry" = "geometry"),
......@@ -72,3 +59,19 @@ unlink(destdir, recursive = TRUE)
# test cleaning a simple feature
x <- clean_sf(inl, cols = "geometry", crs = sf::st_crs(3857))
expect_multi_class(x, classes = c("sf", "data.frame"))
# require internet connection
if (curl::has_internet()) {
# test URL assertion
expect_silent(assert_url("https://www.usa.gov/"))
expect_error(assert_url("https://fail/on/bad/url/"))
expect_error(assert_url("https://anyapi.io/api/v1/exchange/rates?base=NAN&apiKey=123"))
# test downloading file
url <- "https://code.usgs.gov/inl/inldata/-/raw/main/CODE_OF_CONDUCT.md"
file <- download_file(url, cachedir = tempdir(), quiet = TRUE)
expect_file_exists(file, access = "rw")
unlink(file)
}
......@@ -3,113 +3,118 @@ library("tinytest")
library("checkmate")
using("checkmate")
# test existence of data-raw folder
destdir <- tempfile("")
expect_error(
current = make_datasets(path = tempdir(), destdir = destdir),
pattern = "does not exist"
)
unlink(destdir)
# require internet connection
if (curl::has_internet()) {
# test making parameters
pcodes <- "07000"
n <- length(pcodes)
x <- inldata:::mds_parameters(pcodes)
expect_data_frame(x, nrows = n, col.names = "named")
x <- inldata:::tabulate_parm_data(x, samples)
expect_data_frame(x, nrows = n, col.names = "named")
# test existence of data-raw folder
destdir <- tempfile("")
expect_error(
current = make_datasets(path = tempdir(), destdir = destdir),
pattern = "does not exist"
)
unlink(destdir)
# test making detection limits
data <- data.frame(
"srsname" = c("Tritium", "Tritium"),
"pcode" = c("07000", "07000"),
"unit_cd" = c("pCi/L", "pCi/L"),
"lab_det_lim_va" = c("500", "200"),
"min_dt" = c("1949-01-16", "2003-04-01"),
"reference" = c("Bartholomay", "Bartholomay")
)
x <- inldata:::mds_dl(data, parameters)
expect_data_frame(x, nrows = nrow(data), col.names = "named")
# test making parameters
pcodes <- "07000"
n <- length(pcodes)
x <- inldata:::mds_parameters(pcodes)
expect_data_frame(x, nrows = n, col.names = "named")
x <- inldata:::tabulate_parm_data(x, samples)
expect_data_frame(x, nrows = n, col.names = "named")
# test making benchmarks
bm <- data.frame(
"Chemical Name" = "trans-1,3-Dichloropropene",
"CAS Registry Number" = "10061-02-6",
"USGS Parameter Code" = "34699",
"Chemical Class" = "VOC",
"MCL (micrograms/L)" = NA_character_,
"Chronic Noncancer HHBP (micrograms/L)" = NA_character_,
"Carcinogenic HHBP (micrograms/L)" = NA_character_,
"Noncancer HBSL (micrograms/L)" = "200",
"Cancer HBSL (micrograms/L)" = "0.3-30",
"Benchmark Remarks" = NA_character_,
check.names = FALSE
)
mcl_extras <- data.frame(
"srsname" = "Tritium",
"pcode" = "07000",
"mcl" = "20000",
"unit_cd" = "pCi/L"
)
n <- nrow(bm) + nrow(mcl_extras)
x <- inldata:::mds_benchmarks(bm, mcl_extras, parameters)
expect_data_frame(x, nrows = n, col.names = "named")
# test making detection limits
data <- data.frame(
"srsname" = c("Tritium", "Tritium"),
"pcode" = c("07000", "07000"),
"unit_cd" = c("pCi/L", "pCi/L"),
"lab_det_lim_va" = c("500", "200"),
"min_dt" = c("1949-01-16", "2003-04-01"),
"reference" = c("Bartholomay", "Bartholomay")
)
x <- inldata:::mds_dl(data, parameters)
expect_data_frame(x, nrows = nrow(data), col.names = "named")
# test making sites
data <- data.frame(
"agency_cd" = "USGS",
"site_no" = "432700112470801",
"station_nm" = "02N 31E 35DCC1 USGS 1",
"network_cd" = "A",
"pos" = "3"
)
x <- inldata:::mds_sites(data, crs)
expect_multi_class(x, classes = c("sf", "data.frame"))
expect_set_equal(nrow(x), nrow(data))
y <- inldata:::tabulate_site_data(x, samples, gwl, swm)
expect_data_frame(y, nrows = nrow(x), col.names = "named")
# test making benchmarks
bm <- data.frame(
"Chemical Name" = "trans-1,3-Dichloropropene",
"CAS Registry Number" = "10061-02-6",
"USGS Parameter Code" = "34699",
"Chemical Class" = "VOC",
"MCL (micrograms/L)" = NA_character_,
"Chronic Noncancer HHBP (micrograms/L)" = NA_character_,
"Carcinogenic HHBP (micrograms/L)" = NA_character_,
"Noncancer HBSL (micrograms/L)" = "200",
"Cancer HBSL (micrograms/L)" = "0.3-30",
"Benchmark Remarks" = NA_character_,
check.names = FALSE
)
mcl_extras <- data.frame(
"srsname" = "Tritium",
"pcode" = "07000",
"mcl" = "20000",
"unit_cd" = "pCi/L"
)
n <- nrow(bm) + nrow(mcl_extras)
x <- inldata:::mds_benchmarks(bm, mcl_extras, parameters)
expect_data_frame(x, nrows = n, col.names = "named")
# test making surface-water measurements
site_no <- "13131000"
is <- sites$site_no == site_no
x <- inldata:::mds_swm(sites = sites[is, ], tz = "America/Denver")
expect_data_frame(x, min.rows = 1, col.names = "named")
# test making sites
data <- data.frame(
"agency_cd" = "USGS",
"site_no" = "432700112470801",
"station_nm" = "02N 31E 35DCC1 USGS 1",
"network_cd" = "A",
"pos" = "3"
)
x <- inldata:::mds_sites(data, crs)
expect_multi_class(x, classes = c("sf", "data.frame"))
expect_set_equal(nrow(x), nrow(data))
y <- inldata:::tabulate_site_data(x, samples, gwl, swm)
expect_data_frame(y, nrows = nrow(x), col.names = "named")
# test making groundwater levels
site_no <- "433500112572501"
is <- sites$site_no == site_no
x <- inldata:::mds_gwl(sites = sites[is, ], tz = "America/Denver")
expect_data_frame(x, min.rows = 1, col.names = "named")
# test making surface-water measurements
site_no <- "13131000"
is <- sites$site_no == site_no
x <- inldata:::mds_swm(sites = sites[is, ], tz = "America/Denver")
expect_data_frame(x, min.rows = 1, col.names = "named")
# test making units
data <- data.frame(
"unit_cd" = "deg C",
"unit_ds" = "degrees Celsius"
)
x <- inldata:::mds_units(data)
expect_data_frame(x, nrows = nrow(data), col.names = "named")
# test making groundwater levels
site_no <- "433500112572501"
is <- sites$site_no == site_no
x <- inldata:::mds_gwl(sites = sites[is, ], tz = "America/Denver")
expect_data_frame(x, min.rows = 1, col.names = "named")
# test making background concentrations
data <- data.frame(
"srsname" = "Sodium",
"pcode" = "00930",
"unit_cd" = "mg/L",
"bkgrd_min" = "8.3",
"bkgrd_max" = "14.8",
"reference" = "Bartholomay"
)
x <- inldata:::mds_background(data, parameters)
expect_data_frame(x, nrows = nrow(data), col.names = "named")
# test making units
data <- data.frame(
"unit_cd" = "deg C",
"unit_ds" = "degrees Celsius"
)
x <- inldata:::mds_units(data)
expect_data_frame(x, nrows = nrow(data), col.names = "named")
# test unit conversion
data <- data.frame(
"pcode" = c("01065", "00631"),
"unit_cd" = c("ug/L", "ug/L")
)
x <- inldata:::convert_units(data, parameters)
expect_data_frame(x,
types = c("character", "character", "character", "numeric"),
nrows = nrow(data),
col.names = "named"
)
expect_set_equal(colnames(x), c("pcode", "from", "to", "mult"))
# test making background concentrations
data <- data.frame(
"srsname" = "Sodium",
"pcode" = "00930",
"unit_cd" = "mg/L",
"bkgrd_min" = "8.3",
"bkgrd_max" = "14.8",
"reference" = "Bartholomay"
)
x <- inldata:::mds_background(data, parameters)
expect_data_frame(x, nrows = nrow(data), col.names = "named")
# test unit conversion
data <- data.frame(
"pcode" = c("01065", "00631"),
"unit_cd" = c("ug/L", "ug/L")
)
x <- inldata:::convert_units(data, parameters)
expect_data_frame(x,
types = c("character", "character", "character", "numeric"),
nrows = nrow(data),
col.names = "named"
)
expect_set_equal(colnames(x), c("pcode", "from", "to", "mult"))
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment