示例#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'}
示例#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}
示例#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}
示例#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
示例#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}
示例#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'}
示例#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'}
示例#8
0
def test_access_token():
    api = API('https://api.fake.com', access_token='token')
    assert api.access_token == 'token'
示例#9
0
def test_sanitize_base_url():
    api = API('https://api.fake.com/')
    assert api.base_url == 'https://api.fake.com'
示例#10
0
def test_delete_job_raises_access_token_required():
    api = API('https://api.fake.com')
    assert raise_auth_error(api.delete_job, 1)
示例#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'}
示例#12
0
def test_list_jobs_raises_access_token_required():
    api = API('https://api.fake.com')
    assert raise_auth_error(api.list_jobs)
示例#13
0
def test_create_user_raises_access_token_required():
    api = API('https://api.fake.com')
    assert raise_auth_error(api.create_user, '*****@*****.**', 'pass')