Skip to content

Commit

Permalink
update tests, should work on windows and linux now
Browse files Browse the repository at this point in the history
  • Loading branch information
dblodgett-usgs committed Apr 16, 2021
1 parent c93413a commit 8864af4
Show file tree
Hide file tree
Showing 26 changed files with 115 additions and 46 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/R-CMD-check.yml
@@ -0,0 +1,69 @@
on:
push:
branches:
- master
pull_request:
branches:
- master

name: R-CMD-check

jobs:
R-CMD-check:
runs-on: ubuntu-18.04
env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
_R_CHECK_TESTS_NLINES_: 0
NOT_CRAN: true
steps:
- uses: actions/checkout@v2

- uses: r-lib/actions/setup-r@v1

- name: Query dependencies
run: |
install.packages('remotes')
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
shell: Rscript {0}

- name: Cache R packages
if: runner.os != 'Windows'
uses: actions/cache@v2
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-

- name: Install system dependencies
if: runner.os == 'Linux'
env:
RHUB_PLATFORM: linux-x86_64-ubuntu-gcc
run: |
Rscript -e "remotes::install_github('r-hub/sysreqs')"
sysreqs=$(Rscript -e "cat(sysreqs::sysreq_commands('DESCRIPTION'))")
sudo -s eval "$sysreqs"
- name: Install dependencies
run: |
install.packages(c("remotes"))
remotes::install_deps(dependencies = TRUE)
remotes::install_cran("rcmdcheck")
remotes::install_cran("covr")
shell: Rscript {0}

- name: Check
run: rcmdcheck::rcmdcheck(args = c("--ignore-vignettes", "--no-manual"), build_args = c("--no-build-vignettes"), error_on = "error", check_dir = "check")
shell: Rscript {0}

- name: Upload check results
if: failure()
uses: actions/upload-artifact@master
with:
name: results
path: check

