Permissions added for templates and send_messages pages. All tests passing.

Fix up page heading.
This commit is contained in:
Nicholas Staples
2016-02-29 17:03:56 +00:00
parent 900f4cd7ff
commit ffe30c3070
11 changed files with 106 additions and 35 deletions

View File

@@ -17,7 +17,8 @@ def test_choose_template(
mock_get_service,
mock_check_verify_code,
mock_get_service_templates,
mock_get_jobs
mock_get_jobs,
mock_has_permissions
):
with app_.test_request_context():
with app_.test_client() as client:
@@ -40,7 +41,8 @@ def test_upload_empty_csvfile_returns_to_upload_page(
mock_get_service,
mock_get_service_templates,
mock_check_verify_code,
mock_get_service_template
mock_get_service_template,
mock_has_permissions
):
with app_.test_request_context():
with app_.test_client() as client:
@@ -64,7 +66,8 @@ def test_upload_csvfile_with_invalid_phone_shows_check_page_with_errors(
mock_login,
mock_get_service,
mock_get_service_template,
mock_s3_upload
mock_s3_upload,
mock_has_permissions
):
contents = 'to,name\n+44 123,test1\n+44 456,test2'
@@ -95,7 +98,8 @@ def test_upload_csvfile_removes_empty_lines_and_trailing_commas(
mock_login,
mock_get_service,
mock_get_service_template,
mock_s3_upload
mock_s3_upload,
mock_has_permissions
):
contents = 'to,name,,,\n++44 7700 900981,test1,,,\n+44 7700 900981,test2,,,\n ,,, \n ,,, \t \t \n'
@@ -127,7 +131,8 @@ def test_send_test_message_to_self(
mock_login,
mock_get_service,
mock_get_service_template,
mock_s3_upload
mock_s3_upload,
mock_has_permissions
):
expected_data = {'data': ['to', '+4412341234'], 'file_name': 'Test run'}
@@ -150,7 +155,8 @@ def test_download_example_csv(
api_user_active,
mock_login,
mock_get_service,
mock_get_service_template
mock_get_service_template,
mock_has_permissions
):
with app_.test_request_context():
@@ -172,7 +178,8 @@ def test_upload_csvfile_with_valid_phone_shows_all_numbers(
mock_login,
mock_get_service,
mock_get_service_template,
mock_s3_upload
mock_s3_upload,
mock_has_permissions
):
contents = 'to\n+44 7700 900981\n+44 7700 900982\n+44 7700 900983\n+44 7700 900984\n+44 7700 900985\n+44 7700 900986' # noqa
@@ -211,7 +218,8 @@ def test_create_job_should_call_api(
mock_create_job,
mock_get_job,
mock_get_service,
mock_get_service_template
mock_get_service_template,
mock_has_permissions
):
service_id = service_one['id']

View File

