2016-01-15 17:46:09 +00:00
|
|
|
|
from flask import url_for
|
2015-12-17 16:21:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
2016-01-27 12:22:32 +00:00
|
|
|
|
def test_should_return_list_of_all_jobs(app_,
|
|
|
|
|
|
service_one,
|
|
|
|
|
|
api_user_active,
|
2016-01-27 16:30:33 +00:00
|
|
|
|
mock_get_user,
|
|
|
|
|
|
mock_get_user_by_email,
|
2016-01-27 12:22:32 +00:00
|
|
|
|
mock_login):
|
2016-01-15 15:15:35 +00:00
|
|
|
|
with app_.test_request_context():
|
|
|
|
|
|
with app_.test_client() as client:
|
2016-01-27 12:22:32 +00:00
|
|
|
|
client.login(api_user_active)
|
2016-01-15 17:46:09 +00:00
|
|
|
|
response = client.get(url_for('main.view_jobs', service_id=101))
|
2015-12-17 16:21:34 +00:00
|
|
|
|
|
2016-01-11 16:03:41 +00:00
|
|
|
|
assert response.status_code == 200
|
2016-01-19 11:15:00 +00:00
|
|
|
|
assert 'You haven’t sent any notifications yet' in response.get_data(as_text=True)
|
2015-12-17 16:21:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
2016-01-27 12:22:32 +00:00
|
|
|
|
def test_should_show_page_for_one_job(app_,
|
|
|
|
|
|
service_one,
|
|
|
|
|
|
api_user_active,
|
|
|
|
|
|
mock_login,
|
2016-01-27 16:30:33 +00:00
|
|
|
|
mock_get_user,
|
|
|
|
|
|
mock_get_user_by_email):
|
2016-01-15 15:15:35 +00:00
|
|
|
|
with app_.test_request_context():
|
|
|
|
|
|
with app_.test_client() as client:
|
2016-01-13 17:32:40 +00:00
|
|
|
|
# TODO filename will be part of job metadata not in session
|
|
|
|
|
|
with client.session_transaction() as s:
|
|
|
|
|
|
s[456] = 'dispatch_20151114.csv'
|
2016-01-27 12:22:32 +00:00
|
|
|
|
client.login(api_user_active)
|
2016-01-15 17:46:09 +00:00
|
|
|
|
response = client.get(url_for('main.view_job', service_id=123, job_id=456))
|
2015-12-17 16:21:34 +00:00
|
|
|
|
|
2016-01-11 16:03:41 +00:00
|
|
|
|
assert response.status_code == 200
|
|
|
|
|
|
assert 'dispatch_20151114.csv' in response.get_data(as_text=True)
|
|
|
|
|
|
assert 'Test message 1' in response.get_data(as_text=True)
|
2015-12-17 16:21:34 +00:00
|
|
|
|
|
2016-01-11 16:03:41 +00:00
|
|
|
|
|
2016-01-27 12:22:32 +00:00
|
|
|
|
def test_should_show_page_for_one_notification(app_,
|
|
|
|
|
|
service_one,
|
|
|
|
|
|
api_user_active,
|
2016-01-27 16:30:33 +00:00
|
|
|
|
mock_get_user,
|
|
|
|
|
|
mock_get_user_by_email,
|
2016-01-27 12:22:32 +00:00
|
|
|
|
mock_login):
|
2016-01-15 15:15:35 +00:00
|
|
|
|
with app_.test_request_context():
|
|
|
|
|
|
with app_.test_client() as client:
|
2016-01-27 12:22:32 +00:00
|
|
|
|
client.login(api_user_active)
|
2016-01-15 17:46:09 +00:00
|
|
|
|
response = client.get(url_for(
|
|
|
|
|
|
'main.view_notification',
|
|
|
|
|
|
service_id=101,
|
|
|
|
|
|
job_id=123,
|
|
|
|
|
|
notification_id=3))
|
2016-01-11 16:03:41 +00:00
|
|
|
|
|
|
|
|
|
|
assert response.status_code == 200
|
|
|
|
|
|
assert 'Text message' in response.get_data(as_text=True)
|
|
|
|
|
|
assert '+44 7700 900 522' in response.get_data(as_text=True)
|