@@ -28,23 +28,38 @@ def test_opencage():
2828
2929
3030def test_issue_292 ():
31- g = geocoder .opencage ('AirportClinic M - MediCare Flughafen München Medizinisches Zentrum' , countrycode = 'DE' , language = 'de' , no_annotations = 1 )
31+ g = geocoder .opencage (
32+ 'AirportClinic M - MediCare Flughafen München Medizinisches Zentrum' ,
33+ countrycode = 'DE' ,
34+ language = 'de' ,
35+ no_annotations = 1 )
3236 assert g .ok
3337
38+
3439def test_opencage_no_language_param ():
3540 """ Expected result :
3641 https://api.opencagedata.com/geocode/v1/json=Ottawa,Ontario&key=YOUR-API-KEY
3742 """
3843 g = geocoder .opencage (location )
3944 assert 'language' not in g .url
4045
46+
4147def test_opencage_language_param ():
4248 """ Expected result :
4349 https://api.opencagedata.com/geocode/v1/json=Ottawa,Ontario&key=YOUR-API-KEY&language=de
4450 """
4551 g = geocoder .opencage (location , language = 'de' )
4652 assert 'language=de' in g .url .split ('&' )
4753
54+
55+ def test_opencage_countrycode_param ():
56+ """ Expected result:
57+ https://api.opencagedata.com/geocode/v1/json?q=Ottawa,Ontario&key=YOUR-API-KEY&countrycode=ca"
58+ """
59+ g = geocoder .opencage (location , countrycode = 'ca' )
60+ assert 'countrycode=ca' in g .url .split ('&' )
61+
62+
4863def test_opencage_multi_result ():
4964 g = geocoder .opencage (location , maxRows = 5 )
5065 assert len (g ) > 1
@@ -66,9 +81,11 @@ def test_opencage_address():
6681 assert (g .remaining_api_calls > 0 and g .remaining_api_calls != 999999 )
6782 assert (g .limit_api_calls > 0 and g .remaining_api_calls != 999999 )
6883
84+
6985def test_opencage_paid ():
7086 # Paid API keys can be set to unlimited and have rate limit information ommitted from the response
71- url = 'http://api.opencagedata.com/geocode/v1/json?query=The+Happy+Goat%2C+Ottawa&limit=1&key=' + os .environ .get ('OPENCAGE_API_KEY' )
87+ url = 'http://api.opencagedata.com/geocode/v1/json?query=The+Happy+Goat%2C+Ottawa&limit=1&key=' + os .environ .get (
88+ 'OPENCAGE_API_KEY' )
7289 data_file = 'tests/results/opencagedata_paid.json'
7390 with requests_mock .Mocker () as mocker , open (data_file , 'r' ) as input :
7491 mocker .get (url , text = input .read ())
@@ -81,8 +98,6 @@ def test_opencage_paid():
8198 assert result .limit_api_calls == 999999
8299
83100
84-
85-
86101def test_opencage_reverse ():
87102 """ Expected result :
88103 https://api.opencagedata.com/geocode/v1/json?q=45.4215296,-75.6971930&key=YOUR-API-KEY
0 commit comments