@@ -6,7 +6,8 @@ def test_should_show_overview(app_,
mock_get_service,
mock_get_user,
mock_get_user_by_email,
mock_login):
mock_login,
mock_has_permissions):
with app_.test_request_context():
with app_.test_client() as client:
client.login(api_user_active)
@@ -25,7 +26,8 @@ def test_should_show_service_name(app_,
mock_get_service,
mock_get_user,
mock_get_user_by_email,
mock_login):
mock_login,
mock_has_permissions):
with app_.test_request_context():
with app_.test_client() as client:
client.login(api_user_active)
@@ -44,7 +46,8 @@ def test_should_redirect_after_change_service_name(app_,
mock_get_service,
mock_get_user,
mock_get_user_by_email,
mock_login):
mock_login,
mock_has_permissions):
with app_.test_request_context():
with app_.test_client() as client:
client.login(api_user_active)
@@ -64,7 +67,8 @@ def test_should_show_service_name_confirmation(app_,
mock_get_service,
mock_get_user,
mock_get_user_by_email,
mock_login):
mock_login,
mock_has_permissions):
with app_.test_request_context():
with app_.test_client() as client:
client.login(api_user_active)
@@ -85,7 +89,8 @@ def test_should_redirect_after_service_name_confirmation(app_,
mock_get_user,
mock_get_user_by_email,
mock_login,
mock_verify_password):
mock_verify_password,
mock_has_permissions):
with app_.test_request_context():
with app_.test_client() as client:
client.login(api_user_active)
@@ -110,7 +115,8 @@ def test_should_show_request_to_go_live(app_,
mock_get_service,
mock_get_user,
mock_get_user_by_email,
mock_login):
mock_login,
mock_has_permissions):
with app_.test_request_context():
with app_.test_client() as client:
client.login(api_user_active)
@@ -130,7 +136,8 @@ def test_should_redirect_after_request_to_go_live(app_,
mock_update_service,
mock_get_user,
mock_get_user_by_email,
mock_login):
mock_login,
mock_has_permissions):
with app_.test_request_context():
with app_.test_client() as client:
client.login(api_user_active)
@@ -151,7 +158,8 @@ def test_should_show_status_page(app_,
mock_get_service,
mock_get_user,
mock_get_user_by_email,
mock_login):
mock_login,
mock_has_permissions):
with app_.test_request_context():
with app_.test_client() as client:
client.login(api_user_active)
@@ -170,7 +178,8 @@ def test_should_show_redirect_after_status_change(app_,
mock_get_service,
mock_get_user,
mock_get_user_by_email,
mock_login):
mock_login,
mock_has_permissions):
with app_.test_request_context():
with app_.test_client() as client:
client.login(api_user_active)
@@ -190,7 +199,8 @@ def test_should_show_status_confirmation(app_,
mock_get_service,
mock_get_user,
mock_get_user_by_email,
mock_login):
mock_login,
mock_has_permissions):
with app_.test_request_context():
with app_.test_client() as client:
client.login(api_user_active)
@@ -211,7 +221,8 @@ def test_should_redirect_after_status_confirmation(app_,
mock_get_user,
mock_get_user_by_email,
mock_login,
mock_verify_password):
mock_verify_password,
mock_has_permissions):
with app_.test_request_context():
with app_.test_client() as client:
client.login(api_user_active)
@@ -232,7 +243,8 @@ def test_should_show_delete_page(app_,
mock_get_service,
mock_get_user,
mock_get_user_by_email,
mock_login):
mock_login,
mock_has_permissions):
with app_.test_request_context():
with app_.test_client() as client:
client.login(api_user_active)
@@ -250,7 +262,8 @@ def test_should_show_redirect_after_deleting_service(app_,
mock_get_service,
mock_get_user,
mock_get_user_by_email,
mock_login):
mock_login,
mock_has_permissions):
with app_.test_request_context():
with app_.test_client() as client:
client.login(api_user_active)
@@ -269,7 +282,8 @@ def test_should_show_delete_confirmation(app_,
mock_get_service,
mock_get_user,
mock_get_user_by_email,
mock_login):
mock_login,
mock_has_permissions):
with app_.test_request_context():
with app_.test_client() as client:
client.login(api_user_active)
@@ -289,7 +303,8 @@ def test_should_redirect_delete_confirmation(app_,
mock_get_user,
mock_get_user_by_email,
mock_login,
mock_verify_password):
mock_verify_password,
mock_has_permissions):
with app_.test_request_context():
with app_.test_client() as client:
client.login(api_user_active)

View File

@@ -9,7 +9,8 @@ def test_should_show_page_for_one_templates(app_,
mock_get_service_template,
mock_get_user,
mock_get_user_by_email,
mock_login):
mock_login,
mock_has_permissions):
with app_.test_request_context():
with app_.test_client() as client:
client.login(api_user_active)
@@ -33,7 +34,8 @@ def test_should_redirect_when_saving_a_template(app_,
mock_update_service_template,
mock_get_user,
mock_get_user_by_email,
mock_login):
mock_login,
mock_has_permissions):
with app_.test_request_context():
with app_.test_client() as client:
client.login(api_user_active)
@@ -65,7 +67,8 @@ def test_should_show_delete_template_page(app_,
mock_get_service_template,
mock_get_user,
mock_get_user_by_email,
mock_login):
mock_login,
mock_has_permissions):
with app_.test_request_context():
with app_.test_client() as client:
client.login(api_user_active)
@@ -91,7 +94,8 @@ def test_should_redirect_when_deleting_a_template(app_,
mock_delete_service_template,
mock_get_user,
mock_get_user_by_email,
mock_login):
mock_login,
mock_has_permissions):
with app_.test_request_context():
with app_.test_client() as client:
client.login(api_user_active)

View File

@@ -519,7 +519,7 @@ def mock_get_jobs(mocker):
@pytest.fixture(scope='function')
def mock_has_permissions(mocker):
def _has_permission(service_id, permissions):
def _has_permission(service_id, permissions, or_=False):
return True
return mocker.patch(
'app.notify_client.user_api_client.User.has_permissions',