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