Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
inldata
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
INLPO
inldata
Commits
7eb25296
Commit
7eb25296
authored
8 months ago
by
Fisher, Jason C.
Browse files
Options
Downloads
Patches
Plain Diff
more changes to make pipeline run offline
parent
c219b9d6
No related branches found
No related tags found
2 merge requests
!260
Merge in develop and bump version
,
!259
Allow pipeline to run offline
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
inst/tinytest/test_functions.R
+16
-13
16 additions, 13 deletions
inst/tinytest/test_functions.R
inst/tinytest/test_make_datasets.R
+106
-101
106 additions, 101 deletions
inst/tinytest/test_make_datasets.R
with
122 additions
and
114 deletions
inst/tinytest/test_functions.R
+
16
−
13
View file @
7eb25296
...
...
@@ -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
)
}
This diff is collapsed.
Click to expand it.
inst/tinytest/test_make_datasets.R
+
106
−
101
View file @
7eb25296
...
...
@@ -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 paramet
er
s
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 fold
er
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 level
s
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 measurement
s
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"
))
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment