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

Enline start validation #652

Merged
merged 3 commits into from
Aug 1, 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
45 changes: 21 additions & 24 deletions yal/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,33 +204,30 @@ async def process_message(self, message):
endline_survey_started = self.user.metadata.get("endline_survey_started")
endline_reminder = self.user.metadata.get("endline_reminder")

if (
keyword in EJAF_ENDLINE_SURVEY_KEYWORDS
and baseline_survey_completed
and not endline_survey_completed
):
self.save_metadata("assessment_reminder_sent", False)
self.save_metadata("assessment_reminder_name", "")
if endline_survey_started:
self.user.session_id = None

if keyword == "remind me tomorrow":
self.user.session_id = None
self.state_name = AssessmentApplication.REMINDER_STATE
elif keyword == "i m not interested":
if endline_reminder:
self.user.session_id = None
self.state_name = (
AssessmentApplication.REMINDER_NOT_INTERESTED_STATE
)
if (
keyword in EJAF_ENDLINE_SURVEY_KEYWORDS
and baseline_survey_completed
and not endline_survey_completed
):
self.save_metadata("assessment_reminder_sent", False)
self.save_metadata("assessment_reminder_name", "")

if keyword == "remind me tomorrow":
self.state_name = AssessmentApplication.REMINDER_STATE
elif keyword == "i m not interested":
if endline_reminder:
self.state_name = (
AssessmentApplication.REMINDER_NOT_INTERESTED_STATE
)
else:
self.state_name = EndlineTermsApplication.NO_CONSENT_STATE
else:
self.user.session_id = None
self.state_name = EndlineTermsApplication.NO_CONSENT_STATE
self.state_name = EndlineTermsApplication.START_STATE
else:
self.user.session_id = None
self.state_name = EndlineTermsApplication.START_STATE

if endline_survey_started == "True" and not self.state_name:
self.user.session_id = None
self.state_name = EndlineSurveyApplication.SURVEY_VALIDATION_STATE
self.state_name = EndlineSurveyApplication.SURVEY_VALIDATION_STATE

# Fields that RapidPro sets after a feedback push message
feedback_state = await self.get_feedback_state()
Expand Down
14 changes: 9 additions & 5 deletions yal/tests/surveys/test_endline.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ async def test_endline_invitation_i_want_to_answer(tester: AppTester, rapidpro_m
addr="278201234567",
state=StateData(),
session_id=1,
metadata={"baseline_survey_completed": True},
metadata={"baseline_survey_completed": True, "endline_survey_started": True},
)
app = Application(user)
msg = Message(
Expand Down Expand Up @@ -127,7 +127,7 @@ async def test_endline_invitation_not_interested(
addr="278201234567",
state=StateData(),
session_id=1,
metadata={"baseline_survey_completed": True},
metadata={"baseline_survey_completed": True, "endline_survey_started": True},
)
app = Application(user)
msg = Message(
Expand All @@ -152,7 +152,11 @@ async def test_endline_reminder_not_interested(
addr="278201234567",
state=StateData(),
session_id=1,
metadata={"baseline_survey_completed": True, "endline_reminder": True},
metadata={
"baseline_survey_completed": True,
"endline_reminder": True,
"endline_survey_started": True,
},
)
app = Application(user)
msg = Message(
Expand All @@ -175,7 +179,7 @@ async def test_endline_invitation_answer(tester: AppTester, rapidpro_mock):
addr="278201234567",
state=StateData(),
session_id=1,
metadata={"baseline_survey_completed": True},
metadata={"baseline_survey_completed": True, "endline_survey_started": True},
)
app = Application(user)
msg = Message(
Expand All @@ -198,7 +202,7 @@ async def test_endline_survey_validation(tester: AppTester, rapidpro_mock):
addr="278201234567",
state=StateData(),
session_id=1,
metadata={"baseline_survey_completed": True, "endline_survey_started": "True"},
metadata={"baseline_survey_completed": True, "endline_survey_started": True},
)
app = Application(user)
msg = Message(
Expand Down
2 changes: 1 addition & 1 deletion yal/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"try again - I'll get it if you use the option that matches your "
"choice, promise.👍🏾",
"Umm...I'm sorry but I'm not sure what that means "
"[persona_emoji]👩🏾. You can help me by trying again. This time, "
"[persona_emoji]. You can help me by trying again. This time, "
"look for the option matching your choice and send that👍🏾",
)
GENDERS = {
Expand Down
Loading