def test_locations_for(self): expected1 = Location('Abbans-Dessus', 5.88188, 47.120548, 3038800, 'FR') expected2 = Location('Abbans-Dessus', 5.88333, 47.116669, 6452202, 'FR') result = self._instance.locations_for("Abbans-Dessus") self.assertEqual(2, len(result)) for l in result: self.assertTrue(isinstance(l, Location)) self.assertTrue(l.get_ID() in [expected1.get_ID(), expected2.get_ID()])
def test_getters_return_expected_data(self): instance = Location(self.__test_name, self.__test_lon, self.__test_lat, self.__test_ID, self.__test_country) self.assertEqual(instance.get_name(), self.__test_name) self.assertEqual(instance.get_lon(), self.__test_lon) self.assertEqual(instance.get_lat(), self.__test_lat) self.assertEqual(instance.get_ID(), self.__test_ID) self.assertEqual(instance.get_country(), self.__test_country)
def test_location_for(self): expected = Location('Dongen', 4.938890, 51.626671, 2756723, 'NL') result = self._instance.location_for('dongen') self.assertEqual(result.get_name(), expected.get_name()) self.assertEqual(result.get_country(), expected.get_country()) self.assertEqual(result.get_ID(), expected.get_ID()) self.assertEqual(result.get_lat(), expected.get_lat()) self.assertEqual(result.get_lon(), expected.get_lon()) self.assertTrue(self._instance.location_for('aaaaaaaaaa') is None)
def test_location_for(self): ref_to_original = CityIDRegistry._get_lines CityIDRegistry._get_lines = self._mock_get_lines expected = Location('dongdu', 117.699997, 35.849998, 1812597, 'CN') result_1 = self._instance.location_for('dongdu') result_2 = self._instance.location_for('aaaaaaaaaa') CityIDRegistry._get_lines = ref_to_original self.assertEqual(result_1.get_name(), expected.get_name()) self.assertEqual(result_1.get_country(), expected.get_country()) self.assertEqual(result_1.get_ID(), expected.get_ID()) self.assertEqual(result_1.get_lat(), expected.get_lat()) self.assertEqual(result_1.get_lon(), expected.get_lon()) self.assertTrue(result_2 is None)