Skip to content

Commit a964f43

Browse files
committed
lint test files
1 parent 3e26f8c commit a964f43

8 files changed

+50
-29
lines changed

DESCRIPTION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: osmdata
22
Title: Import 'OpenStreetMap' Data as Simple Features or Spatial Objects
3-
Version: 0.1.9.054
3+
Version: 0.1.9.055
44
Authors@R: c(
55
person("Mark", "Padgham", , "[email protected]", role = c("aut", "cre")),
66
person("Bob", "Rudis", role = "aut"),

codemeta.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"codeRepository": "https://github.com/ropensci/osmdata/",
1212
"issueTracker": "https://github.com/ropensci/osmdata/issues",
1313
"license": "https://spdx.org/licenses/GPL-3.0",
14-
"version": "0.1.9.054",
14+
"version": "0.1.9.055",
1515
"programmingLanguage": {
1616
"@type": "ComputerLanguage",
1717
"name": "R",

tests/testthat/test-opq.R

+7-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ test_that ("opq_string", {
5959
)
6060
expect_message (
6161
s0 <- opq_string_intern (q0, quiet = FALSE),
62-
"The overpass server is intended to be used to extract specific features"
62+
paste0 (
63+
"The overpass server is intended to ",
64+
"be used to extract specific features"
65+
)
6366
)
6467
expect_type (s0, "character")
6568
expect_length (s0, 1L)
@@ -189,7 +192,9 @@ test_that ("opq_around", {
189192
expect_true (grepl ("key", x_key))
190193
expect_false (grepl ("value", x_key))
191194

192-
expect_silent (x_key_val <- opq_around (lon, lat, key = "key", value = "val"))
195+
expect_silent (
196+
x_key_val <- opq_around (lon, lat, key = "key", value = "val")
197+
)
193198
expect_true (!identical (x_key, x_key_val))
194199
expect_true (grepl ("key", x_key_val))
195200
expect_true (grepl ("val", x_key_val))

tests/testthat/test-osmdata.R

+10-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,12 @@ test_that ("add feature", {
6161
bbox <- c (-0.118, 51.514, -0.115, 51.517)
6262
qry <- opq (bbox = bbox)
6363
bbox2 <- bbox + c (0.01, 0.01, -0.01, -0.01)
64-
qry6 <- add_osm_feature (qry, bbox = bbox2, key = "highway", value = "!primary")
64+
qry6 <- add_osm_feature (
65+
qry,
66+
bbox = bbox2,
67+
key = "highway",
68+
value = "!primary"
69+
)
6570
expect_true (!identical (qry$bbox, qry6$bbox))
6671
})
6772

@@ -214,7 +219,10 @@ test_that ("add_osm_features", {
214219
qry <- opq (bbox = c (-0.118, 51.514, -0.115, 51.517))
215220
expect_error (
216221
qry <- add_osm_features (qry, features = "a"),
217-
"features must be enclosed in escape-delimited quotations \\(see example\\)"
222+
paste0 (
223+
"features must be enclosed in escape-delimited ",
224+
"quotations \\(see example\\)"
225+
)
218226
)
219227

220228
bbox <- c (-0.118, 51.514, -0.115, 51.517)

tests/testthat/test-sf-construction.R

+6-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ make_sfc <- function (x, type) {
1818
}
1919
xvals <- xy [, 1]
2020
yvals <- xy [, 2]
21-
bb <- structure (rep (NA_real_, 4), names = c ("xmin", "ymin", "xmax", "ymax"))
21+
bb <- structure (
22+
rep (NA_real_, 4),
23+
names = c ("xmin", "ymin", "xmax", "ymax")
24+
)
2225
bb [1:4] <- c (min (xvals), min (yvals), max (xvals), max (yvals))
2326
class (bb) <- "bbox"
2427
if (type == "POLYGON") {
@@ -45,14 +48,14 @@ make_sfc <- function (x, type) {
4548
attr (x, "bbox") <- bb
4649

4750
if (packageVersion ("sf") < 0.9) {
48-
NA_crs_ <- structure (list (
51+
NA_crs_ <- structure (list ( # nolint
4952
epsg = NA_integer_, # nolint
5053
proj4string = NA_character_
5154
), # nolint
5255
class = "crs"
5356
)
5457
} else {
55-
NA_crs_ <- structure (list (
58+
NA_crs_ <- structure (list ( # nolint
5659
input = NA_character_, # nolint
5760
wkt = NA_character_
5861
), # nolint

tests/testthat/test-sf-osm.R

+13-6
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@ test_all <- (identical (Sys.getenv ("MPADGE_LOCAL"), "true") |
44
identical (Sys.getenv ("GITHUB_WORKFLOW"), "test-coverage"))
55

66
test_that ("multipolygon", {
7-
x_sf <- sf::st_read (test_path ("fixtures", "osm-multi.osm"),
7+
osm_multi <- test_path ("fixtures", "osm-multi.osm")
8+
x_sf <- sf::st_read (
9+
osm_multi,
810
layer = "multipolygons",
911
stringsAsFactors = FALSE,
1012
quiet = TRUE
1113
)
1214
q0 <- opq (bbox = c (1, 1, 5, 5))
13-
x <- osmdata_sf (q0, test_path ("fixtures", "osm-multi.osm"))$osm_multipolygons
15+
x <- osmdata_sf (q0, osm_multi)$osm_multipolygons
16+
1417
# GDAL spits out a whole lot of generic field names, so first the
1518
# two have to be reduced to common fields.
1619
x <- x [, which (names (x) %in% names (x_sf))]
@@ -47,13 +50,15 @@ test_that ("multipolygon", {
4750

4851

4952
test_that ("multilinestring", {
50-
x_sf <- sf::st_read (test_path ("fixtures", "osm-multi.osm"),
53+
osm_multi <- test_path ("fixtures", "osm-multi.osm")
54+
x_sf <- sf::st_read (
55+
osm_multi,
5156
layer = "multilinestrings",
5257
stringsAsFactors = FALSE,
5358
quiet = TRUE
5459
)
5560
q0 <- opq (bbox = c (1, 1, 5, 5))
56-
x <- osmdata_sf (q0, test_path ("fixtures", "osm-multi.osm"))$osm_multilines
61+
x <- osmdata_sf (q0, osm_multi)$osm_multilines
5762
x <- x [, which (names (x) %in% names (x_sf))]
5863
x_sf <- x_sf [, which (names (x_sf) %in% names (x))]
5964
rownames (x_sf) <- rownames (x)
@@ -80,13 +85,15 @@ test_that ("multilinestring", {
8085
})
8186

8287
test_that ("ways", {
83-
x_sf <- sf::st_read (test_path ("fixtures", "osm-ways.osm"),
88+
osm_ways <- test_path ("fixtures", "osm-ways.osm")
89+
x_sf <- sf::st_read (
90+
osm_ways,
8491
layer = "lines",
8592
stringsAsFactors = FALSE,
8693
quiet = TRUE
8794
)
8895
q0 <- opq (bbox = c (1, 1, 5, 5))
89-
x <- osmdata_sf (q0, test_path ("fixtures", "osm-ways.osm"))$osm_lines
96+
x <- osmdata_sf (q0, osm_ways)$osm_lines
9097
x <- x [, which (names (x) %in% names (x_sf))]
9198
x_sf <- x_sf [, which (names (x_sf) %in% names (x))]
9299
rownames (x_sf) <- rownames (x)

tests/testthat/test-sp-osm.R

+9-12
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
context ("sp-osm")
22

33
test_that ("multipolygon", {
4-
x_sf <- sf::st_read (test_path ("fixtures", "osm-multi.osm"),
5-
layer = "multipolygons", quiet = TRUE
6-
)
4+
osm_multi <- test_path ("fixtures", "osm-multi.osm")
5+
x_sf <- sf::st_read (osm_multi, layer = "multipolygons", quiet = TRUE)
76
x_sp <- as (x_sf, "Spatial")
87
q0 <- opq (bbox = c (1, 1, 5, 5))
9-
x <- osmdata_sp (q0, test_path ("fixtures", "osm-multi.osm"))$osm_multipolygons
8+
x <- osmdata_sp (q0, osm_multi)$osm_multipolygons
109
# GDAL spits out a whole lot of generic field names, so first the
1110
# two have to be reduced to common fields.
1211
x <- x [, which (names (x) %in% names (x_sp))]
@@ -59,12 +58,11 @@ test_that ("multipolygon", {
5958

6059

6160
test_that ("multilinestring", {
62-
x_sf <- sf::st_read (test_path ("fixtures", "osm-multi.osm"),
63-
layer = "multilinestrings", quiet = TRUE
64-
)
61+
osm_multi <- test_path ("fixtures", "osm-multi.osm")
62+
x_sf <- sf::st_read (osm_multi, layer = "multilinestrings", quiet = TRUE)
6563
x_sp <- as (x_sf, "Spatial")
6664
q0 <- opq (bbox = c (1, 1, 5, 5))
67-
x <- osmdata_sp (q0, test_path ("fixtures", "osm-multi.osm"))$osm_multilines
65+
x <- osmdata_sp (q0, osm_multi)$osm_multilines
6866
x <- x [, which (names (x) %in% names (x_sp))]
6967
x_sp <- x_sp [, which (names (x_sp) %in% names (x))]
7068
rownames (slot (x, "data")) <- rownames (slot (x_sp, "data"))
@@ -96,12 +94,11 @@ test_that ("multilinestring", {
9694
})
9795

9896
test_that ("ways", {
99-
x_sf <- sf::st_read (test_path ("fixtures", "osm-ways.osm"),
100-
layer = "lines", quiet = TRUE
101-
)
97+
osm_ways <- test_path ("fixtures", "osm-ways.osm")
98+
x_sf <- sf::st_read (osm_ways, layer = "lines", quiet = TRUE)
10299
x_sp <- as (x_sf, "Spatial")
103100
q0 <- opq (bbox = c (1, 1, 5, 5))
104-
x <- osmdata_sp (q0, test_path ("fixtures", "osm-ways.osm"))$osm_lines
101+
x <- osmdata_sp (q0, osm_ways)$osm_lines
105102
x <- x [, which (names (x) %in% names (x_sp))]
106103
x_sp <- x_sp [, which (names (x_sp) %in% names (x))]
107104
np <- length (slot (slot (x, "lines") [[1]], "Lines"))

tests/testthat/test-trim.R

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ skip_on_os ("mac")
44
skip_on_os ("windows")
55

66
test_that ("trim_osm_data", {
7+
osm_multi <- test_path ("fixtures", "osm-multi.osm")
78
q0 <- opq (bbox = c (1, 1, 5, 5))
8-
x0 <- osmdata_sf (q0, test_path ("fixtures", "osm-multi.osm"))
9+
x0 <- osmdata_sf (q0, osm_multi)
910
bb <- cbind (c (2, 3), c (2, 3))
1011
require (sf)
1112
expect_error (
@@ -36,7 +37,7 @@ test_that ("trim_osm_data", {
3637
expect_true (nrow (x1$osm_multipolygons) ==
3738
nrow (x0$osm_multipolygons))
3839

39-
expect_silent (x0_sc <- osmdata_sc (q0, test_path ("fixtures", "osm-multi.osm")))
40+
expect_silent (x0_sc <- osmdata_sc (q0, osm_multi))
4041
expect_silent (x1 <- trim_osmdata (x0_sc, bb_poly = bb))
4142
expect_equal (nrow (x1$object), 0)
4243
expect_equal (nrow (x1$object_link_edge), 0)

0 commit comments

Comments
 (0)