mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 23:55:58 -05:00
Use client fixture everywhere
There were a few tests which weren't using the `client` fixture but were using the code it contains. This simplifies them to use the fixture.
This commit is contained in:
@@ -38,20 +38,19 @@ def test_api_key_should_return_error_when_service_does_not_exist(notify_api, sam
|
||||
assert response.status_code == 404
|
||||
|
||||
|
||||
def test_create_api_key_without_key_type_rejects(notify_api, sample_service):
|
||||
with notify_api.test_request_context(), notify_api.test_client() as client:
|
||||
data = {
|
||||
'name': 'some secret name',
|
||||
'created_by': str(sample_service.created_by.id)
|
||||
}
|
||||
auth_header = create_admin_authorization_header()
|
||||
response = client.post(url_for('service.create_api_key', service_id=sample_service.id),
|
||||
data=json.dumps(data),
|
||||
headers=[('Content-Type', 'application/json'), auth_header])
|
||||
assert response.status_code == 400
|
||||
json_resp = json.loads(response.get_data(as_text=True))
|
||||
assert json_resp['result'] == 'error'
|
||||
assert json_resp['message'] == {'key_type': ['Missing data for required field.']}
|
||||
def test_create_api_key_without_key_type_rejects(client, sample_service):
|
||||
data = {
|
||||
'name': 'some secret name',
|
||||
'created_by': str(sample_service.created_by.id)
|
||||
}
|
||||
auth_header = create_admin_authorization_header()
|
||||
response = client.post(url_for('service.create_api_key', service_id=sample_service.id),
|
||||
data=json.dumps(data),
|
||||
headers=[('Content-Type', 'application/json'), auth_header])
|
||||
assert response.status_code == 400
|
||||
json_resp = json.loads(response.get_data(as_text=True))
|
||||
assert json_resp['result'] == 'error'
|
||||
assert json_resp['message'] == {'key_type': ['Missing data for required field.']}
|
||||
|
||||
|
||||
def test_revoke_should_expire_api_key_for_service(notify_api, sample_api_key):
|
||||
|
||||
Reference in New Issue
Block a user