From 0ddae7350a5d6ec164192b962b0e520711a494f8 Mon Sep 17 00:00:00 2001 From: Mudiwa Matanda Date: Mon, 13 Jan 2025 10:24:32 +0200 Subject: [PATCH 1/2] Added demand gen keyword --- yal/main.py | 4 ++++ yal/tests/test_main.py | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/yal/main.py b/yal/main.py index b8a31079..c1d2c4ab 100644 --- a/yal/main.py +++ b/yal/main.py @@ -64,6 +64,7 @@ "i saw this on facebook", } TRACKING_KEYWORDS_ROUND_3 = {"youth", "yth", "yuth", "yut", "yoth", "yot", "yoh"} +TRACKING_KEYWORDS_ROUND_4 = {"RegisterMe"} TRACKING_KEYWORDS_TIKTOK = {"sho"} OPTOUT_KEYWORDS = {"stop", "opt out", "cancel", "quit"} ONBOARDING_REMINDER_KEYWORDS = { @@ -151,6 +152,7 @@ async def process_message(self, message): or keyword in TRACKING_KEYWORDS or keyword in TRACKING_KEYWORDS_ROUND_2 or keyword in TRACKING_KEYWORDS_ROUND_3 + or keyword in TRACKING_KEYWORDS_ROUND_4 or keyword in TRACKING_KEYWORDS_TIKTOK ): self.user.session_id = None @@ -310,6 +312,7 @@ async def state_start(self): inbound in TRACKING_KEYWORDS or inbound in TRACKING_KEYWORDS_ROUND_2 or inbound in TRACKING_KEYWORDS_ROUND_3 + or inbound in TRACKING_KEYWORDS_ROUND_4 or inbound in TRACKING_KEYWORDS_TIKTOK ): self.save_answer("state_source_tracking", inbound) @@ -321,6 +324,7 @@ async def state_start(self): or inbound in TRACKING_KEYWORDS or inbound in TRACKING_KEYWORDS_ROUND_2 or inbound in TRACKING_KEYWORDS_ROUND_3 + or inbound in TRACKING_KEYWORDS_ROUND_4 or inbound in TRACKING_KEYWORDS_TIKTOK ): if terms_accepted and onboarding_completed: diff --git a/yal/tests/test_main.py b/yal/tests/test_main.py index 33d43002..22206108 100644 --- a/yal/tests/test_main.py +++ b/yal/tests/test_main.py @@ -939,6 +939,19 @@ async def test_tracked_keywords_saved_for_new_user_ads_round_3( tester.assert_answer("state_source_tracking", "yoth") +@pytest.mark.asyncio +async def test_tracked_keywords_demand_gen( + tester: AppTester, rapidpro_mock, contentrepo_api_mock +): + rapidpro_mock.tstate.contact_fields["onboarding_completed"] = "" + rapidpro_mock.tstate.contact_fields["terms_accepted"] = "" + await tester.user_input("RegisterMe") + tester.assert_state("state_start") + tester.assert_num_messages(1) + + tester.assert_answer("state_source_tracking", "RegisterMe") + + @pytest.mark.asyncio async def test_tracked_keywords_tiktok( tester: AppTester, rapidpro_mock, contentrepo_api_mock From 33f5fc1186a69579819e077079096686e3ef0a94 Mon Sep 17 00:00:00 2001 From: Mudiwa Matanda Date: Mon, 13 Jan 2025 11:16:05 +0200 Subject: [PATCH 2/2] fixed keyword and linting --- yal/main.py | 2 +- yal/tests/test_main.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/yal/main.py b/yal/main.py index c1d2c4ab..9bf95d02 100644 --- a/yal/main.py +++ b/yal/main.py @@ -64,7 +64,7 @@ "i saw this on facebook", } TRACKING_KEYWORDS_ROUND_3 = {"youth", "yth", "yuth", "yut", "yoth", "yot", "yoh"} -TRACKING_KEYWORDS_ROUND_4 = {"RegisterMe"} +TRACKING_KEYWORDS_ROUND_4 = {"registerme"} TRACKING_KEYWORDS_TIKTOK = {"sho"} OPTOUT_KEYWORDS = {"stop", "opt out", "cancel", "quit"} ONBOARDING_REMINDER_KEYWORDS = { diff --git a/yal/tests/test_main.py b/yal/tests/test_main.py index 22206108..f572f5ff 100644 --- a/yal/tests/test_main.py +++ b/yal/tests/test_main.py @@ -945,11 +945,12 @@ async def test_tracked_keywords_demand_gen( ): rapidpro_mock.tstate.contact_fields["onboarding_completed"] = "" rapidpro_mock.tstate.contact_fields["terms_accepted"] = "" - await tester.user_input("RegisterMe") - tester.assert_state("state_start") + await tester.user_input("registerme") + tester.assert_state("state_welcome") + tester.assert_num_messages(1) - tester.assert_answer("state_source_tracking", "RegisterMe") + tester.assert_answer("state_source_tracking", "registerme") @pytest.mark.asyncio