diff --git a/tests/testthat/tests_general.R b/tests/testthat/tests_general.R index ce207f440..43ff223bc 100644 --- a/tests/testthat/tests_general.R +++ b/tests/testthat/tests_general.R @@ -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") @@ -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)) }) diff --git a/tests/testthat/tests_userFriendly_fxns.R b/tests/testthat/tests_userFriendly_fxns.R index befb1d3ab..68e24645f 100644 --- a/tests/testthat/tests_userFriendly_fxns.R +++ b/tests/testthat/tests_userFriendly_fxns.R @@ -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) }) diff --git a/vignettes/join_by_closest.Rmd b/vignettes/join_by_closest.Rmd index 8341c4df8..f8018466c 100644 --- a/vignettes/join_by_closest.Rmd +++ b/vignettes/join_by_closest.Rmd @@ -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), @@ -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}