Skip to content

Commit

Permalink
Merge pull request #677 from praekeltfoundation/fix_lets_do_this
Browse files Browse the repository at this point in the history
fix lets do it next state
  • Loading branch information
Hlamallama authored Aug 28, 2023
2 parents f7b5e4f + af1ef18 commit b0c7107
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 12 deletions.
5 changes: 1 addition & 4 deletions yal/assessments.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,10 +401,7 @@ async def state_handle_assessment_reminder_response(self):
f"state_{assessment_name.replace('_v2', '')}_assessment_v2"
)
if "endline" in assessment_name:
assessment_name_replace = assessment_name.replace("_endline", "")
return await self.go_to_state(
f"state_{assessment_name_replace}_assessment_endline"
)
return await self.go_to_state("state_start_terms")

return await self.go_to_state(f"state_{assessment_name}_assessment")

Expand Down
5 changes: 1 addition & 4 deletions yal/endline_terms_and_conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,12 +302,9 @@ async def state_set_reminder_timer(self):
msisdn = normalise_phonenumber(self.inbound.from_addr)
whatsapp_id = msisdn.lstrip(" + ")

assessment_name = self.user.metadata.get(
"assessment_name", "locus_of_control_endline"
)
data = {
"assessment_reminder": get_current_datetime().isoformat(),
"assessment_reminder_name": assessment_name,
"assessment_reminder_name": "locus_of_control_endline",
"assessment_reminder_type": "endline reengagement 30min",
}

Expand Down
4 changes: 2 additions & 2 deletions yal/surveys/endline.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,10 +413,10 @@ async def state_alcohol_assessment_endline_end(self):
if error:
return await self.go_to_state("state_error")

return await self.go_to_state("state_platform_review_endline")
return await self.go_to_state("state_platform_review_assessment_endline")

# Platform Review
async def state_platform_review_endline(self):
async def state_platform_review_assessment_endline(self):
self.save_metadata("assessment_name", "platform_review_endline")
self.save_metadata("assessment_end_state", "state_submit_endline_completed")

Expand Down
2 changes: 1 addition & 1 deletion yal/tests/states_dictionary.md
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@
| state_accept_consent | False | Text | Consent to the endline study |
| state_no_consent | False | Text | No consent to the endline study |
| state_consent | False | Text | Ask for consent to the study |
| state_platform_review_endline | False | Text | Review the platform |
| state_platform_review_assessment_endline | False | Text | Review the platform |
| state_relationship_status_endline | False | Text | endline relationship status |
| state_submit_terms_and_conditions_endline | False | Text | Endline Terms and Condition Submit |
| state_not_interested | False | Text | Endline Survery not interested |
Expand Down
23 changes: 23 additions & 0 deletions yal/tests/surveys/test_endline.py
Original file line number Diff line number Diff line change
Expand Up @@ -1294,3 +1294,26 @@ async def test_endline_agree_terms_and_condition(tester: AppTester, rapidpro_moc

await tester.user_input("Yes, I agree")
tester.assert_state("state_accept_consent")


@pytest.mark.asyncio
async def test_state_accept_consent_reminder_lets_do_this(
tester: AppTester, rapidpro_mock
):

tester.user.metadata["baseline_survey_completed"] = True
tester.user.metadata["endline_survey_started"] = "True"
tester.user.metadata["terms_accepted"] = True
tester.user.metadata["onboarding_completed"] = True

tester.setup_state("state_accept_consent")
await tester.user_input("I can't right now")

tester.assert_state("state_set_reminder_timer")
tester.assert_metadata("assessment_reminder_name", "locus_of_control_endline")
tester.assert_metadata("assessment_reminder_type", "endline reengagement 30min")

tester.user.metadata["assessment_reminder_sent"] = True
await tester.user_input("Let's do it")

tester.assert_state("state_start_terms")
2 changes: 1 addition & 1 deletion yal/tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ async def test_assessment_reminder_keywords(
] = "locus_of_control_endline"

await tester.user_input("continue now")
tester.assert_state("state_survey_question")
tester.assert_state("state_start_terms")


@pytest.mark.asyncio
Expand Down

0 comments on commit b0c7107

Please sign in to comment.