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

add new locus questions #659

Merged
merged 2 commits into from
Aug 8, 2023
Merged
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
95 changes: 95 additions & 0 deletions yal/endline_terms_and_conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,106 @@ 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 WhatsAppListState(
self,
question=question,
error=error,
choices=choices,
next=next,
button="Choose Option",
)

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 WhatsAppListState(
self,
question=question,
error=error,
choices=choices,
next="state_submit_terms_and_conditions_endline",
button="Choose Option",
)

async def state_set_reminder_timer(self):
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
48 changes: 45 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,19 @@ 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).",
]
)
tester.assert_message(message)

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


Expand Down Expand Up @@ -111,11 +121,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")
Loading