diff --git a/tests/testthat/tests_imports.R b/tests/testthat/tests_imports.R new file mode 100644 index 0000000000000000000000000000000000000000..14eed0c20f97ce841564fb9ef5d7acd3c1a4342e --- /dev/null +++ b/tests/testthat/tests_imports.R @@ -0,0 +1,57 @@ +context("importRDB_noCRAN") + +test_that("External importRDB1 tests", { + testthat::skip_on_cran() + + siteNumber <- "02177000" + startDate <- "2012-09-01" + endDate <- "2012-10-01" + offering <- "00003" + property <- "00060" + + obs_url <- constructNWISURL(siteNumber,property, + startDate,endDate,"dv",format="tsv") + data <- importRDB1(obs_url) + expect_is(data$datetime, 'character') + + urlMultiPcodes <- constructNWISURL("04085427",c("00060","00010"), + startDate,endDate,"dv",statCd=c("00003","00001"),"tsv") + multiData <- importRDB1(urlMultiPcodes) + pCodeCols <- grep("X", colnames(multiData)) + expect_that(length(pCodeCols)/2 > 2, is_true() ) + + unitDataURL <- constructNWISURL(siteNumber,property, + "2013-11-03","2013-11-03","uv",format="tsv") #includes timezone switch + unitData <- importRDB1(unitDataURL, asDateTime=TRUE) + + expect_that(as.numeric(unitData[which(unitData$tz_cd == "EST")[1],"datetime"]), + equals(as.numeric(as.POSIXct("2013-11-03 01:00:00", tz="UTC")+60*60*5))) + + + qwURL <- constructNWISURL(c('04024430','04024000'), + c('34247','30234','32104','34220'), + "2010-11-03","","qw",format="rdb") + qwData <- importRDB1(qwURL, qw=TRUE, tz="America/Chicago") + + + + iceSite <- '04024430' + start <- "2014-11-09" + end <- "2014-11-28" + urlIce <- constructNWISURL(iceSite,"00060",start, end,"uv",format="tsv") + ice <- importRDB1(urlIce) + iceNoConvert <- importRDB1(urlIce, convertType=FALSE) +}) + +context("importRDB") +test_that("CRAN-friendly importRDB test", { + filePath <- system.file("extdata", package="dataRetrieval") + fileName <- "RDB1Example.txt" + fullPath <- file.path(filePath, fileName) + importUserRDB <- importRDB1(fullPath) + + # default is to turn dates to characters + expect_is(importUserRDB$datetime, 'character') + +}) + diff --git a/tests/testthat/tests_userFriendly_fxns.R b/tests/testthat/tests_userFriendly_fxns.R index a545fe85847c11dbe48c8b7b0060d945b45658ef..71034dd23d79d0238e1ad3a7d34ebae353bda0fc 100644 --- a/tests/testthat/tests_userFriendly_fxns.R +++ b/tests/testthat/tests_userFriendly_fxns.R @@ -27,18 +27,6 @@ test_that("Unit value data returns correct types", { }) -context("importRDB") -test_that("CRAN-friendly importRDB test", { - filePath <- system.file("extdata", package="dataRetrieval") - fileName <- "RDB1Example.txt" - fullPath <- file.path(filePath, fileName) - importUserRDB <- importRDB1(fullPath) - - # default is to turn dates to characters - expect_is(importUserRDB$datetime, 'character') - -}) - context("Peak, rating, meas") test_that("peak, rating curves, surface-water measurements", { testthat::skip_on_cran()