Skip to content

Commit

Permalink
tidy test and refine hepler fuction
Browse files Browse the repository at this point in the history
  • Loading branch information
markj0hnst0n committed Feb 27, 2025
1 parent 6a232f5 commit 0b33089
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 27 deletions.
2 changes: 0 additions & 2 deletions caseworker/cases/helpers/case.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,6 @@ def get_case_detail_url(case_id, case_type, queue_id):
"standard": {"url": "cases:case", "kwargs": {"queue_pk": queue_id, "pk": case_id, "tab": "details"}},
}

case_type = case_type["sub_type"]["key"]
url_name = destinations[case_type]["url"]
kwargs = destinations[case_type]["kwargs"]

return reverse(url_name, kwargs=kwargs)
34 changes: 10 additions & 24 deletions caseworker/cases/helpers/tests/test_case.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,25 @@
import pytest
from uuid import uuid4

from ..case import get_case_detail_url


@pytest.mark.parametrize(
"case, expected",
"case_type, expected",
(
(
{
"id": "67271217-7e55-4345-9db4-31de1bfe4067",
"case_type": {
"id": "00000000-0000-0000-0000-000000000007",
"reference": {"key": "f680", "value": "MOD F680 Clearance"},
"sub_type": {"key": "f680_clearance", "value": "MOD F680 Clearance"},
"type": {"key": "application", "value": "Application"},
},
},
"/queues/00000000-0000-0000-0000-000000000001/cases/67271217-7e55-4345-9db4-31de1bfe4067/f680/",
"f680_clearance",
"f680",
),
(
{
"id": "67271217-7e55-4345-9db4-31de1bfe4067",
"case_type": {
"id": "00000000-0000-0000-0000-000000000004",
"reference": {"key": "siel", "value": "Standard Individual Export Licence"},
"type": {"key": "application", "value": "Application"},
"sub_type": {"key": "standard", "value": "Standard Licence"},
},
},
"/queues/00000000-0000-0000-0000-000000000001/cases/67271217-7e55-4345-9db4-31de1bfe4067/details/",
"standard",
"details",
),
),
)
def test_get_case_detail_url(case, expected):
def test_get_case_detail_url(case_type, expected):
case_id = uuid4()
queue_id = "00000000-0000-0000-0000-000000000001"
result = get_case_detail_url(case["id"], case["case_type"], queue_id)
result = get_case_detail_url(case_id, case_type, queue_id)

assert result == expected
assert result == f"/queues/{queue_id}/cases/{case_id}/{expected}/"
3 changes: 2 additions & 1 deletion caseworker/cases/views/case_assignments.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ def form_valid(self, form):

def get_success_url(self):
case = self.get_case()
return get_case_detail_url(case.id, case.case_type, self.kwargs["queue_pk"])
case_type = case.case_type["sub_type"]["key"]
return get_case_detail_url(case.id, case_type, self.kwargs["queue_pk"])


class CaseOfficerRemove(LoginRequiredMixin, FormView):
Expand Down

0 comments on commit 0b33089

Please sign in to comment.