mirror of
https://github.com/GSA/notifications-api.git
synced 2026-09-06 16:58:25 -04:00
make client request fixture args conform
This commit is contained in:
@@ -290,6 +290,7 @@ class Test(Config):
|
|||||||
FROM_NUMBER = 'testing'
|
FROM_NUMBER = 'testing'
|
||||||
NOTIFY_ENVIRONMENT = 'test'
|
NOTIFY_ENVIRONMENT = 'test'
|
||||||
DEBUG = True
|
DEBUG = True
|
||||||
|
TESTING = True
|
||||||
CSV_UPLOAD_BUCKET_NAME = 'test-notifications-csv-upload'
|
CSV_UPLOAD_BUCKET_NAME = 'test-notifications-csv-upload'
|
||||||
DVLA_RESPONSE_BUCKET_NAME = 'test.notify.com-ftp'
|
DVLA_RESPONSE_BUCKET_NAME = 'test.notify.com-ftp'
|
||||||
STATSD_ENABLED = True
|
STATSD_ENABLED = True
|
||||||
|
|||||||
@@ -988,34 +988,34 @@ def admin_request(client):
|
|||||||
class AdminRequest:
|
class AdminRequest:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get(endpoint, endpoint_kwargs=None, expected_status=200):
|
def get(endpoint, _expected_status=200, **endpoint_kwargs):
|
||||||
resp = client.get(
|
resp = client.get(
|
||||||
url_for(endpoint, **(endpoint_kwargs or {})),
|
url_for(endpoint, **(endpoint_kwargs or {})),
|
||||||
headers=[create_authorization_header()]
|
headers=[create_authorization_header()]
|
||||||
)
|
)
|
||||||
json_resp = json.loads(resp.get_data(as_text=True))
|
json_resp = json.loads(resp.get_data(as_text=True))
|
||||||
assert resp.status_code == expected_status
|
assert resp.status_code == _expected_status
|
||||||
return json_resp
|
return json_resp
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def post(endpoint, endpoint_kwargs=None, data=None, expected_status=200):
|
def post(endpoint, _data=None, _expected_status=200, **endpoint_kwargs):
|
||||||
resp = client.post(
|
resp = client.post(
|
||||||
url_for(endpoint, **(endpoint_kwargs or {})),
|
url_for(endpoint, **(endpoint_kwargs or {})),
|
||||||
data=json.dumps(data),
|
data=json.dumps(_data),
|
||||||
headers=[('Content-Type', 'application/json'), create_authorization_header()]
|
headers=[('Content-Type', 'application/json'), create_authorization_header()]
|
||||||
)
|
)
|
||||||
json_resp = json.loads(resp.get_data(as_text=True))
|
json_resp = json.loads(resp.get_data(as_text=True))
|
||||||
assert resp.status_code == expected_status
|
assert resp.status_code == _expected_status
|
||||||
return json_resp
|
return json_resp
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def delete(endpoint, endpoint_kwargs=None, expected_status=204):
|
def delete(endpoint, _expected_status=204, **endpoint_kwargs):
|
||||||
resp = client.delete(
|
resp = client.delete(
|
||||||
url_for(endpoint, **(endpoint_kwargs or {})),
|
url_for(endpoint, **(endpoint_kwargs or {})),
|
||||||
headers=[create_authorization_header()]
|
headers=[create_authorization_header()]
|
||||||
)
|
)
|
||||||
json_resp = json.loads(resp.get_data(as_text=True))
|
json_resp = json.loads(resp.get_data(as_text=True))
|
||||||
assert resp.status_code == expected_status
|
assert resp.status_code == _expected_status
|
||||||
return json_resp
|
return json_resp
|
||||||
|
|
||||||
return AdminRequest
|
return AdminRequest
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ def test_get_inbound_sms(admin_request, sample_service):
|
|||||||
|
|
||||||
json_resp = admin_request.get(
|
json_resp = admin_request.get(
|
||||||
'inbound_sms.get_inbound_sms_for_service',
|
'inbound_sms.get_inbound_sms_for_service',
|
||||||
endpoint_kwargs={'service_id': sample_service.id}
|
service_id=sample_service.id
|
||||||
)
|
)
|
||||||
|
|
||||||
sms = json_resp['data']
|
sms = json_resp['data']
|
||||||
@@ -192,7 +192,8 @@ def test_get_inbound_sms_limits(admin_request, sample_service):
|
|||||||
|
|
||||||
sms = admin_request.get(
|
sms = admin_request.get(
|
||||||
'inbound_sms.get_inbound_sms_for_service',
|
'inbound_sms.get_inbound_sms_for_service',
|
||||||
endpoint_kwargs={'service_id': sample_service.id, 'limit': 1}
|
service_id=sample_service.id,
|
||||||
|
limit=1,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert len(sms['data']) == 1
|
assert len(sms['data']) == 1
|
||||||
@@ -211,7 +212,8 @@ def test_get_inbound_sms_filters_user_number(admin_request, sample_service, user
|
|||||||
|
|
||||||
sms = admin_request.get(
|
sms = admin_request.get(
|
||||||
'inbound_sms.get_inbound_sms_for_service',
|
'inbound_sms.get_inbound_sms_for_service',
|
||||||
endpoint_kwargs={'service_id': sample_service.id, 'user_number': user_number}
|
service_id=sample_service.id,
|
||||||
|
user_number=user_number,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert len(sms['data']) == 1
|
assert len(sms['data']) == 1
|
||||||
@@ -226,7 +228,8 @@ def test_get_inbound_sms_filters_international_user_number(admin_request, sample
|
|||||||
|
|
||||||
sms = admin_request.get(
|
sms = admin_request.get(
|
||||||
'inbound_sms.get_inbound_sms_for_service',
|
'inbound_sms.get_inbound_sms_for_service',
|
||||||
endpoint_kwargs={'service_id': sample_service.id, 'user_number': '+1 (202) 555-0104'}
|
service_id=sample_service.id,
|
||||||
|
user_number='+1 (202) 555-0104',
|
||||||
)
|
)
|
||||||
|
|
||||||
assert len(sms['data']) == 1
|
assert len(sms['data']) == 1
|
||||||
@@ -249,7 +252,7 @@ def test_get_inbound_sms_summary(admin_request, sample_service):
|
|||||||
|
|
||||||
summary = admin_request.get(
|
summary = admin_request.get(
|
||||||
'inbound_sms.get_inbound_sms_summary_for_service',
|
'inbound_sms.get_inbound_sms_summary_for_service',
|
||||||
endpoint_kwargs={'service_id': sample_service.id}
|
service_id=sample_service.id
|
||||||
)
|
)
|
||||||
|
|
||||||
assert summary == {
|
assert summary == {
|
||||||
@@ -261,7 +264,7 @@ def test_get_inbound_sms_summary(admin_request, sample_service):
|
|||||||
def test_get_inbound_sms_summary_with_no_inbound(admin_request, sample_service):
|
def test_get_inbound_sms_summary_with_no_inbound(admin_request, sample_service):
|
||||||
summary = admin_request.get(
|
summary = admin_request.get(
|
||||||
'inbound_sms.get_inbound_sms_summary_for_service',
|
'inbound_sms.get_inbound_sms_summary_for_service',
|
||||||
endpoint_kwargs={'service_id': sample_service.id}
|
service_id=sample_service.id
|
||||||
)
|
)
|
||||||
|
|
||||||
assert summary == {
|
assert summary == {
|
||||||
@@ -275,10 +278,8 @@ def test_get_inbound_sms_by_id_returns_200(admin_request, sample_service):
|
|||||||
|
|
||||||
response = admin_request.get(
|
response = admin_request.get(
|
||||||
'inbound_sms.get_inbound_by_id',
|
'inbound_sms.get_inbound_by_id',
|
||||||
endpoint_kwargs={
|
service_id=sample_service.id,
|
||||||
'service_id': sample_service.id,
|
inbound_sms_id=inbound.id,
|
||||||
'inbound_sms_id': inbound.id
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
assert response['user_number'] == '447700900001'
|
assert response['user_number'] == '447700900001'
|
||||||
@@ -288,20 +289,16 @@ def test_get_inbound_sms_by_id_returns_200(admin_request, sample_service):
|
|||||||
def test_get_inbound_sms_by_id_invalid_id_returns_404(admin_request, sample_service):
|
def test_get_inbound_sms_by_id_invalid_id_returns_404(admin_request, sample_service):
|
||||||
assert admin_request.get(
|
assert admin_request.get(
|
||||||
'inbound_sms.get_inbound_by_id',
|
'inbound_sms.get_inbound_by_id',
|
||||||
endpoint_kwargs={
|
service_id=sample_service.id,
|
||||||
'service_id': sample_service.id,
|
inbound_sms_id='bar',
|
||||||
'inbound_sms_id': 'bar'
|
_expected_status=404
|
||||||
},
|
|
||||||
expected_status=404
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_get_inbound_sms_by_id_with_invalid_service_id_returns_404(admin_request, sample_service):
|
def test_get_inbound_sms_by_id_with_invalid_service_id_returns_404(admin_request, sample_service):
|
||||||
assert admin_request.get(
|
assert admin_request.get(
|
||||||
'inbound_sms.get_inbound_by_id',
|
'inbound_sms.get_inbound_by_id',
|
||||||
endpoint_kwargs={
|
service_id='foo',
|
||||||
'service_id': 'foo',
|
inbound_sms_id='2cfbd6a1-1575-4664-8969-f27be0ea40d9',
|
||||||
'inbound_sms_id': '2cfbd6a1-1575-4664-8969-f27be0ea40d9'
|
_expected_status=404
|
||||||
},
|
|
||||||
expected_status=404
|
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1322,10 +1322,8 @@ def test_get_notification_for_service_includes_created_by(admin_request, sample_
|
|||||||
|
|
||||||
resp = admin_request.get(
|
resp = admin_request.get(
|
||||||
'service.get_notification_for_service',
|
'service.get_notification_for_service',
|
||||||
endpoint_kwargs={
|
service_id=sample_notification.service_id,
|
||||||
'service_id': sample_notification.service_id,
|
notification_id=sample_notification.id
|
||||||
'notification_id': sample_notification.id
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
assert resp['id'] == str(sample_notification.id)
|
assert resp['id'] == str(sample_notification.id)
|
||||||
@@ -2252,15 +2250,13 @@ def test_fetch_service_inbound_api(client, sample_service):
|
|||||||
def test_send_one_off_notification(admin_request, sample_template):
|
def test_send_one_off_notification(admin_request, sample_template):
|
||||||
response = admin_request.post(
|
response = admin_request.post(
|
||||||
'service.create_one_off_notification',
|
'service.create_one_off_notification',
|
||||||
endpoint_kwargs={
|
service_id=sample_template.service_id,
|
||||||
'service_id': sample_template.service_id
|
_data={
|
||||||
},
|
|
||||||
data={
|
|
||||||
'template_id': str(sample_template.id),
|
'template_id': str(sample_template.id),
|
||||||
'to': '07700900001',
|
'to': '07700900001',
|
||||||
'created_by': str(sample_template.service.created_by_id)
|
'created_by': str(sample_template.service.created_by_id)
|
||||||
},
|
},
|
||||||
expected_status=201
|
_expected_status=201
|
||||||
)
|
)
|
||||||
|
|
||||||
noti = Notification.query.one()
|
noti = Notification.query.one()
|
||||||
|
|||||||
Reference in New Issue
Block a user