From 528de6805c868b5e2b5ed57ff5c707379394cab2 Mon Sep 17 00:00:00 2001 From: Hlamalani Date: Thu, 9 Nov 2023 13:02:58 +0200 Subject: [PATCH] set survey started to not interested --- yal/main.py | 9 +++++++++ yal/tests/test_main.py | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/yal/main.py b/yal/main.py index 124db523..6a40adb6 100644 --- a/yal/main.py +++ b/yal/main.py @@ -238,6 +238,15 @@ async def process_message(self, message): ) else: self.state_name = EndlineTermsApplication.NO_CONSENT_STATE + + data = { + "endline_survey_started": "not_interested", + } + error = await rapidpro.update_profile( + whatsapp_id, data, self.user.metadata + ) + if error: + return await self.go_to_state("state_error") else: self.state_name = EndlineTermsApplication.START_STATE diff --git a/yal/tests/test_main.py b/yal/tests/test_main.py index 150cc46d..e8fa48be 100644 --- a/yal/tests/test_main.py +++ b/yal/tests/test_main.py @@ -899,6 +899,13 @@ async def test_endline_survey_not_interested_keywords( await tester.user_input("I'm not interested") tester.assert_state("state_no_consent") + tester.assert_metadata("endline_survey_started", "not_interested") + + request = rapidpro_mock.tstate.requests[1] + assert json.loads(request.body.decode("utf-8")) == { + "fields": {"endline_survey_started": "not_interested"} + } + @pytest.mark.asyncio async def test_tracked_keywords_saved(