Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
166 changes: 83 additions & 83 deletions tests/testthat/tests_general.R
Original file line number Diff line number Diff line change
Expand Up @@ -295,16 +295,16 @@ test_that("read_waterdata_ts_meta", {
test_that("General WQP retrievals working", {
testthat::skip_on_cran()
testthat::skip_on_ci()
nameToUse <- "pH"
pHData <- readWQPdata(
siteid = "USGS-04024315",
characteristicName = nameToUse,
service = "ResultWQX3"
)
expect_is(pHData$Activity_StartDateTime, "POSIXct")
expect_type(pHData$USGSpcode, "character")
expect_type(pHData$Result_Measure, "double")
expect_type(pHData$SampleCollectionMethod_Identifier, "character")
# nameToUse <- "pH"
# pHData <- readWQPdata(
# siteid = "USGS-04024315",
# characteristicName = nameToUse,
# service = "ResultWQX3"
# )
# expect_is(pHData$Activity_StartDateTime, "POSIXct")
# expect_type(pHData$USGSpcode, "character")
# expect_type(pHData$Result_Measure, "double")
# expect_type(pHData$SampleCollectionMethod_Identifier, "character")
#
# # testing lists:
startDate <- as.Date("2022-01-01")
Expand Down Expand Up @@ -335,80 +335,80 @@ test_that("General WQP retrievals working", {
characteristicName = secchi.names
)

wqp.summary_no_atts <- readWQPdata(
siteid = "USGS-04024315",
characteristicName = nameToUse,
ignore_attributes = TRUE,
service = "ResultWQX3"
)
expect_true(
!all(
c("siteInfo", "variableInfo") %in% names(attributes(wqp.summary_no_atts))
)
)

rawPcode <- readWQPqw("USGS-01594440", "01075", "", "", legacy = FALSE)
expect_true(all(
c("url", "queryTime", "siteInfo") %in%
names(attributes(rawPcode))
))

# This means wqp_check_status was called:
expect_true("dataProviders" %in% names(attr(rawPcode, "headerInfo")))

rawPcode2 <- readWQPqw(
"USGS-01594440",
"01075",
"",
"",
ignore_attributes = TRUE
)
expect_true(all(
!c("queryTime", "siteInfo") %in%
names(attributes(rawPcode2))
))

# This means wqp_check_status wasn't called:
expect_false("dataProviders" %in% names(attr(rawPcode2, "headerInfo")))

pHData <- readWQPdata(
siteid = "USGS-04024315",
characteristicName = "pH",
service = "ResultWQX3"
)
expect_true(all(
c("url", "queryTime", "siteInfo", "headerInfo") %in%
names(attributes(pHData))
))

# # This means wqp_check_status was called:
expect_true("dataProviders" %in% names(attr(pHData, "headerInfo")))

pHData2 <- readWQPdata(
siteid = "USGS-04024315",
characteristicName = "pH",
ignore_attributes = TRUE,
service = "ResultWQX3"
)
expect_true(all(
!c("queryTime", "siteInfo") %in%
names(attributes(pHData2))
))

# wqp.summary_no_atts <- readWQPdata(
# siteid = "USGS-04024315",
# characteristicName = nameToUse,
# ignore_attributes = TRUE,
# service = "ResultWQX3"
# )
# expect_true(
# !all(
# c("siteInfo", "variableInfo") %in% names(attributes(wqp.summary_no_atts))
# )
# )
#
# rawPcode <- readWQPqw("USGS-01594440", "01075", "", "", legacy = FALSE)
# expect_true(all(
# c("url", "queryTime", "siteInfo") %in%
# names(attributes(rawPcode))
# ))
#
# # This means wqp_check_status was called:
expect_false("dataProviders" %in% names(attr(pHData2, "headerInfo")))

rawPcode <- readWQPqw(
"USGS-01594440",
"01075",
ignore_attributes = TRUE,
legacy = FALSE
)
headerInfo <- attr(rawPcode, "headerInfo")
wqp_request_id <- headerInfo$`wqp-request-id`
count_info <- wqp_check_status(wqp_request_id)

expect_true("dataProviders" %in% names(count_info))
# expect_true("dataProviders" %in% names(attr(rawPcode, "headerInfo")))
#
# rawPcode2 <- readWQPqw(
# "USGS-01594440",
# "01075",
# "",
# "",
# ignore_attributes = TRUE
# )
# expect_true(all(
# !c("queryTime", "siteInfo") %in%
# names(attributes(rawPcode2))
# ))
#
# # This means wqp_check_status wasn't called:
# expect_false("dataProviders" %in% names(attr(rawPcode2, "headerInfo")))
#
# pHData <- readWQPdata(
# siteid = "USGS-04024315",
# characteristicName = "pH",
# service = "ResultWQX3"
# )
# expect_true(all(
# c("url", "queryTime", "siteInfo", "headerInfo") %in%
# names(attributes(pHData))
# ))
#
# # # This means wqp_check_status was called:
# expect_true("dataProviders" %in% names(attr(pHData, "headerInfo")))
#
# pHData2 <- readWQPdata(
# siteid = "USGS-04024315",
# characteristicName = "pH",
# ignore_attributes = TRUE,
# service = "ResultWQX3"
# )
# expect_true(all(
# !c("queryTime", "siteInfo") %in%
# names(attributes(pHData2))
# ))
#
# # # This means wqp_check_status was called:
# expect_false("dataProviders" %in% names(attr(pHData2, "headerInfo")))
#
# rawPcode <- readWQPqw(
# "USGS-01594440",
# "01075",
# ignore_attributes = TRUE,
# legacy = FALSE
# )
# headerInfo <- attr(rawPcode, "headerInfo")
# wqp_request_id <- headerInfo$`wqp-request-id`
# count_info <- wqp_check_status(wqp_request_id)
#
# expect_true("dataProviders" %in% names(count_info))
})


Expand Down
68 changes: 34 additions & 34 deletions tests/testthat/tests_userFriendly_fxns.R
Original file line number Diff line number Diff line change
Expand Up @@ -233,40 +233,40 @@ test_that("read_waterdata_daily", {
test_that("WQP qw tests", {
testthat::skip_on_cran()
skip_on_ci()
nameToUse <- "Specific conductance"
pcodeToUse <- "00095"

INFO_WQP <- readWQPqw(
"USGS-04024315",
pcodeToUse,
startDate = "",
endDate = "",
legacy = FALSE
)
expect_is(INFO_WQP$Activity_StartDateTime, "POSIXct")

INFO2 <- readWQPqw(
"WIDNR_WQX-10032762",
nameToUse,
startDate = "",
endDate = "",
legacy = FALSE
)
expect_is(INFO2$Activity_StartDateTime, "POSIXct")

df <- readWQPqw("USGS-04193500", parameterCd = "00665", legacy = FALSE)
expect_true(nrow(df) > 0)

df2 <- readWQPqw("USGS-05427718", parameterCd = "all")
expect_true(nrow(df2) > 0)

#Empty legacy:
df3 <- readWQPqw(
siteNumbers = "USGS-385032115220501",
parameterCd = "all",
legacy = TRUE
)
expect_true(nrow(df3) == 0)
# nameToUse <- "Specific conductance"
# pcodeToUse <- "00095"
#
# INFO_WQP <- readWQPqw(
# "USGS-04024315",
# pcodeToUse,
# startDate = "",
# endDate = "",
# legacy = FALSE
# )
# expect_is(INFO_WQP$Activity_StartDateTime, "POSIXct")
#
# INFO2 <- readWQPqw(
# "WIDNR_WQX-10032762",
# nameToUse,
# startDate = "",
# endDate = "",
# legacy = FALSE
# )
# expect_is(INFO2$Activity_StartDateTime, "POSIXct")
#
# df <- readWQPqw("USGS-04193500", parameterCd = "00665", legacy = FALSE)
# expect_true(nrow(df) > 0)
#
# df2 <- readWQPqw("USGS-05427718", parameterCd = "all")
# expect_true(nrow(df2) > 0)
#
# #Empty legacy:
# df3 <- readWQPqw(
# siteNumbers = "USGS-385032115220501",
# parameterCd = "all",
# legacy = TRUE
# )
# expect_true(nrow(df3) == 0)
})


Expand Down
20 changes: 12 additions & 8 deletions vignettes/join_by_closest.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,13 @@ pcode_uv <- "99133"
pcode_samples <- "00631"
start_date <- as.Date("2018-01-01")
end_date <- as.Date("2020-01-01")
samples_data <- readWQPqw(site_samples, pcode_samples,
startDate = start_date,
endDate = end_date)

samples_data <- read_waterdata_samples(
monitoringLocationIdentifier = site_samples,
usgsPCode = pcode_samples,
activityStartDateUpper = end_date,
activityStartDateLower = start_date,
dataProfile = "fullphyschem")

uv_data <- read_waterdata_continuous(monitoring_location_id = site_uv,
parameter_code = c(pcode_uv),
Expand All @@ -60,11 +64,11 @@ Next we'll clean up the discrete water quality data to make it easy to follow in

```{r trimsamplesdata}
samples_trim <- samples_data |>
filter(ActivityTypeCode == "Sample-Routine",
!is.na(ActivityStartDateTime)) |>
select(samples_date = ActivityStartDateTime,
val_samples = ResultMeasureValue,
det_txt = ResultDetectionConditionText)
filter(Activity_TypeCode == "Sample-Routine",
!is.na(Activity_StartDateTime)) |>
select(samples_date = Activity_StartDateTime,
val_samples = Result_Measure,
det_txt = Result_ResultDetectionCondition)
```

```{r showsamplestrim, echo=FALSE}
Expand Down
Loading