def test_cache_assets_locations(self): from time import time c = CityIq(self.config) c.clear_meta_cache() # These should take gonger because # they are making the full request t = time() o = c.get_locations() self.assertGreater(time() - t, 1) self.assertGreater(len(o), 500) t = time() c.get_assets() self.assertGreater(time() - t, 4) o = self.assertGreater(len(o), 500) # These should be fast, because they are cached. t = time() o = c.get_locations() self.assertLess(time() - t, 1) self.assertGreater(len(o), 500) t = time() o = c.get_assets() self.assertLess(time() - t, 1) self.assertGreater(len(o), 500)
def test_async_runner_locations(self): c = CityIq(config) start = c.tz.localize(datetime(2020, 5, 1, 0, 0, 0)) end = c.tz.localize(datetime(2020, 5, 5, 0, 0, 0)) assets = [ e for e in c.get_assets() if e.eventTypes and 'BICYCLE' in e.eventTypes ] afr = AsyncFetchRunner(c.config, assets[0:10], 'BICYCLE', start, end) for e in afr.get_events(): print(e)