mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-24 00:07:02 -04:00
Make test more robust
Now tests: - that the user doesn’t have the usage menu item when they’re not a member of the organisation (i.e. the counterfactual) - that the user still gets a 403 when they try to view the usage page if they’re not a member of the organisation
This commit is contained in:
@@ -378,7 +378,28 @@ def test_service_navigation_for_org_user(
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def test_org_user_who_is_also_service_user_can_still_see_usage_page(
|
@pytest.mark.parametrize('user_organisations, expected_menu_items, expected_status', [
|
||||||
|
(
|
||||||
|
[],
|
||||||
|
(
|
||||||
|
'Templates',
|
||||||
|
'Sent messages',
|
||||||
|
'Team members',
|
||||||
|
),
|
||||||
|
403,
|
||||||
|
),
|
||||||
|
(
|
||||||
|
[ORGANISATION_ID],
|
||||||
|
(
|
||||||
|
'Templates',
|
||||||
|
'Sent messages',
|
||||||
|
'Team members',
|
||||||
|
'Usage',
|
||||||
|
),
|
||||||
|
200,
|
||||||
|
),
|
||||||
|
])
|
||||||
|
def test_service_user_without_manage_service_permission_can_see_usage_page_when_org_user(
|
||||||
client_request,
|
client_request,
|
||||||
mocker,
|
mocker,
|
||||||
active_caseworking_user,
|
active_caseworking_user,
|
||||||
@@ -390,9 +411,14 @@ def test_org_user_who_is_also_service_user_can_still_see_usage_page(
|
|||||||
mock_get_invites_for_service,
|
mock_get_invites_for_service,
|
||||||
mock_get_users_by_service,
|
mock_get_users_by_service,
|
||||||
mock_get_service_organisation,
|
mock_get_service_organisation,
|
||||||
|
mock_get_service_templates,
|
||||||
|
mock_get_template_folders,
|
||||||
|
user_organisations,
|
||||||
|
expected_status,
|
||||||
|
expected_menu_items,
|
||||||
):
|
):
|
||||||
active_caseworking_user['services'] = [SERVICE_ONE_ID]
|
active_caseworking_user['services'] = [SERVICE_ONE_ID]
|
||||||
active_caseworking_user['organisations'] = [ORGANISATION_ID]
|
active_caseworking_user['organisations'] = user_organisations
|
||||||
service = service_json(
|
service = service_json(
|
||||||
id_=SERVICE_ONE_ID,
|
id_=SERVICE_ONE_ID,
|
||||||
organisation_id=ORGANISATION_ID,
|
organisation_id=ORGANISATION_ID,
|
||||||
@@ -402,19 +428,19 @@ def test_org_user_who_is_also_service_user_can_still_see_usage_page(
|
|||||||
return_value={'data': service}
|
return_value={'data': service}
|
||||||
)
|
)
|
||||||
client_request.login(active_caseworking_user, service=service)
|
client_request.login(active_caseworking_user, service=service)
|
||||||
|
|
||||||
page = client_request.get(
|
page = client_request.get(
|
||||||
'main.usage',
|
'main.choose_template',
|
||||||
service_id=SERVICE_ONE_ID,
|
service_id=SERVICE_ONE_ID,
|
||||||
)
|
)
|
||||||
assert [
|
assert tuple(
|
||||||
item.text.strip() for item in page.select('nav.navigation a')
|
item.text.strip() for item in page.select('nav.navigation a')
|
||||||
] == [
|
) == expected_menu_items
|
||||||
'Templates',
|
|
||||||
'Sent messages',
|
client_request.get(
|
||||||
'Team members',
|
'main.usage',
|
||||||
'Usage',
|
service_id=SERVICE_ONE_ID,
|
||||||
]
|
_expected_status=expected_status,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_name_of_decorator_from_ast_node(node):
|
def get_name_of_decorator_from_ast_node(node):
|
||||||
|
|||||||
Reference in New Issue
Block a user