diff --git a/testdata/models/routing_error_forbidden_credentials.json b/testdata/models/routing_error_forbidden_credentials.json new file mode 100644 index 0000000..ad3aa79 --- /dev/null +++ b/testdata/models/routing_error_forbidden_credentials.json @@ -0,0 +1,4 @@ +{ + "error": "Forbidden", + "error_description": "These credentials do not authorize access" +} diff --git a/tests/test_routing_api.py b/tests/test_routing_api.py index 00050ca..89b2169 100644 --- a/tests/test_routing_api.py +++ b/tests/test_routing_api.py @@ -140,6 +140,20 @@ def test_carroute_when_error_invalid_credentials_occurred(self): with self.assertRaises(herepy.InvalidCredentialsError): api.car_route([11.0, 12.0], [22.0, 23.0]) + @responses.activate + def test_carroute_when_error_forbidden_credentials_occurred(self): + with open("testdata/models/routing_error_forbidden_credentials.json", "r") as f: + expectedResponse = f.read() + responses.add( + responses.GET, + "https://route.ls.hereapi.com/routing/7.2/calculateroute.json", + expectedResponse, + status=401, + ) + api = herepy.RoutingApi("forbidden_api_key", "forbidden_app_code") + with self.assertRaises(herepy.InvalidCredentialsError): + api.car_route([11.0, 12.0], [22.0, 23.0]) + @responses.activate def test_carroute_when_error_no_route_found_occurred(self): with open("testdata/models/routing_error_no_route_found.json", "r") as f: