Skip to content

Commit

Permalink
Merge pull request #768 from praekeltfoundation/demand_gen
Browse files Browse the repository at this point in the history
Added demand gen keyword
  • Loading branch information
Mudiwa66 authored Jan 13, 2025
2 parents f545158 + 33f5fc1 commit 6ca6bf4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions yal/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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:
Expand Down
14 changes: 14 additions & 0 deletions yal/tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -939,6 +939,20 @@ 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_welcome")

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
Expand Down

0 comments on commit 6ca6bf4

Please sign in to comment.