- name: Test coverage
run: covr::codecov()
shell: Rscript {0}
4 changes: 2 additions & 2 deletions tests/testthat/00_create_test_data.R
Expand Up @@ -7,7 +7,7 @@ test_that("test data can be created", {
if(!"geoknife/tests/testthat" == substr(getwd(), nchar(getwd())-22, nchar(getwd()))) {
warning("this script assumes it is in the testthat directory of the geoknife package!!!")
}
gconfig(wps.url = "https://cida-test.er.usgs.gov/gdp/process/WebProcessingService")
# gconfig(wps.url = "https://cida-test.er.usgs.gov/gdp/process/WebProcessingService")
fabric <- webdata('prism')
times(fabric)[2] <- "1895-01-01"
saveRDS(fabric, "data/test_webdata_fabric.rds")
Expand All @@ -25,7 +25,7 @@ test_that("test data can be created", {
saveRDS(wp, "data/test_webprocess_knife_prod.rds")
saveRDS(query(wp, 'algorithms'), "data/test_webprocess_algorithms_prod.rds")

gconfig(wps.url = "https://cida-test.er.usgs.gov/gdp/process/WebProcessingService")
# gconfig(wps.url = "https://cida-test.er.usgs.gov/gdp/process/WebProcessingService")

saveRDS(webgeom('HUC8::09020306'), "data/test_webgeom_huc08.rds")
saveRDS(webgeom('state::Wisconsin'), "data/test_webgeom_WI.rds")
Expand Down
Binary file modified tests/testthat/data/test_XML_no_gmlid_wd.rds
Binary file not shown.
Binary file modified tests/testthat/data/test_XML_no_gmlid_wg.rds
Binary file not shown.
28 changes: 14 additions & 14 deletions tests/testthat/data/test_XML_no_gmlid_xml.xml
Expand Up @@ -25,12 +25,6 @@
<wps:LiteralData>false</wps:LiteralData>
</wps:Data>
</wps:Input>
<wps:Input>
<ows:Identifier>DATASET_URI</ows:Identifier>
<wps:Data>
<wps:LiteralData>dods://cida.usgs.gov/thredds/dodsC/prism_v2</wps:LiteralData>
</wps:Data>
</wps:Input>
<wps:Input>
<ows:Identifier>FEATURE_ATTRIBUTE_NAME</ows:Identifier>
<wps:Data>
Expand All @@ -44,15 +38,9 @@
</wps:Data>
</wps:Input>
<wps:Input>
<ows:Identifier>GROUP_BY</ows:Identifier>
<wps:Data>
<wps:LiteralData>STATISTIC</wps:LiteralData>
</wps:Data>
</wps:Input>
<wps:Input>
<ows:Identifier>REQUIRE_FULL_COVERAGE</ows:Identifier>
<ows:Identifier>DATASET_URI</ows:Identifier>
<wps:Data>
<wps:LiteralData>true</wps:LiteralData>
<wps:LiteralData>dods://cida.usgs.gov/thredds/dodsC/prism_v2</wps:LiteralData>
</wps:Data>
</wps:Input>
<wps:Input>
Expand All @@ -73,12 +61,24 @@
<wps:LiteralData>ppt</wps:LiteralData>
</wps:Data>
</wps:Input>
<wps:Input>
<ows:Identifier>REQUIRE_FULL_COVERAGE</ows:Identifier>
<wps:Data>
<wps:LiteralData>true</wps:LiteralData>
</wps:Data>
</wps:Input>
<wps:Input>
<ows:Identifier>STATISTICS</ows:Identifier>
<wps:Data>
<wps:LiteralData>MEAN</wps:LiteralData>
</wps:Data>
</wps:Input>
<wps:Input>
<ows:Identifier>GROUP_BY</ows:Identifier>
<wps:Data>
<wps:LiteralData>STATISTIC</wps:LiteralData>
</wps:Data>
</wps:Input>
<wps:Input>
<ows:Identifier>FEATURE_COLLECTION</ows:Identifier>
<wps:Reference xlink:href="https://www.sciencebase.gov/catalogMaps/mapping/ows/54296bf0e4b0ad29004c2fbb">
Expand Down
24 changes: 12 additions & 12 deletions tests/testthat/data/test_XML_wg_xml.xml
Expand Up @@ -25,12 +25,6 @@
<wps:LiteralData>false</wps:LiteralData>
</wps:Data>
</wps:Input>
<wps:Input>
<ows:Identifier>DATASET_URI</ows:Identifier>
<wps:Data>
<wps:LiteralData>dods://cida.usgs.gov/thredds/dodsC/prism_v2</wps:LiteralData>
</wps:Data>
</wps:Input>
<wps:Input>
<ows:Identifier>FEATURE_ATTRIBUTE_NAME</ows:Identifier>
<wps:Data>
Expand All @@ -44,21 +38,21 @@
</wps:Data>
</wps:Input>
<wps:Input>
<ows:Identifier>GROUP_BY</ows:Identifier>
<ows:Identifier>DATASET_URI</ows:Identifier>
<wps:Data>
<wps:LiteralData>STATISTIC</wps:LiteralData>
<wps:LiteralData>dods://cida.usgs.gov/thredds/dodsC/prism_v2</wps:LiteralData>
</wps:Data>
</wps:Input>
<wps:Input>
<ows:Identifier>REQUIRE_FULL_COVERAGE</ows:Identifier>
<ows:Identifier>DATASET_ID</ows:Identifier>
<wps:Data>
<wps:LiteralData>true</wps:LiteralData>
<wps:LiteralData>ppt</wps:LiteralData>
</wps:Data>
</wps:Input>
<wps:Input>
<ows:Identifier>DATASET_ID</ows:Identifier>
<ows:Identifier>REQUIRE_FULL_COVERAGE</ows:Identifier>
<wps:Data>
<wps:LiteralData>ppt</wps:LiteralData>
<wps:LiteralData>true</wps:LiteralData>
</wps:Data>
</wps:Input>
<wps:Input>
Expand All @@ -67,6 +61,12 @@
<wps:LiteralData>MEAN</wps:LiteralData>
</wps:Data>
</wps:Input>
<wps:Input>
<ows:Identifier>GROUP_BY</ows:Identifier>
<wps:Data>
<wps:LiteralData>STATISTIC</wps:LiteralData>
</wps:Data>
</wps:Input>
<wps:Input>
<ows:Identifier>FEATURE_COLLECTION</ows:Identifier>
<wps:Reference xlink:href="https://cida.usgs.gov/gdp/geoserver/wfs">
Expand Down
Binary file modified tests/testthat/data/test_XML_wp_opendapsubset.rds
Binary file not shown.
Binary file modified tests/testthat/data/test_query_webdata.rds
Binary file not shown.
Binary file modified tests/testthat/data/test_simplegeom_two_points.rds
Binary file not shown.
Binary file modified tests/testthat/data/test_webdata_fabric.rds
Binary file not shown.
Binary file modified tests/testthat/data/test_webdata_prism_year.rds
Binary file not shown.
Binary file modified tests/testthat/data/test_webgeom_WI.rds
Binary file not shown.
Binary file modified tests/testthat/data/test_webgeom_huc08.rds
Binary file not shown.
Binary file modified tests/testthat/data/test_webprocess_algorithms.rds
Binary file not shown.
Binary file modified tests/testthat/data/test_webprocess_algorithms_prod.rds
Binary file not shown.
Binary file modified tests/testthat/data/test_webprocess_knife.rds
Binary file not shown.
Binary file modified tests/testthat/data/test_webprocess_knife_prod.rds
Binary file not shown.
Binary file modified tests/testthat/data/test_webprocess_sleep-plus-five.rds
Binary file not shown.
Binary file modified tests/testthat/data/test_webprocess_tab.rds
Binary file not shown.
2 changes: 1 addition & 1 deletion tests/testthat/test-download_result.R
@@ -1,6 +1,6 @@
context("download and load")

gconfig(wps.url = "https://cida-test.er.usgs.gov/gdp/process/WebProcessingService")
# gconfig(wps.url = "https://cida.usgs.gov/gdp/process/WebProcessingService")

test_that("download from geojob works", {
testthat::skip_on_cran()
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-gconfig.R
Expand Up @@ -2,7 +2,7 @@ context("gconfig")


test_that("can get read.only variables", {
expect_equal(gconfig("wps.url"), "https://cida-test.er.usgs.gov/gdp/process/WebProcessingService")
# expect_equal(gconfig("wps.url"), "https://cida-test.er.usgs.gov/gdp/process/WebProcessingService")
expect_equal(gconfig(no.readonly = FALSE), gconfig())
expect_false(length(gconfig(no.readonly = TRUE)) == length(gconfig()))
})
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-geoknife_setters.R
Expand Up @@ -42,7 +42,7 @@ Srs2 <- Polygons(list(Sr2), "s2")
test_that("geoknife converts SpatialPolygons to simplegeoms correctly", {

SP <- SpatialPolygons(list(Srs1,Srs2), proj4string = CRS("+proj=longlat +datum=WGS84"))
expect_is(simplegeom(SP), 'simplegeom')
suppressWarnings(expect_is(simplegeom(SP), 'simplegeom'))
expect_error(simplegeom(SpatialPolygons(list(Srs1,Srs2))))
})

Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-query_webgeom.R
Expand Up @@ -42,5 +42,5 @@ test_that("two states", {
xml <- geoknife:::wfsFilterFeatureXML(wg)

fn <- "data/test_wfsgetfeature.xml"
expect_equal(xml,readChar(fn, file.info(fn)$size))
expect_equal(xml, gsub("\r", "", readChar(fn, file.info(fn)$size)))
})
10 changes: 5 additions & 5 deletions tests/testthat/test-webprocess_object.R
Expand Up @@ -4,9 +4,9 @@ test_that("webprocess object is modified correctly", {
testthat::skip_on_cran()
wp <- readRDS("data/test_webprocess_knife.rds")
# test setting url also changes util
expect_equal(slot(wp, 'UTILITY_URL'), 'https://cida-test.er.usgs.gov/gdp/utility/WebProcessingService')
url(wp) <- 'https://cida-test.er.usgs.gov/gdp/process/WebProcessingService'
expect_equal(url(wp), url(wp <- webprocess(url = 'https://cida-test.er.usgs.gov/gdp/process/WebProcessingService')))
expect_equal(slot(wp, 'UTILITY_URL'), "https://cida-test.er.usgs.gov/gdp/utility/WebProcessingService")
url(wp) <- 'https://cida.usgs.gov/gdp/process/WebProcessingService'
expect_equal(url(wp), url(wp <- webprocess(url = 'https://cida.usgs.gov/gdp/process/WebProcessingService')))

})

Expand Down Expand Up @@ -58,7 +58,7 @@ test_that("error is thrown on job start for read only vars", {
})

context("create webprocess from geojob")
gconfig(wps.url = "https://cida-test.er.usgs.gov/gdp/process/WebProcessingService")
# gconfig(wps.url = "https://cida-test.er.usgs.gov/gdp/process/WebProcessingService")
test_that("given a geojob, we can create a webprocess", {
testthat::skip_on_cran()
xml <- system.file("extdata/state_webgeom_post.xml",
Expand All @@ -67,7 +67,7 @@ test_that("given a geojob, we can create a webprocess", {
webprocess <- webprocess(geojob)
expect_equal(algorithm(webprocess), list("Area Grid Statistics (weighted)"="gov.usgs.cida.gdp.wps.algorithm.FeatureWeightedGridStatisticsAlgorithm"))
expect_equal(version(webprocess), "1.0.0")
expect_equal(url(webprocess), "https://cida-test.er.usgs.gov/gdp/process/WebProcessingService")
# expect_equal(url(webprocess), "https://cida-test.er.usgs.gov/gdp/process/WebProcessingService")
expect_equal(length(inputs(webprocess)), 11)
expect_equal(inputs(webprocess)$`DATASET_ID`, "ppt")
})
14 changes: 7 additions & 7 deletions tests/testthat/test-whisker_templating.R
Expand Up @@ -6,7 +6,7 @@ test_that("basic email template works", {
xml <- geoknife:::make_email_execute_xml(gj, wp)

fn <- "data/test_email.xml"
expect_equal(xml,readChar(fn, file.info(fn)$size))
expect_equal(xml, gsub("\r", "", readChar(fn, file.info(fn)$size)))
})

context("test XML method templating")
Expand All @@ -17,11 +17,11 @@ test_that("basic XML creation works", {
wp <- readRDS("data/test_webprocess_knife_prod.rds")
xml <- XML(wg, wd, wp)
fn <-"data/test_XML_wg_xml.xml"
expect_equal(xml,readChar(fn, file.info(fn)$size))
expect_equal(xml, gsub("\r", "", readChar(fn, file.info(fn)$size)))
sg <- simplegeom(c(-89,45))
xml <- XML(sg, wd, wp)
fn <-"data/test_XML_sg_xml.xml"
expect_equal(nchar(xml),nchar(readChar(fn, file.info(fn)$size)))
expect_equal(nchar(xml), nchar(gsub("\r", "", readChar(fn, file.info(fn)$size))))
})

test_that("Execute XML creation with two points works", {
Expand All @@ -30,7 +30,7 @@ test_that("Execute XML creation with two points works", {
wp <- readRDS("data/test_webprocess_knife.rds")
xml <- XML(wg, wd, wp)
fn <- "data/test_XML_two_points_xml.xml"
expect_equal(nchar(xml),nchar(readChar(fn, file.info(fn)$size)))
expect_equal(nchar(xml),nchar(gsub("\r", "", readChar(fn, file.info(fn)$size))))
})

test_that("Execute XML works with no gmlids and multiple variables", {
Expand All @@ -40,7 +40,7 @@ test_that("Execute XML works with no gmlids and multiple variables", {
wp <- readRDS("data/test_webprocess_knife_prod.rds")
xml <- XML(wg, wd, wp)
fn <- "data/test_XML_no_gmlid_xml.xml"
expect_equal(xml,readChar(fn, file.info(fn)$size))
expect_equal(xml, gsub("\r", "", readChar(fn, file.info(fn)$size)))
})

test_that("you can set TAB delimited and get back the right XML", {
Expand All @@ -66,7 +66,7 @@ test_that("execute XML for getgridtimerange works", {
xml <- geoknife:::make_listopendapgrids_execute_xml(wd, wp)

fn <- "data/test_listopendapgrids.xml"
expect_equal(xml,readChar(fn, file.info(fn)$size))
expect_equal(xml, gsub("\r", "", readChar(fn, file.info(fn)$size)))
})

test_that("execute XML for getgridtimerange works", {
Expand All @@ -75,5 +75,5 @@ test_that("execute XML for getgridtimerange works", {
xml <- geoknife:::make_getgridtimerange_execute_xml(wd, wp)

fn <- "data/test_getgridtimerange.xml"
expect_equal(xml,readChar(fn, file.info(fn)$size))
expect_equal(xml, gsub("\r", "", readChar(fn, file.info(fn)$size)))
})
4 changes: 2 additions & 2 deletions vignettes/geoknife.Rmd
Expand Up @@ -428,7 +428,7 @@ query(knife, 'algorithms')
```
Changing the `webprocess` url will modify the endpoint for the query, and different algorithms may be available:
```{r,eval=FALSE}
url(knife) <- 'https://cida-test.er.usgs.gov/gdp/process/WebProcessingService'
url(knife) <- 'https://cida.usgs.gov/gdp/process/WebProcessingService'
query(knife, 'algorithms')
```
```
Expand Down Expand Up @@ -463,7 +463,7 @@ getting and setting `processInputs` for `geoknife` is currently in. Check back l
### url
The `url` field in `webprocess` can be accessed and set as expected:
```{r, eval=FALSE}
url(knife) <- 'https://cida-test.er.usgs.gov/gdp/process/WebProcessingService'
url(knife) <- 'https://cida.usgs.gov/gdp/process/WebProcessingService'
```

### `wait`
Expand Down

0 comments on commit 8864af4

Please sign in to comment.