Example #1
0
 def __init__(self, api_client=None):
     if api_client is None:
         api_client = ApiClient()
     self.api_client = api_client
Example #2
0
if sys.version_info[:2] in [(2, 6), (2, 7)]:
    reload(sys)
    sys.setdefaultencoding('utf-8')
elif sys.version_info[:2] in [(3, 6), (3, 7)]:
    # pylint: disable=E0401, E0611, E1101
    import importlib

    importlib.reload(sys)

ENV_ARROW_TIMEZONE = ConfManage.getString("ARROW_TIMEZONE")
ENV_ARROW_TZSHIFT = ConfManage.getInt("ARROW_TZSHIFT")
ENV_DATA_API_TIMERANGE = ConfManage.getInt("DATA_API_TIMERANGE")
ENV_ZONE = ConfManage.getString("ZONE")
logger = Logger.get_instance(ConfManage.getString("LOG_CRON_NAME"))
client = ApiClient()
osrm_api_client = OsrmApi()


def fetch_model_info(id_list, model_name='order', col=None, chunk_size=500):
    model = get_model(model_name)
    result = None
    id_chunks = chunks(id_list, chunk_size)
    for id_chunk in id_chunks:
        if result is None:
            result = model.fetch_in(
                id_chunk) if col is None else model.fetch_in(id_chunk, col=col)
        else:
            result = result.append(model.fetch_in(id_chunk), sort=False) if col is None \
                else result.append(model.fetch_in(id_chunk, col=col), sort=False)
    logger.info('Fetch %s (Count): %d' % (model_name, len(result)))
def test_init_with_invalid_token():
    api_client = ApiClient(server_url=SERVER_URL, token="asdf")
    assert api_client.validate_own_token()
def client():
    yield ApiClient(server_url=SERVER_URL)
def test_get_token():
    api_client = ApiClient(server_url=SERVER_URL)
    assert api_client.validate_own_token()