Skip to content

Commit

Permalink
add skip_on_cran() to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mpadge committed Jul 12, 2016
1 parent 4fc66d3 commit d6f7f4a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 16 deletions.
12 changes: 9 additions & 3 deletions tests/testthat/test-connect-highways.R
Expand Up @@ -10,6 +10,8 @@ if (curl::has_internet ()) # otherwise all of these return errors not warnings
})

test_that ('unrecognised highways', {
skip_on_cran ()

bbox <- get_bbox (c (-0.13, 51.5, -0.11, 51.52))
# No error specified because different HTML errors may also be
# generated
Expand All @@ -19,22 +21,26 @@ if (curl::has_internet ()) # otherwise all of these return errors not warnings
})

test_that ('highways do not connect', {
skip_on_cran ()

bbox <- get_bbox (c(-0.15,51.5,-0.10,51.52))
highways <- c ('Kingsway', 'Holborn', 'Farringdon.St', 'Strand',
'Fleet.St', 'Aldwych')
# No warning specified here because different warnings will be
# given if download fails
#expect_warning (connect_highways (highways=highways, bbox=bbox))
expect_warning (connect_highways (highways=highways, bbox=bbox))
#expect_warning (connect_highways (highways=highways, bbox=bbox),
# 'Cycle unable to be extended through all ways')
})

test_that ('plot', {
skip_on_cran ()

bbox <- get_bbox (c(-0.15,51.5,-0.10,51.52))
highways <- c ('Regent.St', 'Oxford.St', 'Shaftesbury')
# This can't fail because failed downloads will generate warnings
# and successful ones will generate a plot.
#expect_output (connect_highways (highways=highways, bbox=bbox,
# plot=TRUE))
expect_output (connect_highways (highways=highways, bbox=bbox,
plot=TRUE))
})
} # end if has_internet
32 changes: 19 additions & 13 deletions tests/testthat/test-extract-objects.R
Expand Up @@ -3,18 +3,20 @@ context ('extract-objects')
test_that ('missing objects', {
expect_error (extract_osm_objects (), 'key must be provided')
expect_error (extract_osm_objects ('aaa'), 'bbox must be provided')
})
})

test_that ('key missing', {
bbox <- get_bbox (c (-0.12, 51.51, -0.11, 51.52))
expect_error (extract_osm_objects (bbox=bbox, key=''),
'key must be provided')
expect_error (extract_osm_objects (bbox=bbox), 'key must be provided')
})
})

if (curl::has_internet ()) # otherwise all of these return errors not warnings
{
test_that ('invalid key', {
skip_on_cran ()

bbox <- get_bbox (c (-0.12, 51.51, -0.11, 51.52))
# No warning specified here because different warnings will be
# given if download fails
Expand All @@ -24,6 +26,8 @@ if (curl::has_internet ()) # otherwise all of these return errors not warnings
})

test_that ('valid key', {
skip_on_cran ()

bbox <- get_bbox (c (-0.12, 51.515, -0.115, 51.52))
dat <- extract_osm_objects (bbox=bbox, key='building')
# Will return NULL if any warnings are generated (such as by
Expand All @@ -33,17 +37,19 @@ if (curl::has_internet ()) # otherwise all of these return errors not warnings
})

test_that ('return_type', {
key <- 'route'
value <- 'bicycle'
extra_pairs <- c ('name', 'London.Cycle.Network.Route.9')
bbox <- get_bbox (c (-0.26,51.47,0.11,51.67))
# This can't be run because any downloading issues generate
# warnings. Only if downloading succeeds will the message be
# generated ('Cannot determine return_type, maybe specify
# explicitly?')
#expect_message (dat <- extract_osm_objects (bbox=bbox, key=key,
# value=value,
# extra_pairs=extra_pairs))
skip_on_cran ()

key <- 'route'
value <- 'bicycle'
extra_pairs <- c ('name', 'London.Cycle.Network.Route.9')
bbox <- get_bbox (c (-0.26,51.47,0.11,51.67))
# This can't be run because any downloading issues generate
# warnings. Only if downloading succeeds will the message be
# generated ('Cannot determine return_type, maybe specify
# explicitly?')
expect_message (dat <- extract_osm_objects (bbox=bbox, key=key,
value=value,
extra_pairs=extra_pairs))
})

} # end if has_internet

0 comments on commit d6f7f4a

Please sign in to comment.