Beispiel #1
0
def test_retry_job(fake_post):
    api = API('https://api.fake.com', 'token')
    result = api.retry_job(1)

    assert result['url'] == 'https://api.fake.com/jobs/1/retry'
    assert result['data'] is None
    assert result['headers'] == {'Authorization': 'Bearer token'}
Beispiel #2
0
def test_list_jobs_with_queryparams(fake_get):
    api = API('https://api.fake.com', 'token')
    result = api.list_jobs(q='query', offset=0, limit=1)

    assert result['url'] == 'https://api.fake.com/jobs'
    assert result['headers'] == {'Authorization': 'Bearer token'}
    assert result['params'] == {'q': 'query', 'offset': 0, 'limit': 1}
Beispiel #3
0
def test_list_jobs(fake_get):
    api = API('https://api.fake.com', 'token')
    result = api.list_jobs()

    assert result['url'] == 'https://api.fake.com/jobs'
    assert result['headers'] == {'Authorization': 'Bearer token'}
    assert result['params'] == {'q': None, 'offset': None, 'limit': None}
Beispiel #4
0
def test_list_users(fake_get):
    api = API('https://api.fake.com', 'token')
    result = api.list_users()

    assert result['url'] == 'https://api.fake.com/users'
    assert result['headers'] == {'Authorization': 'Bearer token'}
    assert result['params'] is None
Beispiel #5
0
def test_authenticate(fake_post):
    username = '******'
    password = '******'

    api = API('https://api.fake.com')
    result = api.authenticate(username, password)

    assert result['url'] == 'https://api.fake.com/auth/sign-in'
    assert result['data'] == {'username': username, 'password': password}
Beispiel #6
0
def test_create_user(fake_post):
    username = '******'
    password = '******'

    api = API('https://api.fake.com', 'token')
    result = api.create_user(username, password)

    assert result['url'] == 'https://api.fake.com/users'
    assert result['data'] == {'username': username, 'password': password}
    assert result['headers'] == {'Authorization': 'Bearer token'}
Beispiel #7
0
def test_update_access_token():
    api = API('https://api.fake.com', access_token='token')
    api.access_token = 'new token'
    assert api.auth_header == {'Authorization': 'Bearer new token'}
Beispiel #8
0
def test_access_token():
    api = API('https://api.fake.com', access_token='token')
    assert api.access_token == 'token'
Beispiel #9
0
def test_sanitize_base_url():
    api = API('https://api.fake.com/')
    assert api.base_url == 'https://api.fake.com'
Beispiel #10
0
def test_delete_job_raises_access_token_required():
    api = API('https://api.fake.com')
    assert raise_auth_error(api.delete_job, 1)
Beispiel #11
0
def test_delete_job(fake_delete):
    api = API('https://api.fake.com', 'token')
    result = api.delete_job(1)

    assert result['url'] == 'https://api.fake.com/jobs/1'
    assert result['headers'] == {'Authorization': 'Bearer token'}
Beispiel #12
0
def test_list_jobs_raises_access_token_required():
    api = API('https://api.fake.com')
    assert raise_auth_error(api.list_jobs)
Beispiel #13
0
def test_create_user_raises_access_token_required():
    api = API('https://api.fake.com')
    assert raise_auth_error(api.create_user, '*****@*****.**', 'pass')