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

Location survey #675

Merged
merged 2 commits into from
Aug 22, 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
36 changes: 27 additions & 9 deletions yal/surveys/location.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,22 @@ async def state_location_introduction(self):
)

async def state_location_not_invited(self):
return EndState(
question = self._(
"Unfortunately it looks like we already have enough people answering this "
"survey, but thank you for your interest."
)
return WhatsAppButtonState(
self,
self._(
"Unfortunately it looks like we already have enough people answering "
"this survey, but thank you for your interest."
),
next=self.START_STATE,
question=question,
choices=[
Choice("menu", self._("Go to the menu")),
Choice("aaq", self._("Ask a question")),
],
next={
"menu": "state_pre_mainmenu",
"aaq": AAQApplication.START_STATE,
},
error=self._(get_generic_error()),
)

async def state_location_invalid_province(self):
Expand All @@ -124,10 +133,19 @@ async def state_location_invalid_province(self):
)

async def state_location_already_completed(self):
return EndState(
question = self._("This number has already completed the location survey.")
return WhatsAppButtonState(
self,
self._("This number has already completed the location survey."),
next=self.START_STATE,
question=question,
choices=[
Choice("menu", self._("Go to the menu")),
Choice("aaq", self._("Ask a question")),
],
next={
"menu": "state_pre_mainmenu",
"aaq": AAQApplication.START_STATE,
},
error=self._(get_generic_error()),
)

async def state_location_decline(self):
Expand Down
4 changes: 2 additions & 2 deletions yal/tests/states_dictionary.md
Original file line number Diff line number Diff line change
Expand Up @@ -760,8 +760,8 @@
| state_name | accepts_user_input | data_type | description |
| ---------- | ------------------ | --------- | ----------- |
| state_location_introduction | TRUE | Text | Surveu introduction
| state_location_not_invited | FALSE | Text | Tells user they weren't invited to the study
| state_location_already_completed | FALSE | Text | Tells user they already completed the study
| state_location_not_invited | TRUE | Text | Tells user they weren't invited to the study
| state_location_already_completed | TRUE | Text | Tells user they already completed the study
| state_location_province | TRUE | Text | Ask user which province they live in
| state_location_not_recruiting | FALSE | Text | Tells user we're not recruiting in the province they live in
| state_location_name_city | TRUE | Text | Ask user the name of the city they live in
Expand Down
6 changes: 3 additions & 3 deletions yal/tests/surveys/test_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ async def test_state_location_introduction_already_completed(tester: AppTester):

await tester.user_input(session=Message.SESSION_EVENT.NEW)

tester.assert_state("state_start")
tester.assert_state("state_location_already_completed")

tester.assert_message("This number has already completed the location survey.")

Expand Down Expand Up @@ -129,7 +129,7 @@ async def test_state_location_introduction_not_invited(tester: AppTester):
tester.setup_state("state_location_introduction")
await tester.user_input(session=Message.SESSION_EVENT.NEW)

tester.assert_state("state_start")
tester.assert_state("state_location_not_invited")

tester.assert_message(
"Unfortunately it looks like we already have enough people answering this "
Expand All @@ -143,7 +143,7 @@ async def test_state_location_introduction_group_max(tester: AppTester):
tester.setup_state("state_location_introduction")
await tester.user_input(session=Message.SESSION_EVENT.NEW)

tester.assert_state("state_start")
tester.assert_state("state_location_not_invited")

tester.assert_message(
"Unfortunately it looks like we already have enough people answering this "
Expand Down
Loading