def test_basic(self): c1 = self.get_test_data('config1.yaml') c2 = self.get_test_data('config2.yaml') c = Config(c1) with self.assertRaises(AttributeError): self.assertEqual('client1', c.client) self.assertEqual('client1', c.client_id) c = Config(c1, client_id='client3') self.assertEqual('client3', c.client_id) # # ENV VARS environ['CITYIQ_CONFIG'] = c2 c = Config() self.assertEqual('client2', c.client_id) environ['CITYIQ_CLIENT_ID'] = 'client4' self.assertEqual('client4', c.client_id) c = Config(client_id='client5') self.assertEqual('client5', c.client_id) # # User dir. Requires the user has a file at ~.city-iq.yaml # Path.home().joinpath('.city-iq.yaml').exists(), c = Config() del environ['CITYIQ_CLIENT_ID'] print(c.client_id)
def test_asset_events(self): c = CityIq(Config(cache_objects='/tmp')) start = c.tz.localize(datetime(2019, 1, 1, 0, 0, 0)) end = c.tz.localize(datetime(2019, 1, 31, 0, 0, 0)) a = c.get_asset('ff0cfb97-d1d5-463a-b36f-2626421b5e8d') ft = FetchTask(0, a, 'PKIN', start, end, overwrite=True) events1 = ft.run() print(len(events1))
def test_location_events(self): from datetime import datetime c = CityIq(Config(cache_dir='/tmp', cache_errors='/tmp/errors')) locations = list(c.walkways) start = c.tz.localize(datetime(2019, 1, 1, 0, 0, 0)) end = c.tz.localize(datetime(2019, 1, 31, 0, 0, 0)) ft = FetchTask(locations[100], overwrite=True) events1 = ft.events('PEDEVT', start, end) print(len(events1)) events2 = locations[100].events('PEDEVT', start, end) print(len(events2))
def setUp(self): #api_logger.setLevel(logging.DEBUG) task_logger.setLevel(logging.DEBUG) self.config = Config(Path(__file__).parent.joinpath())
import logging from cityiq.api import CityIq from cityiq.api import logger as api_logger from cityiq.config import Config from cityiq.scrape import logger as scrape_logger from cityiq.token import logger as token_logger from datetime import datetime from .support import CityIQTest from cityiq.task import FetchTask from cityiq.scrape import AsyncFetchRunner import logging logging.basicConfig(level=logging.DEBUG) config = Config(cache_objects='/tmp', cache_errors='/tmp/errors') class TestLocAsset(CityIQTest): def test_location_events(self): from datetime import datetime c = CityIq(Config(cache_dir='/tmp', cache_errors='/tmp/errors')) locations = list(c.walkways) start = c.tz.localize(datetime(2019, 1, 1, 0, 0, 0)) end = c.tz.localize(datetime(2019, 1, 31, 0, 0, 0)) ft = FetchTask(locations[100], overwrite=True)
def setUp(self): import warnings self.config = Config(Path(__file__).parent.joinpath()) warnings.simplefilter('ignore')
def setUp(self): self.config = Config(Path(__file__).parent.joinpath())