Exemple #1
0
def test_read_from_file_without_cache(credentials_path, section, token,
                                      cache_path):
    write_token_to_cache(section, (token['access_token'], token['expires_in']),
                         cache_path)
    args = read_from_file(str(credentials_path), section)

    credentials = Credentials(*args, cache_path=cache_path)
    assert credentials.cached_profile is None
    assert credentials._token == NULL_TOKEN
Exemple #2
0
def test_read_from_file_with_cache(credentials_path, section, token,
                                   cache_path):
    write_token_to_cache(section, (token['access_token'], token['expires_in']),
                         cache_path)
    credentials_path.write_text(credentials_path.read_text() +
                                '\nuse_cache = true')
    args = read_from_file(str(credentials_path), section)

    credentials = Credentials(*args, cache_path=cache_path)
    assert credentials.cached_profile == section
    assert credentials._token == (token['access_token'], token['expires_in'])
Exemple #3
0
        'documentId': response['documentId'],
    }

    if model_id:
        content['modelId'] = model_id

    response = client.execute_workflow(workflow_id, content)
    logging.info(f'{json.dumps(response, indent=2)}')


if __name__ == '__main__':
    parser = ArgumentParser()
    parser.add_argument('document')
    parser.add_argument('--workflow-id')
    parser.add_argument('--model-id')
    parser.add_argument('--content-type', default='application/pdf')
    parser.add_argument('--profile')
    args = parser.parse_args()

    if args.profile:
        credentials = Credentials(*read_from_file(section=args.profile))
        client = Client(credentials)
    else:
        client = Client()

    main(client=client,
         workflow_id=args.workflow_id,
         document_path=args.document,
         content_type=args.content_type,
         model_id=args.model_id)