Skip to content

Commit

Permalink
add new locus questions
Browse files Browse the repository at this point in the history
  • Loading branch information
Hlamallama committed Aug 8, 2023
1 parent f4b9f89 commit 0f7615f
Show file tree
Hide file tree
Showing 3 changed files with 150 additions and 3 deletions.
93 changes: 93 additions & 0 deletions yal/endline_terms_and_conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,99 @@ async def state_monthly_household_income_endline(self):
]
)
)
return ChoiceState(
self,
question=question,
error=error,
choices=choices,
next="state_household_number_of_people",
)

async def state_household_number_of_people(self):
choices = [
Choice("one", self._("Just me")),
Choice("two", self._("Two people")),
Choice("three", self._("Three people")),
Choice("four", self._("Four people")),
Choice("five", self._("Five people")),
Choice("six", self._("Six people")),
Choice("seven", self._("Seven people")),
Choice("eight_more", self._("Eight or more")),
Choice("rather", "Rather not say"),
Choice("skip_question", self._("Skip question")),
]

question = self._(
"\n".join(
[
"*How many people (including yourself) live in the household now?"
" Don’t forget to include babies.*",
"",
"(If you’re unsure - this counts as anyone sleeping the house"
"4 nights in the past week).",
]
)
)
error = self._(
"\n".join(
[
"*Oops. We did not understand your answer*",
"Please respond with the *number* of an option below",
"",
"How many people (including yourself) live in the household now?",
]
)
)

next = "state_submit_terms_and_conditions_endline"

if choices[0].value == "eight_more":
next = "state_household_number_of_people_more"

return ChoiceState(
self,
question=question,
error=error,
choices=choices,
next=next,
)

async def state_household_number_of_people_eight_or_more(self):
choices = [
Choice("eight", self._("Including me")),
Choice("nine", self._("Nine people")),
Choice("ten", self._("Ten people")),
Choice("eleven", self._("Eleven people")),
Choice("twelve", self._("Twelve people")),
Choice("thirteen", self._("Thirteen people")),
Choice("fourteen", self._("Fourteen people")),
Choice("fifteen", self._("Fifteen people")),
Choice("rather", "Rather not say"),
Choice("skip_question", self._("Skip question")),
]

question = self._(
"\n".join(
[
"*Okay - you said there are 8 or more people in your household.*",
"*How many people (including yourself) live in the household now?"
" Don’t forget to include babies.*",
"(If you’re unsure - this counts as anyone sleeping the house"
"4 nights in the past week).",
]
)
)
error = self._(
"\n".join(
[
"*Oops. We did not understand your answer*",
"Please respond with the *number* of an option below",
"",
"How many people (including yourself) live in the household now?",
]
)
)

return ChoiceState(
self,
question=question,
Expand Down
2 changes: 2 additions & 0 deletions yal/tests/states_dictionary.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,8 @@
| state_remind_tomorrow | TRUE | Text | TRUE | Lets the user know we will remind them tomorrow, asks the user if they would like to go to the mainmenu |
| state_reminder_not_interested | True | Text | TRUE | Lets the user know that they will no longer be prt of the study |
| state_survey_validation | True | Text | TRUE | endline survey catch all validation |
state_household_number_of_people | False | Text | Endline number of peopleing living in househould |
| state_household_number_of_people_eight_or_more | False | Text | Endline number of peopleing living in househould if more than 8 people |


### Service finder flow
Expand Down
58 changes: 55 additions & 3 deletions yal/tests/test_endline_terms_and_condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,29 @@ async def test_state_monthly_household_income_endline(tester: AppTester, rapidpr
tester.setup_state("state_monthly_household_income_endline")
await tester.user_input("1")

tester.assert_state("state_survey_question")
tester.assert_state("state_household_number_of_people")

message = "\n".join(
[
"*How many people (including yourself) live in the household now?"
" Don’t forget to include babies.*",
"",
"(If you’re unsure - this counts as anyone sleeping the house"
"4 nights in the past week).",
"1. Just me",
"2. Two people",
"3. Three people",
"4. Four people",
"5. Five people",
"6. Six people",
"7. Seven people",
"8. Eight or more",
"9. Rather not say",
"10. Skip question",
]
)
tester.assert_message(message)

message = "\n".join(["◼️◽️◽️◽️", "-----", "", "*I'm my own boss.* 😎"])
tester.assert_message(message)


Expand Down Expand Up @@ -111,11 +131,43 @@ async def test_state_accept_consent_reminder(tester: AppTester, rapidpro_mock):
async def test_state_submit_terms_and_conditions_accept(
tester: AppTester, rapidpro_mock
):
tester.setup_state("state_monthly_household_income_endline")
tester.setup_state("state_household_number_of_people")
await tester.user_input("1")

assert len(rapidpro_mock.tstate.requests) == 3
request = rapidpro_mock.tstate.requests[0]
assert json.loads(request.body.decode("utf-8")) == {
"fields": {"endline_terms_accepted": "True"},
}


@pytest.mark.asyncio
async def test_state_household_number_of_people(tester: AppTester, rapidpro_mock):
tester.setup_state("state_household_number_of_people")
await tester.user_input("2")
message = "\n".join(["◼️◽️◽️◽️", "-----", "", "*I'm my own boss.* 😎"])

tester.assert_message(message)
tester.assert_state("state_survey_question")


@pytest.mark.asyncio
async def test_state_household_number_of_people_more(tester: AppTester, rapidpro_mock):
tester.setup_state("state_household_number_of_people")
await tester.user_input("7")
message = "\n".join(["◼️◽️◽️◽️", "-----", "", "*I'm my own boss.* 😎"])

tester.assert_message(message)
tester.assert_state("state_survey_question")


@pytest.mark.asyncio
async def test_state_household_number_of_people_eight_or_more(
tester: AppTester, rapidpro_mock
):
tester.setup_state("state_household_number_of_people_eight_or_more")
await tester.user_input("1")
message = "\n".join(["◼️◽️◽️◽️", "-----", "", "*I'm my own boss.* 😎"])

tester.assert_message(message)
tester.assert_state("state_survey_question")

0 comments on commit 0f7615f

Please sign in to comment.