Skip to content

Commit

Permalink
httptest2 mock test-osmdata for #272
Browse files Browse the repository at this point in the history
  • Loading branch information
mpadge committed Jun 2, 2022
1 parent ef0adbf commit 13f8b4f
Show file tree
Hide file tree
Showing 11 changed files with 1,392 additions and 8 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: osmdata
Title: Import 'OpenStreetMap' Data as Simple Features or Spatial Objects
Version: 0.1.9.019
Version: 0.1.9.020
Authors@R: c(
person("Mark", "Padgham", , "mark.padgham@email.com", role = c("aut", "cre")),
person("Bob", "Rudis", role = "aut"),
Expand Down
2 changes: 1 addition & 1 deletion codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"codeRepository": "https://github.com/ropensci/osmdata/",
"issueTracker": "https://github.com/ropensci/osmdata/issues",
"license": "https://spdx.org/licenses/GPL-3.0",
"version": "0.1.9.019",
"version": "0.1.9.020",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Connected as: 177471748
Current time: 2022-06-02T11:51:30Z
Rate limit: 0
Currently running queries (pid, space limit, time limit, start time):
2401657 536870912 100000 2022-06-02T11:50:04Z
2402214 536870912 180 2022-06-02T11:51:30Z

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Connected as: 177471748
Current time: 2022-06-02T11:50:06Z
Rate limit: 0
Currently running queries (pid, space limit, time limit, start time):

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions tests/testthat/mock_osm_xml/overpass.kumi.systems/api/status.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Connected as: 177471748
Current time: 2022-06-02T11:47:28Z
Rate limit: 0
Currently running queries (pid, space limit, time limit, start time):
2910353 536870912 100000 2022-06-02T11:46:34Z
2910591 536870912 900 2022-06-02T11:47:01Z
2910728 536870912 900 2022-06-02T11:47:15Z
2910725 536870912 900 2022-06-02T11:47:15Z
2910788 536870912 180 2022-06-02T11:47:24Z
2910803 536870912 180 2022-06-02T11:47:27Z
2910801 536870912 180 2022-06-02T11:47:27Z
2910802 536870912 180 2022-06-02T11:47:27Z
2910804 536870912 180 2022-06-02T11:47:28Z
2910807 536870912 180 2022-06-02T11:47:28Z

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Connected as: 177471748
Current time: 2022-06-02T11:48:56Z
Rate limit: 0
Currently running queries (pid, space limit, time limit, start time):
2400777 536870912 180 2022-06-02T11:48:56Z
23 changes: 17 additions & 6 deletions tests/testthat/test-osmdata.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ test_that ("add feature", {

test_that ("make_query", {

qry <- opq (bbox = c(-0.118, 51.514, -0.115, 51.517))
qry <- opq (bbox = c(-0.116, 51.516, -0.115, 51.517))
qry <- add_osm_feature (qry, key = "highway")

if (!has_internet) {
Expand All @@ -65,13 +65,22 @@ test_that ("make_query", {
"Overpass query unavailable without internet")
} else {

doc <- osmdata_xml (qry)
doc <- with_mock_dir ("mock_osm_xml", {
osmdata_xml (qry)
})
expect_true (is (doc, "xml_document"))
expect_silent (osmdata_xml (qry, file = "junk.osm"))
expect_silent (
doc2 <- with_mock_dir ("mock_osm_xml2", {
osmdata_xml (qry, file = "junk.osm")
})
)
expect_equal (doc, doc2)

if (test_all) {
res <- osmdata_sp (qry)
expect_equal (res, print (res))

res <- with_mock_dir ("mock_osm_sp", {
osmdata_sp (qry)
})
expect_message (print (res), "Object of class 'osmdata' with")
expect_silent (res <- osmdata_sp (qry, doc))
expect_message (print (res), "Object of class 'osmdata' with")
Expand All @@ -86,7 +95,9 @@ test_that ("make_query", {
nms <- c ("timestamp", "OSM_version", "overpass_version")
expect_named (res$meta, expected = nms)

res <- osmdata_sf (qry)
res <- with_mock_dir ("mock_osm_sf", {
osmdata_sf (qry)
})
expect_message (print (res), "Object of class 'osmdata' with")
expect_silent (res <- osmdata_sf (qry, doc))
expect_message (print (res), "Object of class 'osmdata' with")
Expand Down

0 comments on commit 13f8b4f

Please sign in to comment.