Skip to content

Commit d6f7f4a

Browse files
committed
add skip_on_cran() to tests
1 parent 4fc66d3 commit d6f7f4a

File tree

2 files changed

+28
-16
lines changed

2 files changed

+28
-16
lines changed

tests/testthat/test-connect-highways.R

+9-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ if (curl::has_internet ()) # otherwise all of these return errors not warnings
1010
})
1111

1212
test_that ('unrecognised highways', {
13+
skip_on_cran ()
14+
1315
bbox <- get_bbox (c (-0.13, 51.5, -0.11, 51.52))
1416
# No error specified because different HTML errors may also be
1517
# generated
@@ -19,22 +21,26 @@ if (curl::has_internet ()) # otherwise all of these return errors not warnings
1921
})
2022

2123
test_that ('highways do not connect', {
24+
skip_on_cran ()
25+
2226
bbox <- get_bbox (c(-0.15,51.5,-0.10,51.52))
2327
highways <- c ('Kingsway', 'Holborn', 'Farringdon.St', 'Strand',
2428
'Fleet.St', 'Aldwych')
2529
# No warning specified here because different warnings will be
2630
# given if download fails
27-
#expect_warning (connect_highways (highways=highways, bbox=bbox))
31+
expect_warning (connect_highways (highways=highways, bbox=bbox))
2832
#expect_warning (connect_highways (highways=highways, bbox=bbox),
2933
# 'Cycle unable to be extended through all ways')
3034
})
3135

3236
test_that ('plot', {
37+
skip_on_cran ()
38+
3339
bbox <- get_bbox (c(-0.15,51.5,-0.10,51.52))
3440
highways <- c ('Regent.St', 'Oxford.St', 'Shaftesbury')
3541
# This can't fail because failed downloads will generate warnings
3642
# and successful ones will generate a plot.
37-
#expect_output (connect_highways (highways=highways, bbox=bbox,
38-
# plot=TRUE))
43+
expect_output (connect_highways (highways=highways, bbox=bbox,
44+
plot=TRUE))
3945
})
4046
} # end if has_internet

tests/testthat/test-extract-objects.R

+19-13
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,20 @@ context ('extract-objects')
33
test_that ('missing objects', {
44
expect_error (extract_osm_objects (), 'key must be provided')
55
expect_error (extract_osm_objects ('aaa'), 'bbox must be provided')
6-
})
6+
})
77

88
test_that ('key missing', {
99
bbox <- get_bbox (c (-0.12, 51.51, -0.11, 51.52))
1010
expect_error (extract_osm_objects (bbox=bbox, key=''),
1111
'key must be provided')
1212
expect_error (extract_osm_objects (bbox=bbox), 'key must be provided')
13-
})
13+
})
1414

1515
if (curl::has_internet ()) # otherwise all of these return errors not warnings
1616
{
1717
test_that ('invalid key', {
18+
skip_on_cran ()
19+
1820
bbox <- get_bbox (c (-0.12, 51.51, -0.11, 51.52))
1921
# No warning specified here because different warnings will be
2022
# given if download fails
@@ -24,6 +26,8 @@ if (curl::has_internet ()) # otherwise all of these return errors not warnings
2426
})
2527

2628
test_that ('valid key', {
29+
skip_on_cran ()
30+
2731
bbox <- get_bbox (c (-0.12, 51.515, -0.115, 51.52))
2832
dat <- extract_osm_objects (bbox=bbox, key='building')
2933
# Will return NULL if any warnings are generated (such as by
@@ -33,17 +37,19 @@ if (curl::has_internet ()) # otherwise all of these return errors not warnings
3337
})
3438

3539
test_that ('return_type', {
36-
key <- 'route'
37-
value <- 'bicycle'
38-
extra_pairs <- c ('name', 'London.Cycle.Network.Route.9')
39-
bbox <- get_bbox (c (-0.26,51.47,0.11,51.67))
40-
# This can't be run because any downloading issues generate
41-
# warnings. Only if downloading succeeds will the message be
42-
# generated ('Cannot determine return_type, maybe specify
43-
# explicitly?')
44-
#expect_message (dat <- extract_osm_objects (bbox=bbox, key=key,
45-
# value=value,
46-
# extra_pairs=extra_pairs))
40+
skip_on_cran ()
41+
42+
key <- 'route'
43+
value <- 'bicycle'
44+
extra_pairs <- c ('name', 'London.Cycle.Network.Route.9')
45+
bbox <- get_bbox (c (-0.26,51.47,0.11,51.67))
46+
# This can't be run because any downloading issues generate
47+
# warnings. Only if downloading succeeds will the message be
48+
# generated ('Cannot determine return_type, maybe specify
49+
# explicitly?')
50+
expect_message (dat <- extract_osm_objects (bbox=bbox, key=key,
51+
value=value,
52+
extra_pairs=extra_pairs))
4753
})
4854

4955
} # end if has_internet

0 commit comments

Comments
 (0)