Skip to content

Commit

Permalink
Add test for notes without a user problem
Browse files Browse the repository at this point in the history
  • Loading branch information
said-moj committed Sep 18, 2024
1 parent 9f16e07 commit 271fa50
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cla_backend/apps/reports/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -1079,7 +1079,7 @@ def _get_col_index(self, column_name):
@staticmethod
def notes_to_dict(notes):
ret = {"user problem": "", "categories": [], "scope": ""}
parts = notes.split("User selected:\nWhat do you need help with?: ")
parts = filter(None, notes.split("User selected:\nWhat do you need help with?: "))
if not notes:
return ret

Expand Down
2 changes: 1 addition & 1 deletion cla_backend/apps/reports/sql/MIScopeReport.sql
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ SELECT
else 'unknown'
END as "Means eligibility state"
,CASE
WHEN ec.state NOT IN('yes', 'no') THEN 'Pending'
WHEN diagnosis.state IS NULL OR diagnosis.state = 'UNKNOWN' THEN 'Pending'
WHEN ec.state IS NOT NULL AND provider_assigned_at IS NULL THEN 'Operator'
-- All the provider outcome codes that are not MI-OOS
WHEN c.provider_viewed IS NOT NULL AND log_mi_oos_outcome_code.code IS NULL AND c.outcome_code IN ('MIS-MEANS', 'COI', 'MIS', 'SPOP', 'CLSP', 'DREFER', 'REOPEN', 'REF-EXT', 'REF-INT', 'REF-EXT_CREATED', 'REF-INT_CREATED') THEN 'Read and approved by SP'
Expand Down
35 changes: 35 additions & 0 deletions cla_backend/apps/reports/tests/test_reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,29 @@ def test_report_client_notes(self):
}
self.assertDictContainsSubset(expected, dict(report[0]))

def test_report_client_notes_no_user_problem(self):
eligible_case = make_recipe("legalaid.eligible_case", source="WEB")
eligible_case.eligibility_check.notes = self.get_notes_without_user_problem()
eligible_case.eligibility_check.save()

self.assertEqual(eligible_case.eligibility_check.state, "yes")
self.assertEqual(eligible_case.diagnosis.state, "INSCOPE")
self.assertEqual(eligible_case.source, "WEB")

report = self.get_report()
expected = {
"Web diagnosis category 1": "Discrimination",
"Web diagnosis category 2": "Age",
"Web diagnosis category 3": "18 or over",
"Web diagnosis category 4": "At work",
"Web diagnosis category 5": "",
"Web diagnosis category 6": "",
"Web scope state": "INSCOPE",
"Client notes": "",
"Workflow status": "Operator",
}
self.assertDictContainsSubset(expected, dict(report[0]))

def test_report_workflow_status_pending(self):
eligible_case = make_recipe("legalaid.case", source="WEB")
self.assertEqual(eligible_case.source, "WEB")
Expand Down Expand Up @@ -637,4 +660,16 @@ def get_notes(self):
Where did the discrimination occur?: At work
Outcome: INSCOPE"""

def get_notes_without_user_problem(self):
return """User selected:
What do you need help with?: Discrimination
On what grounds have you been discriminated against?: Age
How old are you?: 18 or over
Where did the discrimination occur?: At work
Outcome: INSCOPE"""

0 comments on commit 271fa50

Please sign in to comment.