Functionality added to existing endpoint without a user_has_permission decorator, tests passing.

Fix tests.
This commit is contained in:
Nicholas Staples
2016-03-23 12:15:57 +00:00
parent bb08589875
commit 961ed6b362
7 changed files with 58 additions and 8 deletions

View File

@@ -278,7 +278,8 @@ def test_new_invited_user_verifies_and_added_to_service(app_,
mock_get_service,
mock_get_service_templates,
mock_get_service_statistics,
mock_get_jobs):
mock_get_jobs,
mock_has_permissions):
with app_.test_request_context():
with app_.test_client() as client:

View File

@@ -1,4 +1,5 @@
from flask import url_for
from tests import validate_route_permission
def test_should_show_recent_jobs_on_dashboard(app_,
@@ -9,7 +10,8 @@ def test_should_show_recent_jobs_on_dashboard(app_,
mock_get_user,
mock_get_user_by_email,
mock_login,
mock_get_jobs):
mock_get_jobs,
mock_has_permissions):
with app_.test_request_context():
with app_.test_client() as client:
@@ -133,3 +135,30 @@ def test_menu_all_services_for_platform_admin_user(mocker, app_, platform_admin_
assert url_for('main.view_notifications', service_id=service_one['id']) in page
assert url_for('main.view_jobs', service_id=service_one['id']) in page
assert url_for('main.api_keys', service_id=service_one['id']) not in page
def test_route_for_service_permissions(mocker,
app_,
api_user_active,
service_one,
mock_get_service,
mock_get_user,
mock_get_service_templates,
mock_get_jobs,
mock_get_service_statistics):
routes = [
'main.service_dashboard']
with app_.test_request_context():
# Just test that the user is part of the service
for route in routes:
validate_route_permission(
mocker,
app_,
"GET",
200,
url_for(
route,
service_id=service_one['id']),
[],
api_user_active,
service_one)

View File

@@ -9,7 +9,8 @@ def test_should_return_list_of_all_jobs(app_,
mock_get_user,
mock_get_user_by_email,
mock_login,
mock_get_jobs):
mock_get_jobs,
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_show_page_for_one_job(
mock_get_service_template,
job_data,
mock_get_job,
mock_get_notifications
mock_get_notifications,
mock_has_permissions
):
service_id = job_data['service']
job_id = job_data['id']
@@ -61,7 +63,8 @@ def test_should_show_updates_for_one_job_as_json(
mock_get_service_template,
job_data,
mock_get_job,
mock_get_notifications
mock_get_notifications,
mock_has_permissions
):
service_id = job_data['service']
job_id = job_data['id']
@@ -88,7 +91,8 @@ def test_should_show_notifications_for_a_service(app_,
mock_get_user,
mock_get_user_by_email,
mock_get_service,
mock_get_notifications):
mock_get_notifications,
mock_has_permissions):
with app_.test_request_context():
with app_.test_client() as client:
client.login(api_user_active)
@@ -110,7 +114,8 @@ def test_should_show_notifications_for_a_service_with_next_previous(app_,
mock_get_user,
mock_get_user_by_email,
mock_get_service,
mock_get_notifications_with_previous_next):
mock_get_notifications_with_previous_next,
mock_has_permissions):
with app_.test_request_context():
with app_.test_client() as client:
client.login(api_user_active)

View File

@@ -762,3 +762,10 @@ def mock_set_user_permissions(mocker):
@pytest.fixture(scope='function')
def mock_remove_user_from_service(mocker):
return mocker.patch('app.service_api_client.remove_user_from_service', return_value=None)
@pytest.fixture(scope='function')
def mock_get_service_statistics(mocker):
return mocker.patch(
'app.statistics_api_client.get_statistics_for_service',
return_value={'data': [{}]})