Ejemplo n.º 1
0
 def test_nearbyHomes_IndexError(self):
     test_case = self.success_test_params
     with mock.patch("requests.request") as barMock:
         barMock.side_effect = IndexError
         inp = test_case[KEY_INPUT]
         result = apifunctions.nearby_homes(inp[PROPERTY_ID],
                                            inp[MIN_PRICE], inp[MAX_PRICE])
 def test_nearbyhomes_success(self):
     '''
     mocks nearbyhomes
     '''
     test_case = self.success_test_params
     with mock.patch("requests.request", self.mock_success_requests):
         with mock.patch("googlemaps.Client.geocode", self.mock_success_geocode):
             with mock.patch("google_maps_api.get_place_id", self.mock_get_place_id):
                 with mock.patch(
                     "google_maps_api.generate_iframe_url",
                     self.mock_generate_iframe_url,
                 ):
                     with mock.patch(
                         "googlemaps.Client.directions", self.mock_directions
                     ):
                         with mock.patch(
                             "walkscore_api.get_walkscore_info",
                             self.mock_walkscore_info,
                         ):
                             input_case = test_case[KEY_INPUT]
                             results = apifunctions.nearby_homes(
                                 input_case[PROPERTY_ID],
                                 input_case[MIN_PRICE],
                                 input_case[MAX_PRICE],
                                 input_case[ABSOLUTE_ADDRESS],
                             )
                             for result in results:
                                 # print(result)
                                 # print(test_case[KEY_EXPECTED][0])
                                 self.assertDictEqual(
                                     result, test_case[KEY_EXPECTED][0]
                                 )
 def test_nearbyhomes_index_err(self):
     '''
     Check index error handling
     '''
     test_case = self.success_test_params
     with mock.patch("requests.request") as bar_mock:
         bar_mock.side_effect = IndexError
         input_case = test_case[KEY_INPUT]
         result = apifunctions.nearby_homes(
             input_case[PROPERTY_ID], input_case[MIN_PRICE], input_case[MAX_PRICE], input_case[ABSOLUTE_ADDRESS]
         )
 def test_nearbyhomes_request_exception(self):
     '''
     Checks a genenic bad request handling
     '''
     test_case = self.success_test_params
     with mock.patch("requests.request") as bar_mock:
         bar_mock.side_effect = requests.exceptions.RequestException
         input_case = test_case[KEY_INPUT]
         result = apifunctions.nearby_homes(
             input_case[PROPERTY_ID], input_case[MIN_PRICE], input_case[MAX_PRICE], input_case[ABSOLUTE_ADDRESS]
         )
Ejemplo n.º 5
0
 def test_nearbyHomes_success(self):
     test_case = self.success_test_params
     with mock.patch("requests.request", self.mock_success_requests):
         with mock.patch("googlemaps.Client.geocode",
                         self.mock_success_geocode):
             inp = test_case[KEY_INPUT]
             results = apifunctions.nearby_homes(inp[PROPERTY_ID],
                                                 inp[MIN_PRICE],
                                                 inp[MAX_PRICE])
             for result in results:
                 # print(result)
                 # print(test_case[KEY_EXPECTED][0])
                 self.assertDictEqual(result, test_case[KEY_EXPECTED][0])