Skip to content

Commit

Permalink
Merge branch 'dev' into LTD-5824-CRN-validation-prefix-changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Tllew authored Jan 23, 2025
2 parents 13ec8fb + 387afb1 commit 43ce6ba
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 6 deletions.
13 changes: 10 additions & 3 deletions caseworker/cases/helpers/case.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

TAU_ALIAS = "TAU"
LU_ALIAS = "LICENSING_UNIT"
FCDO_ALIAS = "FCO"
LU_POST_CIRC_FINALISE_QUEUE_ALIAS = "LU_POST_CIRC_FINALISE"
LU_PRE_CIRC_REVIEW_QUEUE_ALIAS = "LU_PRE_CIRC_REVIEW"

Expand Down Expand Up @@ -85,6 +86,9 @@ def is_tau_user(self):
def is_lu_user(self):
return self.caseworker["team"]["alias"] == LU_ALIAS

def is_fcdo_user(self):
return self.caseworker["team"]["alias"] == FCDO_ALIAS

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
allocate_to_me_form = (
Expand All @@ -99,6 +103,11 @@ def get_context_data(self, **kwargs):
}
)
)
approve_all_url = reverse("cases:approve_all", kwargs={"queue_pk": self.queue_id, "pk": self.case_id})
if self.is_fcdo_user():
approve_all_url = reverse(
"cases:approve_all_legacy", kwargs={"queue_pk": self.queue_id, "pk": self.case_id}
)
allocate_and_approve_form = (
None
if self.queue["is_system_queue"]
Expand All @@ -108,9 +117,7 @@ def get_context_data(self, **kwargs):
"queue_id": self.queue_id,
"user_id": self.caseworker["id"],
"case_id": self.case_id,
"return_to": reverse(
"cases:approve_all_legacy", kwargs={"queue_pk": self.queue_id, "pk": self.case_id}
),
"return_to": approve_all_url,
},
)
)
Expand Down
67 changes: 64 additions & 3 deletions unit_tests/caseworker/cases/views/test_quick_summary.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import re
from decimal import Decimal
import pytest
from bs4 import BeautifulSoup
Expand All @@ -6,11 +7,12 @@

from django.urls import reverse

from core import client


@pytest.fixture(autouse=True)
def setup(
settings,
mock_queue,
mock_gov_lu_user,
mock_case,
mock_standard_case_activity_filters,
Expand All @@ -24,7 +26,37 @@ def setup(
pass


def test_case_summary_activated(authorized_client, data_queue, data_standard_case):
@pytest.fixture
def mock_gov_fcdo_ogd_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": "FCDO",
"alias": "FCO",
}

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 data_ogd_queue():
return {
"id": "00000000-0000-0000-0000-000000000002",
"alias": None,
"name": "Some OGD",
"is_system_queue": False,
"countersigning_queue": None,
}


@pytest.fixture
def mock_ogd_queue(requests_mock, data_ogd_queue):
url = client._build_absolute_uri("/queues/")
yield requests_mock.get(url=re.compile(f"{url}.*/"), json=data_ogd_queue)


def test_case_summary_activated(authorized_client, data_queue, data_standard_case, mock_queue):
url = reverse(
"cases:case",
kwargs={"queue_pk": data_queue["id"], "pk": data_standard_case["case"]["id"], "tab": "quick-summary"},
Expand All @@ -33,7 +65,35 @@ def test_case_summary_activated(authorized_client, data_queue, data_standard_cas
assertTemplateUsed(response, "case/tabs/quick-summary.html")


def test_case_summary_data(authorized_client, data_queue, data_standard_case):
def test_case_summary_allocate_and_approve(authorized_client, data_ogd_queue, data_standard_case, mock_ogd_queue):
url = reverse(
"cases:case",
kwargs={"queue_pk": data_ogd_queue["id"], "pk": data_standard_case["case"]["id"], "tab": "quick-summary"},
)
response = authorized_client.get(url)
assertTemplateUsed(response, "case/tabs/quick-summary.html")
assert "allocate_and_approve_form" in response.context
assert response.context["allocate_and_approve_form"].initial["return_to"] == reverse(
"cases:approve_all", kwargs={"queue_pk": data_ogd_queue["id"], "pk": data_standard_case["case"]["id"]}
)


def test_case_summary_allocate_and_approve_fcdo(
authorized_client, data_ogd_queue, data_standard_case, mock_ogd_queue, mock_gov_fcdo_ogd_user
):
url = reverse(
"cases:case",
kwargs={"queue_pk": data_ogd_queue["id"], "pk": data_standard_case["case"]["id"], "tab": "quick-summary"},
)
response = authorized_client.get(url)
assertTemplateUsed(response, "case/tabs/quick-summary.html")
assert "allocate_and_approve_form" in response.context
assert response.context["allocate_and_approve_form"].initial["return_to"] == reverse(
"cases:approve_all_legacy", kwargs={"queue_pk": data_ogd_queue["id"], "pk": data_standard_case["case"]["id"]}
)


def test_case_summary_data(authorized_client, data_queue, data_standard_case, mock_queue):
gov_user = {
"id": "2a43805b-c082-47e7-9188-c8b3e1a83cb0",
"email": "[email protected]",
Expand Down Expand Up @@ -158,6 +218,7 @@ def test_case_summary_data(authorized_client, data_queue, data_standard_case):
def test_case_summary_sub_status(
data_standard_case,
data_queue,
mock_queue,
authorized_client,
value,
expected,
Expand Down

0 comments on commit 43ce6ba

Please sign in to comment.