2016-01-14 14:03:27 +00:00
|
|
|
from flask import url_for
|
2016-01-11 16:03:41 +00:00
|
|
|
|
|
|
|
|
|
2016-01-19 09:49:01 +00:00
|
|
|
def test_should_return_list_of_all_templates(app_, db_, db_session, active_user):
|
2016-01-15 15:15:35 +00:00
|
|
|
with app_.test_request_context():
|
|
|
|
|
with app_.test_client() as client:
|
2016-01-19 09:49:01 +00:00
|
|
|
client.login(active_user)
|
2016-01-14 14:03:27 +00:00
|
|
|
response = client.get(url_for('.manage_templates', service_id=123))
|
2015-12-20 00:00:01 +00:00
|
|
|
|
|
|
|
|
assert response.status_code == 200
|
|
|
|
|
|
|
|
|
|
|
2016-01-19 09:49:01 +00:00
|
|
|
def test_should_show_page_for_one_templates(app_, db_, db_session, active_user):
|
2016-01-15 15:15:35 +00:00
|
|
|
with app_.test_request_context():
|
|
|
|
|
with app_.test_client() as client:
|
2016-01-19 09:49:01 +00:00
|
|
|
client.login(active_user)
|
2016-01-14 14:03:27 +00:00
|
|
|
response = client.get(url_for('.edit_template', service_id=123, template_id=1))
|
2015-12-20 00:00:01 +00:00
|
|
|
|
|
|
|
|
assert response.status_code == 200
|
|
|
|
|
|
|
|
|
|
|
2016-01-19 09:49:01 +00:00
|
|
|
def test_should_redirect_when_saving_a_template(app_, db_, db_session, active_user):
|
2016-01-15 15:15:35 +00:00
|
|
|
with app_.test_request_context():
|
|
|
|
|
with app_.test_client() as client:
|
2016-01-19 09:49:01 +00:00
|
|
|
client.login(active_user)
|
2016-01-14 14:03:27 +00:00
|
|
|
response = client.post(url_for('.edit_template', service_id=123, template_id=1))
|
2015-12-20 00:00:01 +00:00
|
|
|
|
2016-01-14 14:03:27 +00:00
|
|
|
assert response.status_code == 302
|
|
|
|
|
assert response.location == url_for('.manage_templates', service_id=123, _external=True)
|
2016-01-14 09:44:06 +00:00
|
|
|
|
|
|
|
|
|
2016-01-19 09:49:01 +00:00
|
|
|
def test_should_show_delete_template_page(app_, db_, db_session, active_user):
|
|
|
|
|
with app_.test_request_context():
|
|
|
|
|
with app_.test_client() as client:
|
|
|
|
|
client.login(active_user)
|
2016-01-14 14:03:27 +00:00
|
|
|
response = client.get(url_for('.delete_template', service_id=123, template_id=1))
|
2016-01-14 09:44:06 +00:00
|
|
|
|
|
|
|
|
assert response.status_code == 200
|
|
|
|
|
assert 'Are you sure' in response.get_data(as_text=True)
|
|
|
|
|
|
|
|
|
|
|
2016-01-19 09:49:01 +00:00
|
|
|
def test_should_redirect_when_deleting_a_template(app_, db_, db_session, active_user):
|
|
|
|
|
with app_.test_request_context():
|
|
|
|
|
with app_.test_client() as client:
|
|
|
|
|
client.login(active_user)
|
2016-01-14 14:03:27 +00:00
|
|
|
response = client.post(url_for('.delete_template', service_id=123, template_id=1))
|
2015-12-20 00:00:01 +00:00
|
|
|
|
2016-01-14 14:03:27 +00:00
|
|
|
assert response.status_code == 302
|
|
|
|
|
assert response.location == url_for('.manage_templates', service_id=123, _external=True)
|