From fb45fa5524ab991b97a6b70427086bf88ce08e00 Mon Sep 17 00:00:00 2001 From: Antoine Revel Date: Tue, 14 May 2024 09:56:31 +0200 Subject: [PATCH] new test cases for optionnal params --- tests/test_geocoder_api.py | 45 +++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/tests/test_geocoder_api.py b/tests/test_geocoder_api.py index e7e17c1..8e10a0f 100644 --- a/tests/test_geocoder_api.py +++ b/tests/test_geocoder_api.py @@ -90,10 +90,53 @@ def test_addresswithdetails_whensucceed(self): expectedResponse, status=200, ) - response = self._api.address_with_details(34, "Barbaros", "Istanbul", "Turkey") + response = self._api.address_with_details( + street="Barbaros", + city="Istanbul", + country="Turkey", + house_number=34 + ) + self.assertTrue(response) + self.assertIsInstance(response, herepy.GeocoderResponse) + + @responses.activate + def test_address_with_detail_without_street(self): + with open("testdata/models/geocoder.json", "r") as f: + expected_response = f.read() + responses.add( + responses.GET, + "https://geocode.search.hereapi.com/v1/geocode", + expected_response, + status=200, + ) + response = self._api.address_with_details( + city="Istanbul", + country="Turkey", + house_number=34, + street= None + ) self.assertTrue(response) self.assertIsInstance(response, herepy.GeocoderResponse) + @responses.activate + def test_address_with_detail_without_house_number(self): + with open("testdata/models/geocoder.json", "r") as f: + expected_response = f.read() + responses.add( + responses.GET, + "https://geocode.search.hereapi.com/v1/geocode", + expected_response, + status=200, + ) + response = self._api.address_with_details( + street="Barbaros", + city="Istanbul", + country="Turkey", + house_number= None + ) + self.assertTrue(response) + self.assertIsInstance(response, herepy.GeocoderResponse) + @responses.activate def test_addresswithdetails_whenerroroccurred(self): with open("testdata/models/geocoder_error.json", "r") as f: