Files
notifications-admin/tests/app/main/views/test_add_service.py
Chris Hill-Scott f129cc3db2 Reword the add service page
Without the preview service name we probably have to go back to communicating
a bit more on the add service page. This commit brings back the two bullet
points about where the service name will appear, and tries to tie it into the
nice words that Matt Sheret wrote for us.
2016-02-26 13:17:58 +00:00

67 lines
3.5 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from flask import url_for
from app.main.dao import services_dao
def test_get_should_render_add_service_template(app_,
api_user_active,
mock_login,
mock_get_service,
mock_get_services,
mock_get_user,
mock_get_user_by_email):
with app_.test_request_context():
with app_.test_client() as client:
client.login(api_user_active)
response = client.get(url_for('main.add_service'))
assert response.status_code == 200
assert 'Which service do you want to set up notifications for?' in response.get_data(as_text=True)
def test_should_add_service_and_redirect_to_next_page(app_,
mock_login,
mock_create_service,
mock_get_services,
api_user_active,
mock_get_user,
mock_get_user_by_email):
with app_.test_request_context():
with app_.test_client() as client:
client.login(api_user_active)
response = client.post(
url_for('main.add_service'),
data={'name': 'testing the post'})
assert response.status_code == 302
assert response.location == url_for('main.service_dashboard', service_id=101, _external=True)
assert mock_create_service.called
def test_should_return_form_errors_when_service_name_is_empty(app_,
api_user_active,
mock_get_service,
mock_get_services,
mock_get_user,
mock_get_user_by_email,
mock_login):
with app_.test_request_context():
with app_.test_client() as client:
client.login(api_user_active)
response = client.post(url_for('main.add_service'), data={})
assert response.status_code == 200
assert 'Service name cant be empty' in response.get_data(as_text=True)
def test_should_return_form_errors_with_duplicate_service_name(app_,
mock_login,
mock_get_services,
mock_get_user,
api_user_active,
mock_get_user_by_email):
with app_.test_request_context():
with app_.test_client() as client:
client.login(api_user_active)
response = client.post(
url_for('main.add_service'), data={'name': 'service_one'})
assert response.status_code == 200
assert 'This service name is already in use' in response.get_data(as_text=True)
assert mock_get_services.called