Skip to content

Commit

Permalink
Merge pull request #708 from praekeltfoundation/endline_reminder
Browse files Browse the repository at this point in the history
endline reminders
  • Loading branch information
Hlamallama authored Nov 14, 2023
2 parents cb2ffd1 + 767896e commit 0866924
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
4 changes: 2 additions & 2 deletions yal/assessments.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ async def state_handle_assessment_reminder_response(self):
if error:
return await self.go_to_state("state_error")

if assessment_name.endswith("endline"):
if "endline" in assessment_name:
return await self.go_to_state("state_not_interested")

return await self.go_to_state("state_pre_mainmenu")
Expand All @@ -447,7 +447,7 @@ async def state_not_interested(self):
msisdn = utils.normalise_phonenumber(self.inbound.from_addr)
whatsapp_id = msisdn.lstrip(" + ")
data = {
"endline_survey_started": "",
"endline_survey_started": "not_interested",
}
error = await rapidpro.update_profile(whatsapp_id, data, self.user.metadata)
if error:
Expand Down
13 changes: 11 additions & 2 deletions yal/tests/test_assessments.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ async def test_state_handle_assessment_reminder_response_not_interested(
"assessment_reminder_type": "",
},
}

tester.assert_metadata("assessment_reminder_name", "")
tester.assert_metadata("assessment_reminder_sent", "")
tester.assert_metadata("assessment_reminder_type", "")
Expand All @@ -496,17 +497,25 @@ async def test_state_handle_assessment_reminder_response_not_interested_endline(
await tester.user_input("I'm not interested")
tester.assert_state("state_not_interested")

request = rapidpro_mock.tstate.requests[1]
assert json.loads(request.body.decode("utf-8")) == {
request_one = rapidpro_mock.tstate.requests[1]
assert json.loads(request_one.body.decode("utf-8")) == {
"fields": {
"assessment_reminder_name": "",
"assessment_reminder_sent": "",
"assessment_reminder_type": "",
},
}

request_two = rapidpro_mock.tstate.requests[2]
assert json.loads(request_two.body.decode("utf-8")) == {
"fields": {
"endline_survey_started": "not_interested",
},
}
tester.assert_metadata("assessment_reminder_name", "")
tester.assert_metadata("assessment_reminder_sent", "")
tester.assert_metadata("assessment_reminder_type", "")
tester.assert_metadata("endline_survey_started", "not_interested")
tester.assert_message(
"\n".join(
[
Expand Down

0 comments on commit 0866924

Please sign in to comment.