Files
notifications-admin/tests/app/main/views/test_service_settings.py
Chris Hill-Scott de1c0e36c8 Add /services prefix to all service-related URLs
The URLs will be easier to parse if the parts are clearly labelled.

This is a precursor to making a blueprint for all service-related URLs.
2016-01-13 13:25:06 +00:00

166 lines
7.4 KiB
Python

from tests.app.main import create_test_user
def test_should_show_overview(notifications_admin, notifications_admin_db, notify_db_session):
with notifications_admin.test_request_context():
with notifications_admin.test_client() as client:
user = create_test_user('active')
client.login(user)
response = client.get('/services/123/service-settings')
assert response.status_code == 200
assert 'Service settings' in response.get_data(as_text=True)
def test_should_show_service_name(notifications_admin, notifications_admin_db, notify_db_session):
with notifications_admin.test_request_context():
with notifications_admin.test_client() as client:
user = create_test_user('active')
client.login(user)
response = client.get('/services/123/service-settings/name')
assert response.status_code == 200
assert 'Change your service name' in response.get_data(as_text=True)
def test_should_redirect_after_change_service_name(notifications_admin, notifications_admin_db, notify_db_session):
with notifications_admin.test_request_context():
with notifications_admin.test_client() as client:
user = create_test_user('active')
client.login(user)
response = client.post('/services/123/service-settings/request-to-go-live')
assert response.status_code == 302
assert 'http://localhost/services/123/service-settings' == response.location
def test_should_show_service_name_confirmation(notifications_admin, notifications_admin_db, notify_db_session):
with notifications_admin.test_request_context():
with notifications_admin.test_client() as client:
user = create_test_user('active')
client.login(user)
response = client.get('/services/123/service-settings/name/confirm')
assert response.status_code == 200
assert 'Change your service name' in response.get_data(as_text=True)
def test_should_redirect_after_service_name_confirmation(notifications_admin, notifications_admin_db,
notify_db_session):
with notifications_admin.test_request_context():
with notifications_admin.test_client() as client:
user = create_test_user('active')
client.login(user)
response = client.post('/services/123/service-settings/name/confirm')
assert response.status_code == 302
assert 'http://localhost/services/123/service-settings' == response.location
def test_should_show_request_to_go_live(notifications_admin, notifications_admin_db, notify_db_session):
with notifications_admin.test_request_context():
with notifications_admin.test_client() as client:
user = create_test_user('active')
client.login(user)
response = client.get('/services/123/service-settings/request-to-go-live')
assert response.status_code == 200
assert 'Request to go live' in response.get_data(as_text=True)
def test_should_redirect_after_request_to_go_live(notifications_admin, notifications_admin_db, notify_db_session):
with notifications_admin.test_request_context():
with notifications_admin.test_client() as client:
user = create_test_user('active')
client.login(user)
response = client.post('/services/123/service-settings/request-to-go-live')
assert response.status_code == 302
assert 'http://localhost/services/123/service-settings' == response.location
def test_should_show_status_page(notifications_admin, notifications_admin_db, notify_db_session):
with notifications_admin.test_request_context():
with notifications_admin.test_client() as client:
user = create_test_user('active')
client.login(user)
response = client.get('/services/123/service-settings/status')
assert response.status_code == 200
assert 'Turn off all outgoing notifications' in response.get_data(as_text=True)
def test_should_show_redirect_after_status_change(notifications_admin, notifications_admin_db, notify_db_session):
with notifications_admin.test_request_context():
with notifications_admin.test_client() as client:
user = create_test_user('active')
client.login(user)
response = client.post('/services/123/service-settings/status')
assert response.status_code == 302
assert 'http://localhost/services/123/service-settings/status/confirm' == response.location
def test_should_show_status_confirmation(notifications_admin, notifications_admin_db, notify_db_session):
with notifications_admin.test_request_context():
with notifications_admin.test_client() as client:
user = create_test_user('active')
client.login(user)
response = client.get('/services/123/service-settings/status/confirm')
assert response.status_code == 200
assert 'Turn off all outgoing notifications' in response.get_data(as_text=True)
def test_should_redirect_after_status_confirmation(notifications_admin, notifications_admin_db, notify_db_session):
with notifications_admin.test_request_context():
with notifications_admin.test_client() as client:
user = create_test_user('active')
client.login(user)
response = client.post('/services/123/service-settings/status/confirm')
assert response.status_code == 302
assert 'http://localhost/services/123/service-settings' == response.location
def test_should_show_delete_page(notifications_admin, notifications_admin_db, notify_db_session):
with notifications_admin.test_request_context():
with notifications_admin.test_client() as client:
user = create_test_user('active')
client.login(user)
response = client.get('/services/123/service-settings/delete')
assert response.status_code == 200
assert 'Delete this service from Notify' in response.get_data(as_text=True)
def test_should_show_redirect_after_deleting_service(notifications_admin, notifications_admin_db, notify_db_session):
with notifications_admin.test_request_context():
with notifications_admin.test_client() as client:
user = create_test_user('active')
client.login(user)
response = client.post('/services/123/service-settings/delete')
assert response.status_code == 302
assert 'http://localhost/services/123/service-settings/delete/confirm' == response.location
def test_should_show_delete_confirmation(notifications_admin, notifications_admin_db, notify_db_session):
with notifications_admin.test_request_context():
with notifications_admin.test_client() as client:
user = create_test_user('active')
client.login(user)
response = client.get('/services/123/service-settings/delete/confirm')
assert response.status_code == 200
assert 'Delete this service from Notify' in response.get_data(as_text=True)
def test_should_redirect_delete_confirmation(notifications_admin, notifications_admin_db, notify_db_session):
with notifications_admin.test_request_context():
with notifications_admin.test_client() as client:
user = create_test_user('active')
client.login(user)
response = client.post('/services/123/service-settings/delete/confirm')
assert response.status_code == 302
assert 'http://localhost/services/123/dashboard' == response.location