Skip to content

Commit

Permalink
Merge branch 'dev' into LTD-4926-Spell-out-ECJU-in-first-use-in-LITE
Browse files Browse the repository at this point in the history
  • Loading branch information
markj0hnst0n authored Apr 16, 2024
2 parents 62af1ee + a2cb90d commit e6d1490
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 2 deletions.
1 change: 0 additions & 1 deletion caseworker/core/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ def get_permissible_statuses(request, case):
if status["key"]
not in [
CaseStatusEnum.APPLICANT_EDITING,
CaseStatusEnum.CLOSED,
CaseStatusEnum.FINALISED,
CaseStatusEnum.REGISTERED,
CaseStatusEnum.CLC,
Expand Down
36 changes: 36 additions & 0 deletions unit_tests/caseworker/cases/views/test_change_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,42 @@ def test_change_status_GET_provides_finalise_status(
assert (CaseStatusEnum.FINALISED in statuses) == expected


@pytest.mark.parametrize(
"gov_user_type,expected",
[
("mock_gov_tau_user", False),
("mock_gov_fcdo_user", False),
("mock_gov_desnz_nuclear_user", False),
("mock_gov_lu_user", False),
("mock_gov_lu_super_user", True),
],
)
def test_closed_status_visible_to_specific_roles(
authorized_client,
change_status_url,
case_id,
gov_user_type,
expected,
request,
):
_ = request.getfixturevalue(gov_user_type)

response = authorized_client.get(change_status_url)
assert response.status_code == 200

assertTemplateUsed(response, "layouts/case.html")
context = response.context
assert context["case"].id == case_id

html = BeautifulSoup(response.content, "html.parser")
all_h1s = [elem.get_text().strip() for elem in html.find_all("h1")]
assert "Change case status" in all_h1s

# Only LU users get an option set the status as 'Finalised'
statuses = [item["value"] for item in html.find_all("option")]
assert (CaseStatusEnum.CLOSED in statuses) == expected


def test_change_status_success(
authorized_client,
case_url,
Expand Down
17 changes: 16 additions & 1 deletion unit_tests/caseworker/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,22 @@ def mock_gov_lu_user(requests_mock, mock_notifications, mock_case_statuses, mock
requests_mock.get(url=re.compile(f"{url}{gov_uk_user_id}/"), json=mock_gov_user)


@pytest.fixture
def mock_gov_lu_super_user(requests_mock, mock_notifications, mock_case_statuses, mock_gov_user, gov_uk_user_id):
mock_gov_user["user"]["team"] = {
"id": "521154de-f39e-45bf-9922-baaaaaa",
"name": "Licencing Unit",
"alias": "LICENSING_UNIT",
}
mock_gov_user["user"]["role"]["statuses"].extend(
[{"id": "00000000-0000-0000-0000-000000000009", "key": "closed", "value": "Closed", "priority": 16}]
)

url = client._build_absolute_uri("/gov-users/")
requests_mock.get(url=f"{url}me/", json=mock_gov_user)
requests_mock.get(url=re.compile(f"{url}{gov_uk_user_id}/"), json=mock_gov_user)


@pytest.fixture
def mock_notifications(requests_mock):
url = client._build_absolute_uri("/gov-users/notifications/")
Expand Down Expand Up @@ -1605,7 +1621,6 @@ def mock_case_statuses(requests_mock):
"priority": 14,
},
{"id": "00000000-0000-0000-0000-000000000008", "key": "withdrawn", "value": "Withdrawn", "priority": 15},
{"id": "00000000-0000-0000-0000-000000000009", "key": "closed", "value": "Closed", "priority": 16},
{"id": "00000000-0000-0000-0000-000000000010", "key": "registered", "value": "Registered", "priority": 17},
{
"id": "00000000-0000-0000-0000-000000000011",
Expand Down

0 comments on commit e6d1490

Please sign in to comment.