def test_get_geocoding(mock_requests, mock_info): mock_requests.get.return_value.status_code = 200 api = PublicAPI(TOKEN) api.get_geocoding( address = "Gemeindezentrum 1b, 79790 Küssaberg") mock_requests.get.assert_called_once_with( 'https://connectapi.feuersoftware.com/interfaces/public/geocoding', data='{"address": "Gemeindezentrum 1b, 79790 K\\u00fcssaberg"}', headers={"authorization": f"bearer {TOKEN}", "accept": "application/json", "content-type": "application/json"}) mock_info.assert_called_with("Success, API call 'get geocoding' complete")
def test_get_geocoding(mock_requests, mock_info): mock_requests.get.return_value.status_code = 200 api = PublicAPI(TOKEN) api.get_geocoding(address="Gemeindezentrum 1b, 79790 Küssaberg") mock_requests.get.assert_called_once_with( 'https://connectapi.feuersoftware.com/interfaces/public/geocoding', data='{"address": "Gemeindezentrum 1b, 79790 K\\u00fcssaberg"}', headers={ "authorization": f"bearer {TOKEN}", "accept": "application/json", "content-type": "application/json" }) mock_info.assert_called_with("Success, API call 'get geocoding' complete")
def test_error_get_geocoding(mock_requests, mock_error): mock_requests.get.return_value.status_code = 401 mock_requests.get.return_value.text = "unauthorized" api = PublicAPI("ABCD") api.get_geocoding( address = "Gemeindezentrum 1b, 79790 Küssaberg") mock_requests.get.assert_called_once_with( 'https://connectapi.feuersoftware.com/interfaces/public/geocoding', data='{"address": "Gemeindezentrum 1b, 79790 K\\u00fcssaberg"}', headers={"authorization": f"bearer ABCD", "accept": "application/json", "content-type": "application/json"}) mock_error.assert_called_with("Error while sending API call 'get geocoding': 401 unauthorized")
def test_error_get_geocoding(mock_requests, mock_error): mock_requests.get.return_value.status_code = 401 mock_requests.get.return_value.text = "unauthorized" api = PublicAPI("ABCD") api.get_geocoding(address="Gemeindezentrum 1b, 79790 Küssaberg") mock_requests.get.assert_called_once_with( 'https://connectapi.feuersoftware.com/interfaces/public/geocoding', data='{"address": "Gemeindezentrum 1b, 79790 K\\u00fcssaberg"}', headers={ "authorization": f"bearer ABCD", "accept": "application/json", "content-type": "application/json" }) mock_error.assert_called_with( "Error while sending API call 'get geocoding': 401 unauthorized")