mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-02 12:49:01 -04:00
Add mocked service ID to all service-specific pages
This commit is contained in:
@@ -23,7 +23,7 @@ def test_should_add_service_and_redirect_to_next_page(notifications_admin, notif
|
||||
client.post('/two-factor', data={'sms_code': '12345'})
|
||||
response = client.post('/add-service', data={'service_name': 'testing the post'})
|
||||
assert response.status_code == 302
|
||||
assert response.location == 'http://localhost/dashboard'
|
||||
assert response.location == 'http://localhost/123/dashboard'
|
||||
saved_service = services_dao.find_service_by_service_name('testing the post')
|
||||
assert saved_service is not None
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ def test_should_show_recent_jobs_on_dashboard(notifications_admin,
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.get(url_for('main.dashboard'))
|
||||
response = client.get('/123/dashboard')
|
||||
|
||||
assert response.status_code == 200
|
||||
assert 'Test message 1' in response.get_data(as_text=True)
|
||||
|
||||
@@ -6,7 +6,7 @@ def test_should_return_list_of_all_jobs(notifications_admin, notifications_admin
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.get('/jobs')
|
||||
response = client.get('/123/jobs')
|
||||
|
||||
assert response.status_code == 200
|
||||
assert 'Test message 1' in response.get_data(as_text=True)
|
||||
@@ -18,7 +18,7 @@ def test_should_show_page_for_one_job(notifications_admin, notifications_admin_d
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.get('/jobs/job')
|
||||
response = client.get('/123/jobs/job')
|
||||
|
||||
assert response.status_code == 200
|
||||
assert 'dispatch_20151114.csv' in response.get_data(as_text=True)
|
||||
@@ -30,7 +30,7 @@ def test_should_show_page_for_one_notification(notifications_admin, notification
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.get('/jobs/job/notification/3')
|
||||
response = client.get('/123/jobs/job/notification/3')
|
||||
|
||||
assert response.status_code == 200
|
||||
assert 'Text message' in response.get_data(as_text=True)
|
||||
|
||||
@@ -6,7 +6,7 @@ def test_should_show_overview(notifications_admin, notifications_admin_db, notif
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.get('/service-settings')
|
||||
response = client.get('/123/service-settings')
|
||||
assert response.status_code == 200
|
||||
assert 'Service settings' in response.get_data(as_text=True)
|
||||
|
||||
@@ -16,7 +16,7 @@ def test_should_show_service_name(notifications_admin, notifications_admin_db, n
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.get('/service-settings/name')
|
||||
response = client.get('/123/service-settings/name')
|
||||
assert response.status_code == 200
|
||||
assert 'Change your service name' in response.get_data(as_text=True)
|
||||
|
||||
@@ -26,10 +26,10 @@ def test_should_redirect_after_change_service_name(notifications_admin, notifica
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.post('/service-settings/request-to-go-live')
|
||||
response = client.post('/123/service-settings/request-to-go-live')
|
||||
|
||||
assert response.status_code == 302
|
||||
assert 'http://localhost/service-settings' == response.location
|
||||
assert 'http://localhost/123/service-settings' == response.location
|
||||
|
||||
|
||||
def test_should_show_service_name_confirmation(notifications_admin, notifications_admin_db, notify_db_session):
|
||||
@@ -37,7 +37,7 @@ def test_should_show_service_name_confirmation(notifications_admin, notification
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.get('/service-settings/name/confirm')
|
||||
response = client.get('/123/service-settings/name/confirm')
|
||||
|
||||
assert response.status_code == 200
|
||||
assert 'Change your service name' in response.get_data(as_text=True)
|
||||
@@ -49,10 +49,10 @@ def test_should_redirect_after_service_name_confirmation(notifications_admin, no
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.post('/service-settings/name/confirm')
|
||||
response = client.post('/123/service-settings/name/confirm')
|
||||
|
||||
assert response.status_code == 302
|
||||
assert 'http://localhost/service-settings' == response.location
|
||||
assert 'http://localhost/123/service-settings' == response.location
|
||||
|
||||
|
||||
def test_should_show_request_to_go_live(notifications_admin, notifications_admin_db, notify_db_session):
|
||||
@@ -60,7 +60,7 @@ def test_should_show_request_to_go_live(notifications_admin, notifications_admin
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.get('/service-settings/request-to-go-live')
|
||||
response = client.get('/123/service-settings/request-to-go-live')
|
||||
|
||||
assert response.status_code == 200
|
||||
assert 'Request to go live' in response.get_data(as_text=True)
|
||||
@@ -71,10 +71,10 @@ def test_should_redirect_after_request_to_go_live(notifications_admin, notificat
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.post('/service-settings/request-to-go-live')
|
||||
response = client.post('/123/service-settings/request-to-go-live')
|
||||
|
||||
assert response.status_code == 302
|
||||
assert 'http://localhost/service-settings' == response.location
|
||||
assert 'http://localhost/123/service-settings' == response.location
|
||||
|
||||
|
||||
def test_should_show_status_page(notifications_admin, notifications_admin_db, notify_db_session):
|
||||
@@ -82,7 +82,7 @@ def test_should_show_status_page(notifications_admin, notifications_admin_db, no
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.get('/service-settings/status')
|
||||
response = client.get('/123/service-settings/status')
|
||||
|
||||
assert response.status_code == 200
|
||||
assert 'Turn off all outgoing notifications' in response.get_data(as_text=True)
|
||||
@@ -93,10 +93,10 @@ def test_should_show_redirect_after_status_change(notifications_admin, notificat
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.post('/service-settings/status')
|
||||
response = client.post('/123/service-settings/status')
|
||||
|
||||
assert response.status_code == 302
|
||||
assert 'http://localhost/service-settings/status/confirm' == response.location
|
||||
assert 'http://localhost/123/service-settings/status/confirm' == response.location
|
||||
|
||||
|
||||
def test_should_show_status_confirmation(notifications_admin, notifications_admin_db, notify_db_session):
|
||||
@@ -104,7 +104,7 @@ def test_should_show_status_confirmation(notifications_admin, notifications_admi
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.get('/service-settings/status/confirm')
|
||||
response = client.get('/123/service-settings/status/confirm')
|
||||
|
||||
assert response.status_code == 200
|
||||
assert 'Turn off all outgoing notifications' in response.get_data(as_text=True)
|
||||
@@ -115,10 +115,10 @@ def test_should_redirect_after_status_confirmation(notifications_admin, notifica
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.post('/service-settings/status/confirm')
|
||||
response = client.post('/123/service-settings/status/confirm')
|
||||
|
||||
assert response.status_code == 302
|
||||
assert 'http://localhost/service-settings' == response.location
|
||||
assert 'http://localhost/123/service-settings' == response.location
|
||||
|
||||
|
||||
def test_should_show_delete_page(notifications_admin, notifications_admin_db, notify_db_session):
|
||||
@@ -126,7 +126,7 @@ def test_should_show_delete_page(notifications_admin, notifications_admin_db, no
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.get('/service-settings/delete')
|
||||
response = client.get('/123/service-settings/delete')
|
||||
|
||||
assert response.status_code == 200
|
||||
assert 'Delete this service from Notify' in response.get_data(as_text=True)
|
||||
@@ -137,10 +137,10 @@ def test_should_show_redirect_after_deleting_service(notifications_admin, notifi
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.post('/service-settings/delete')
|
||||
response = client.post('/123/service-settings/delete')
|
||||
|
||||
assert response.status_code == 302
|
||||
assert 'http://localhost/service-settings/delete/confirm' == response.location
|
||||
assert 'http://localhost/123/service-settings/delete/confirm' == response.location
|
||||
|
||||
|
||||
def test_should_show_delete_confirmation(notifications_admin, notifications_admin_db, notify_db_session):
|
||||
@@ -148,7 +148,7 @@ def test_should_show_delete_confirmation(notifications_admin, notifications_admi
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.get('/service-settings/delete/confirm')
|
||||
response = client.get('/123/service-settings/delete/confirm')
|
||||
|
||||
assert response.status_code == 200
|
||||
assert 'Delete this service from Notify' in response.get_data(as_text=True)
|
||||
@@ -159,7 +159,7 @@ def test_should_redirect_delete_confirmation(notifications_admin, notifications_
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.post('/service-settings/delete/confirm')
|
||||
response = client.post('/123/service-settings/delete/confirm')
|
||||
|
||||
assert response.status_code == 302
|
||||
assert 'http://localhost/dashboard' == response.location
|
||||
assert 'http://localhost/123/dashboard' == response.location
|
||||
|
||||
@@ -34,8 +34,7 @@ def test_sign_out_user(notifications_admin,
|
||||
with notifications_admin.test_client() as client:
|
||||
client.login(user)
|
||||
# Check we are logged in
|
||||
response = client.get(
|
||||
url_for('main.dashboard'))
|
||||
response = client.get('/123/dashboard')
|
||||
assert response.status_code == 200
|
||||
response = client.get(url_for('main.sign_out'))
|
||||
assert response.status_code == 302
|
||||
|
||||
@@ -9,7 +9,7 @@ def test_upload_empty_csvfile_returns_to_upload_page(notifications_admin, notifi
|
||||
client.login(user)
|
||||
|
||||
upload_data = {'file': (BytesIO(''.encode('utf-8')), 'emtpy.csv')}
|
||||
response = client.post('/sms/send', data=upload_data,
|
||||
response = client.post('/123/sms/send', data=upload_data,
|
||||
follow_redirects=True)
|
||||
|
||||
assert response.status_code == 200
|
||||
@@ -27,7 +27,7 @@ def test_upload_csvfile_with_invalid_phone_shows_check_page_with_errors(
|
||||
|
||||
file_contents = 'phone\n+44 123\n+44 456'.encode('utf-8')
|
||||
upload_data = {'file': (BytesIO(file_contents), 'invalid.csv')}
|
||||
response = client.post('/sms/send', data=upload_data,
|
||||
response = client.post('/123/sms/send', data=upload_data,
|
||||
follow_redirects=True)
|
||||
assert response.status_code == 200
|
||||
content = response.get_data(as_text=True)
|
||||
@@ -48,7 +48,7 @@ def test_upload_csvfile_with_valid_phone_shows_first3_and_last3_numbers(
|
||||
file_contents = 'phone\n+44 7700 900981\n+44 7700 900982\n+44 7700 900983\n+44 7700 900984\n+44 7700 900985\n+44 7700 900986\n+44 7700 900987\n+44 7700 900988\n+44 7700 900989'.encode('utf-8') # noqa
|
||||
|
||||
upload_data = {'file': (BytesIO(file_contents), 'valid.csv')}
|
||||
response = client.post('/sms/send', data=upload_data,
|
||||
response = client.post('/123/sms/send', data=upload_data,
|
||||
follow_redirects=True)
|
||||
|
||||
content = response.get_data(as_text=True)
|
||||
@@ -79,7 +79,7 @@ def test_upload_csvfile_with_valid_phone_shows_all_if_6_or_less_numbers(
|
||||
file_contents = 'phone\n+44 7700 900981\n+44 7700 900982\n+44 7700 900983\n+44 7700 900984\n+44 7700 900985\n+44 7700 900986'.encode('utf-8') # noqa
|
||||
|
||||
upload_data = {'file': (BytesIO(file_contents), 'valid.csv')}
|
||||
response = client.post('/sms/send', data=upload_data,
|
||||
response = client.post('/123/sms/send', data=upload_data,
|
||||
follow_redirects=True)
|
||||
|
||||
content = response.get_data(as_text=True)
|
||||
@@ -102,7 +102,7 @@ def test_should_redirect_to_job(notifications_admin, notifications_admin_db,
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
|
||||
response = client.post('/sms/check')
|
||||
response = client.post('/123/sms/check')
|
||||
|
||||
assert response.status_code == 302
|
||||
assert response.location == 'http://localhost/jobs/job'
|
||||
assert response.location == 'http://localhost/123/jobs/job'
|
||||
|
||||
@@ -6,7 +6,7 @@ def test_should_return_list_of_all_templates(notifications_admin, notifications_
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.get('/templates')
|
||||
response = client.get('/123/templates')
|
||||
|
||||
assert response.status_code == 200
|
||||
|
||||
@@ -16,7 +16,7 @@ def test_should_show_page_for_one_templates(notifications_admin, notifications_a
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.get('/templates/template')
|
||||
response = client.get('/123/templates/template')
|
||||
|
||||
assert response.status_code == 200
|
||||
|
||||
@@ -26,7 +26,7 @@ def test_should_redirect_when_saving_a_template(notifications_admin, notificatio
|
||||
with notifications_admin.test_client() as client:
|
||||
user = create_test_user('active')
|
||||
client.login(user)
|
||||
response = client.post('/templates/template')
|
||||
response = client.post('/123/templates/template')
|
||||
|
||||
assert response.status_code == 302
|
||||
assert response.location == 'http://localhost/templates'
|
||||
assert response.location == 'http://localhost/123/templates'
|
||||
|
||||
@@ -28,7 +28,7 @@ def test_should_login_user_and_redirect_to_dashboard(notifications_admin, notifi
|
||||
data={'sms_code': '12345'})
|
||||
|
||||
assert response.status_code == 302
|
||||
assert response.location == url_for('main.dashboard', _external=True)
|
||||
assert response.location == url_for('main.dashboard', service_id=123, _external=True)
|
||||
|
||||
|
||||
def test_should_return_200_with_sms_code_error_when_sms_code_is_wrong(notifications_admin,
|
||||
|
||||
Reference in New Issue
Block a user