Skip to content

Commit 967dec4

Browse files
author
Jesse Cambon
committed
added api_options tests
1 parent 26922e2 commit 967dec4

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

tests/testthat/test-geocode.R

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,6 @@ test_that("Test geo() and reverse_geo() error handling", {
7272
expect_error(reverse_geo(no_query = TRUE, lat = 1, long = 2, mode = "123"))
7373
# incompatible address arguments
7474
expect_error(geo(no_query = TRUE, address = "abc", street = "xyz", no_query = TRUE))
75-
# invalid return_type
76-
expect_error(geo(no_query = TRUE, address = "abc", api_options = list(census_return_type = "xyz")))
77-
78-
# invalid api_option argument
79-
expect_error(geo(no_query = TRUE, address = "abc", api_options = list(bad_argument = "xyz")))
8075

8176
# invalid limit
8277
expect_error(geo(no_query = TRUE, address = "abc", limit = 0))
@@ -97,15 +92,26 @@ test_that("Test geo() and reverse_geo() error handling", {
9792
# expect_error(geo('xy', no_query = TRUE, full_results = TRUE, method = 'cascade'))
9893
# expect_error(geo('ab', no_query = TRUE, limit = 5, method = 'cascade'))
9994

95+
# api_options tests ------------------------------------------------------------------------------------------------
10096
# invalid mapbox_permanent parameter
10197
expect_error(geo(no_query = TRUE, address = "abc", api_options = list(mapbox_permanent = "AA")))
98+
expect_error(reverse_geo(no_query = TRUE, lat = -5, long = 10, api_options = list(mapbox_permanent = "AA")))
10299

103100
# invalid api_options parameter
104101
expect_error(geo(no_query = TRUE, address = "abc", api_options = list(invalid_parameter = "blah")))
102+
expect_error(reverse_geo(no_query = TRUE, lat = 0, long = 0, api_options = list(invalid_parameter = "blah")))
103+
104+
# api_options - method mismatch
105+
expect_error(geo(no_query = TRUE, method = 'google', address = "abc", api_options = list(geocodio_v = 1.0)))
106+
expect_error(reverse_geo(lat = 1, long = 2, no_query = TRUE, method = 'google', address = "abc", api_options = list(geocodio_v = 1.0)))
107+
expect_error(geo(no_query = TRUE, method = 'geocodio', address = "abc", api_options = list(geocodio_v = 1.0, census_return_type ="geographies")))
105108

106109
# invalid here_request_id parameter
107110
expect_error(geo(no_query = TRUE, address = "abc", method = "here", api_options = list(here_request_id = 12345)))
108111
expect_error(reverse_geo(no_query = TRUE, lat = 1, long = 2, method = "here", api_options = list(here_request_id = 12345)))
112+
113+
# invalid return_type
114+
expect_error(geo(no_query = TRUE, address = "abc", api_options = list(census_return_type = "xyz")))
109115

110116
# here specific batch issue for here_request_id
111117
expect_error(reverse_geo(

0 commit comments

Comments
 (0)