def test_SynchronizeFlush(self): self.assertEquals(StationInformation.query.count(), 0) Cartography.synchronize(TEST_XML_URL_DATA_STATION) self.assertEquals(StationInformation.query.count(), 112) Cartography.flush() self.assertEquals(StationInformation.query.count(), 0)
def test_Init(self): Cartography.synchronize(TEST_XML_URL_DATA_STATION) station = Station(42008) geofinder = StationGeoFinder(station) self.assertEquals(geofinder.lat, station.informations.lat) self.assertEquals(geofinder.lng, station.informations.lng) Cartography.flush()
def test_GetStationsAround(self): Cartography.synchronize(TEST_XML_URL_DATA_STATION) station = Station(self.velib_id) station.around_radius = 1200 stations_around = station.stations_around self.assertEquals(len(stations_around), 9) Cartography.flush()
def test_my_strange_experiment(self): Cartography.synchronize(TEST_XML_URL_DATA_STATION) station = Station(self.velib_id) around = station.stations_around coords = ((station.informations.lat, station.informations.lng), (around[-1].lat, around[-1].lng)) self.assertEquals(haversine_distance(*coords), around[-1].distance) Cartography.flush()
def test_GetStationsInArea(self): test_1 = (('4.89', '4.90', '4.91'), ('18.79', '18.80', '18.81')) test_2 = (('48.80', '48.81', '48.82'), ('2.37', '2.38', '2.39')) Cartography.synchronize(TEST_XML_URL_DATA_STATION) finder = BaseGeoFinder(1, 1) self.assertEquals(len(finder.get_stations_in_area(*test_1)), 0) self.assertEquals(len(finder.get_stations_in_area(*test_2)), 8) Cartography.flush()
def test_GetStationsAround(self): Cartography.synchronize(TEST_XML_URL_DATA_STATION) finder = BaseGeoFinder(1, 1) self.assertEquals(len(finder.get_stations_around( STATION_AROUND_RADIUS)), 0) finder.lat = 48.81 finder.lng = 2.38 self.assertEquals( [station.id for station in finder.get_stations_around(STATION_AROUND_RADIUS)], [42012, 42010, 42009, 42008, 42016, 42006, 42007, 42015]) Cartography.flush()
def synchronization(): print _('-> Online synchronization...') Cartography.synchronize() print _('-> Synchronization complete !')