Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LGA-3319: Add additional MI Scope Report tests for new notes format #1251

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cla_backend/apps/reports/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -1084,7 +1084,7 @@ def _get_col_index(self, column_name):
def notes_to_dict(notes):
def get_categories_and_scope(user_selected_text):
items, scope = user_selected_text.split("Outcome: ")
scope = re.sub(r"\s+|\n", "", scope)
scope = re.sub(r"\s+", " ", scope).strip()
categories = []
for category in items.split("\n\n"):
if ": " in category:
Expand Down
77 changes: 77 additions & 0 deletions cla_backend/apps/reports/tests/test_reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,52 @@ def test_report_client_public_diagnosis_note(self):
}
self.assertDictContainsSubset(expected, dict(report[0]))

def test_report_client_new_frontend(self):
eligible_case = make_recipe("legalaid.eligible_case", source="WEB")
eligible_case.eligibility_check.notes = self.get_notes_new_frontend()
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": "Work - including colleagues, employer or employment agency",
"Web diagnosis category 3": "Disability, health condition, mental health condition",
"Web diagnosis category 4": "",
"Web diagnosis category 5": "",
"Web diagnosis category 6": "",
"Web scope state": "In Scope",
"Client notes": "Optional data\n\n",
"Workflow status": "Operator",
}
self.assertDictContainsSubset(expected, dict(report[0]))

def test_report_client_new_frontend_public_diagnsosis_note(self):
eligible_case = make_recipe("legalaid.eligible_case", source="WEB")
eligible_case.eligibility_check.notes = self.get_notes_new_frontend_public_diagnsosis_note()
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": "Domestic abuse",
"Web diagnosis category 2": "Help to protect you and your children",
"Web diagnosis category 3": "Yes",
"Web diagnosis category 4": "",
"Web diagnosis category 5": "",
"Web diagnosis category 6": "",
"Web scope state": "In Scope - Skip means test",
"Client notes": "Data\n\n",
"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 @@ -737,3 +783,34 @@ def get_notes_public_diagnosis_note(self):

Outcome: CONTACT
"""

def get_notes_new_frontend(self):
return """User problem:
Optional data

User selected:
What do you need help with?: Discrimination

Where did the discrimination happen?: Work - including colleagues, employer or employment agency

Why were you treated differently?: Disability, health condition, mental health condition

Outcome: In Scope
"""

def get_notes_new_frontend_public_diagnsosis_note(self):
return """User problem:
Data

Public Diagnosis note:
User is at immediate risk of harm

User selected:
What do you need help with?: Domestic abuse

Domestic Abuse: Help to protect you and your children

Are you or your children at immediate risk of harm?: Yes

Outcome: In Scope - Skip means test
"""
Loading