-
Notifications
You must be signed in to change notification settings - Fork 12
/
test-read.R
43 lines (36 loc) · 1.05 KB
/
test-read.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
test_that("oe_read: simplest examples work", {
f = system.file("its-example.osm.pbf", package = "osmextract")
osm_data = oe_read(f)
# result is sf object:
expect_s3_class(object = osm_data, class = "sf")
# linestring geometry is default:
expect_equal(
as.character(unique(sf::st_geometry_type(osm_data))),
"LINESTRING"
)
osm_data_points = oe_read(f, layer = "points")
expect_equal(
as.character(unique(sf::st_geometry_type(osm_data_points))),
"POINT"
)
f_gpkg = system.file("its-example.osm.pbf", package = "osmextract")
if (f_gpkg != "") {
file.remove(f_gpkg)
}
})
test_that("or_read: simplest example with a URL works", {
skip_if_offline()
my_url = "https://github.com/ITSLeeds/osmextract/raw/master/inst/its-example.osm.pbf"
oe_read(
my_url,
provider = "test",
quiet = TRUE,
download_directory = tempdir()
)
})
test_that("oe_read fails with a clear error message with wrong URL of file path", {
expect_error(
oe_read("geofabrik_typo-in-path.osm.pbf"),
"it doesn't look like a URL"
)
})