Skip to content

Commit

Permalink
62 cran tests exit gracefully (#64)
Browse files Browse the repository at this point in the history
* update version

* Fix tests in accordance with cran policy to not skip unless internet resource is down and provide useful message. Closes #62
  • Loading branch information
JustinCally committed Jun 14, 2023
1 parent 8dc6ab8 commit d240496
Show file tree
Hide file tree
Showing 11 changed files with 49 additions and 63 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
@@ -1,6 +1,6 @@
Package: VicmapR
Title: Access Victorian Spatial Data Through Web File Services (WFS)
Version: 0.2.0.9000
Version: 0.2.2
Authors@R:
c(person(given = "Justin",
family = "Cally",
Expand Down
5 changes: 4 additions & 1 deletion NEWS.md
@@ -1,4 +1,7 @@
# VicmapR (development version)
# VicmapR 0.2.2
* Exits test if internet resource is not available and providees an informative message as per CRAN policy

# VicmapR 0.2.1
* Fixed CRAN issue with tests running on internet resources

# VicmapR 0.2.0
Expand Down
46 changes: 23 additions & 23 deletions README.md
Expand Up @@ -119,7 +119,7 @@ melbourne <- sf::st_read(system.file("shapes/melbourne.geojson", package="Vicmap

# Obtain a promise of what data will be returned for a given layer
vicmap_query(layer = "open-data-platform:hy_watercourse")
#> • Using collect() on this object will return 1837814 features and 21
#> • Using collect() on this object will return 1835052 features and 21
#> • fields
#> • At most six rows of the record are printed here
#> ────────────────────────────────────────────────────────────────────────────────
Expand All @@ -129,20 +129,20 @@ vicmap_query(layer = "open-data-platform:hy_watercourse")
#> Bounding box: xmin: 146.3073 ymin: -38.9966 xmax: 146.3657 ymax: -38.9847
#> Geodetic CRS: GDA94
#> # A tibble: 6 × 21
#> id ufi pfi featu…¹ name named…² origin const…³ usage hiera…⁴ featu…⁵
#> <chr> <int> <int> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <int>
#> 1 hy_w… 3.63e6 9.63e6 waterc… <NA> <NA> 1 <NA> 1 L 4762
#> 2 hy_w… 3.63e6 9.63e6 waterc… <NA> <NA> 1 <NA> 1 L 4762
#> 3 hy_w… 3.63e6 9.63e6 waterc… <NA> <NA> 1 <NA> 1 L 4762
#> 4 hy_w… 3.63e6 9.63e6 waterc… <NA> <NA> 1 <NA> 1 L 4762
#> 5 hy_w… 3.63e6 9.63e6 waterc… <NA> <NA> 1 <NA> 1 L 4762
#> 6 hy_w… 3.63e6 9.63e6 waterc… <NA> <NA> 1 <NA> 1 L 4762
#> # … with 10 more variables: create_date_pfi <dttm>, superceded_pfi <chr>,
#> # create_date_ufi <dttm>, auth_org_code <chr>, auth_org_id <chr>,
#> # auth_org_verified <chr>, task_id <chr>, feature_ufi <int>,
#> # feature_create_date_ufi <dttm>, geometry <LINESTRING [°]>, and abbreviated
#> # variable names ¹​feature_type_code, ²​named_feature_id, ³​construction,
#> # ⁴​hierarchy, ⁵​feature_quality_id
#> id ufi pfi featu…¹ name named…² origin const…³ usage hiera…⁴ auth_…⁵
#> <chr> <int> <int> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 hy_w… 3.63e6 9.63e6 waterc… <NA> <NA> 1 <NA> 1 L <NA>
#> 2 hy_w… 3.63e6 9.63e6 waterc… <NA> <NA> 1 <NA> 1 L <NA>
#> 3 hy_w… 3.63e6 9.63e6 waterc… <NA> <NA> 1 <NA> 1 L <NA>
#> 4 hy_w… 3.63e6 9.63e6 waterc… <NA> <NA> 1 <NA> 1 L <NA>
#> 5 hy_w… 3.63e6 9.63e6 waterc… <NA> <NA> 1 <NA> 1 L <NA>
#> 6 hy_w… 3.63e6 9.63e6 waterc… <NA> <NA> 1 <NA> 1 L <NA>
#> # … with 10 more variables: auth_org_id <chr>, auth_org_verified <chr>,
#> # feature_quality_id <int>, task_id <chr>, create_date_pfi <dttm>,
#> # superceded_pfi <chr>, feature_ufi <int>, feature_create_date_ufi <dttm>,
#> # create_date_ufi <dttm>, geometry <LINESTRING [°]>, and abbreviated variable
#> # names ¹​feature_type_code, ²​named_feature_id, ³​construction, ⁴​hierarchy,
#> # ⁵​auth_org_code

# Build a more specific query and collect the results
vicmap_query(layer = "open-data-platform:hy_watercourse") %>% # layer to query
Expand All @@ -158,14 +158,14 @@ vicmap_query(layer = "open-data-platform:hy_watercourse") %>% # layer to query
#> # A tibble: 8 × 4
#> id pfi hierarchy geometry
#> <chr> <int> <chr> <LINESTRING [°]>
#> 1 hy_watercourse.1657019 19272791 L (144.9287 -37.8033, 144.9186 -37.80
#> 2 hy_watercourse.1658128 14608551 L (144.9201 -37.79069, 144.9202 -37.7
#> 3 hy_watercourse.763289 14577596 L (144.929 -37.81409, 144.9294 -37.81
#> 4 hy_watercourse.763296 14577602 L (144.9288 -37.81417, 144.9292 -37.8
#> 5 hy_watercourse.1191058 14608731 L (144.9365 -37.81511, 144.9359 -37.8
#> 6 hy_watercourse.1183410 17520306 L (144.9415 -37.78232, 144.9414 -37.7…
#> 7 hy_watercourse.1183418 14615146 L (144.9442 -37.78198, 144.9441 -37.7
#> 8 hy_watercourse.1183482 14608434 L (144.9403 -37.78253, 144.9401 -37.7…
#> 1 hy_watercourse.763443 14577596 L (144.929 -37.81409, 144.9294 -37.81
#> 2 hy_watercourse.763452 14577602 L (144.9288 -37.81417, 144.9292 -37.8
#> 3 hy_watercourse.1191149 14608731 L (144.9365 -37.81511, 144.9359 -37.8
#> 4 hy_watercourse.1183449 17520306 L (144.9415 -37.78232, 144.9414 -37.7
#> 5 hy_watercourse.1183457 14615146 L (144.9442 -37.78198, 144.9441 -37.7
#> 6 hy_watercourse.1183525 14608434 L (144.9403 -37.78253, 144.9401 -37.7…
#> 7 hy_watercourse.1651720 19272791 L (144.9287 -37.8033, 144.9186 -37.80
#> 8 hy_watercourse.1652842 14608551 L (144.9201 -37.79069, 144.9202 -37.7…
```

VicmapR translates numerous geometric filter functions available in the
Expand Down
4 changes: 2 additions & 2 deletions cran-comments.md
@@ -1,5 +1,5 @@
## Submission 0.2.0 (2023-05-24)
+ Fixed CRAN issue with tests running on internet resources
## Submission 0.2.2 (2023-06-14)
+ Exits test if internet resource is not available and provides an informative message as per CRAN policy

## Submission 0.2.0 (2023-04-11)
+ Changes to the internal elements of the package to use a new database url
Expand Down
15 changes: 5 additions & 10 deletions tests/testthat/test-build-query.R
Expand Up @@ -14,8 +14,7 @@ geoserver_down <- !(check_geoserver(timeout = 5, quiet = TRUE))

test_that("vicmap_query works", {
skip_if_offline()
skip_on_cran()
skip_if(geoserver_down)
skip_if(geoserver_down, message = "VicmapR geoserver not currently available")

q <- vicmap_query(layer = "open-data-platform:hy_watercourse", CRS = 3111, wfs_version = "1.0.0")
q2 <- vicmap_query(layer = "open-data-platform:hy_watercourse", wfs_version = "2.0.0")
Expand All @@ -41,17 +40,15 @@ test_that("vicmap_query works", {

test_that("print.vicmap_promise works", {
skip_if_offline()
skip_on_cran()
skip_if(geoserver_down)
skip_if(geoserver_down, message = "VicmapR geoserver not currently available")

expect_error(print(vicmap_query('not a layer')), regexp = "Bad Request [(]HTTP 400[)].")
expect_output(print(vicmap_query(layer = "open-data-platform:hy_watercourse", wfs_version = "2.0.0")), regexp = NULL)
})

test_that("head.vicmap_promise works", {
skip_if_offline()
skip_on_cran()
skip_if(geoserver_down)
skip_if(geoserver_down, message = "VicmapR geoserver not currently available")

r <- vicmap_query(layer = "open-data-platform:hy_watercourse") %>%
head(10) %>%
Expand All @@ -63,8 +60,7 @@ test_that("head.vicmap_promise works", {

test_that("collect.vicmap_promise works", {
skip_if_offline()
skip_on_cran()
skip_if(geoserver_down)
skip_if(geoserver_down, message = "VicmapR geoserver not currently available")

d <- vicmap_query(layer = "open-data-platform:hy_watercourse") %>%
head(10) %>%
Expand All @@ -84,8 +80,7 @@ test_that("collect.vicmap_promise works", {

test_that("show_query.vicmap_promise works", {
skip_if_offline()
skip_on_cran()
skip_if(geoserver_down)
skip_if(geoserver_down, message = "VicmapR geoserver not currently available")

expect_output({vicmap_query(layer = "open-data-platform:hy_watercourse") %>%
show_query()}, regexp = NULL)
Expand Down
3 changes: 1 addition & 2 deletions tests/testthat/test-check_geoserver.R
Expand Up @@ -14,8 +14,7 @@ geoserver_down <- !(check_geoserver(timeout = 5, quiet = TRUE))

test_that("Check geoserver works", {
skip_if_offline()
skip_on_cran()
skip_if(geoserver_down)
skip_if(geoserver_down, message = "VicmapR geoserver not currently available")

expect_error(check_geoserver(timeout = 0.001))

Expand Down
11 changes: 4 additions & 7 deletions tests/testthat/test-citation.R
Expand Up @@ -14,8 +14,7 @@ geoserver_down <- !(check_geoserver(timeout = 5, quiet = TRUE))

test_that("get_metadata works", {
skip_if_offline()
skip_on_cran()
skip_if(geoserver_down)
skip_if(geoserver_down, message = "VicmapR geoserver not currently available")

r <- get_metadata(vicmap_query(layer = "open-data-platform:hy_watercourse"))

Expand All @@ -33,8 +32,7 @@ test_that("get_metadata works", {

test_that("data_dictionary works", {
skip_if_offline()
skip_on_cran()
skip_if(geoserver_down)
skip_if(geoserver_down, message = "VicmapR geoserver not currently available")

r <- data_dictionary(vicmap_query(layer = "open-data-platform:apiary"))

Expand All @@ -44,11 +42,10 @@ test_that("data_dictionary works", {

test_that("data_citation works", {
skip_if_offline()
skip_on_cran()
skip_if(geoserver_down)
skip_if(geoserver_down, message = "VicmapR geoserver not currently available")

data_citation(vicmap_query(layer = "open-data-platform:basins"))

expect_output({data_citation(vicmap_query(layer = "open-data-platform:basins"))})

})
})
11 changes: 4 additions & 7 deletions tests/testthat/test-convert-layer-names.R
Expand Up @@ -15,8 +15,7 @@ geoserver_down <- !(check_geoserver(timeout = 5, quiet = TRUE))
test_that("convert layer name works", {

skip_if_offline()
skip_on_cran()
skip_if(geoserver_down)
skip_if(geoserver_down, message = "VicmapR geoserver not currently available")

r1 <- vicmap_query(layer = "datavic:VMHYDRO_WATERCOURSE_DRAIN") %>%
head(10) %>%
Expand All @@ -36,8 +35,7 @@ test_that("convert layer name works", {
test_that("convert layer filter works", {

skip_if_offline()
skip_on_cran()
skip_if(geoserver_down)
skip_if(geoserver_down, message = "VicmapR geoserver not currently available")

r3 <- vicmap_query(layer = "datavic:VMHYDRO_WATERCOURSE_DRAIN") %>%
filter(HIERARCHY == "L" & PFI == 8547514) %>%
Expand All @@ -55,8 +53,7 @@ test_that("convert layer filter works", {
test_that("convert layer select works", {

skip_if_offline()
skip_on_cran()
skip_if(geoserver_down)
skip_if(geoserver_down, message = "VicmapR geoserver not currently available")

r5 <- vicmap_query(layer = "datavic:VMHYDRO_WATERCOURSE_DRAIN") %>%
select(HIERARCHY, PFI) %>%
Expand All @@ -70,4 +67,4 @@ test_that("convert layer select works", {
collect()

expect_equal(r5, r6)
})
})
9 changes: 3 additions & 6 deletions tests/testthat/test-filter.R
Expand Up @@ -14,8 +14,7 @@ geoserver_down <- !(check_geoserver(timeout = 5, quiet = TRUE))

test_that("filter works", {
skip_if_offline()
skip_on_cran()
skip_if(geoserver_down)
skip_if(geoserver_down, message = "VicmapR geoserver not currently available")

r <- vicmap_query("open-data-platform:hy_watercourse", wfs_version = "2.0.0") %>%
filter(hierarchy == "L", pfi == 8553127)
Expand All @@ -25,8 +24,7 @@ test_that("filter works", {

test_that("passing an non-existent object to a geom predicate", {
skip_if_offline()
skip_on_cran()
skip_if(geoserver_down)
skip_if(geoserver_down, message = "VicmapR geoserver not currently available")

expect_error(vicmap_query("open-data-platform:hy_watercourse") %>%
filter(INTERSECTS(districts)))
Expand All @@ -35,8 +33,7 @@ test_that("passing an non-existent object to a geom predicate", {

test_that("geometric filter works", {
skip_if_offline()
skip_on_cran()
skip_if(geoserver_down)
skip_if(geoserver_down, message = "VicmapR geoserver not currently available")
skip_if(!(sf::sf_extSoftVersion()[["GDAL"]] > 3))

polygon <- sf::st_read(system.file("shapes/melbourne.geojson", package="VicmapR"), quiet = TRUE)
Expand Down
3 changes: 1 addition & 2 deletions tests/testthat/test-listLayers.R
Expand Up @@ -14,8 +14,7 @@ geoserver_down <- !(check_geoserver(timeout = 5, quiet = TRUE))

test_that("listLayers works", {
skip_if_offline()
skip_on_cran()
skip_if(geoserver_down)
skip_if(geoserver_down, message = "VicmapR geoserver not currently available")

full_ll <- listLayers(pattern = "trees", ignore.case = TRUE)
sub_ll <- listLayers(abstract = FALSE)
Expand Down
3 changes: 1 addition & 2 deletions tests/testthat/test-utils-metadata.R
Expand Up @@ -14,8 +14,7 @@ geoserver_down <- !(check_geoserver(timeout = 5, quiet = TRUE))

test_that("feature_hits() works", {
skip_if_offline()
skip_on_cran()
skip_if(geoserver_down)
skip_if(geoserver_down, message = "VicmapR geoserver not currently available")

expect_equal(vicmap_query("open-data-platform:hy_watercourse", wfs_version = "2.0.0") %>%
filter(hierarchy == "L", pfi == 8553127) %>%
Expand Down

0 comments on commit d240496

Please sign in to comment.