Beispiel #1
0
 def test_validate_raises_error_on_failure(self):
     client, _ = make_client_mocks("get_fields", "FAKE FIELD")
     mock_query(client, "get_groups", None)
     campaign = FollowupCampaign("Boop Group", "date_of_boop")
     with pytest.raises(ValueError,
                        match="Unable to find RapidPro group 'Boop Group'"):
         campaign.validate(client)
Beispiel #2
0
 def test_wont_add_contact_to_group_if_they_have_blocked_or_stopped_us(
         self):
     contact = Contact.create(groups=["FAKE ARG GROUP"],
                              fields={"fake_field": "blah"},
                              blocked=True)
     client, _ = make_client_mocks("get_contacts", contact)
     mock_query(client, "get_groups", "FAKE BOOP GROUP")
     campaign = FollowupCampaign("Boop Group", "date_of_boop")
     with freeze_time("2018-01-02"):
         campaign.add_contact(client, "Narf Jones", "5551234567", "en")
     client.update_contact.assert_not_called()
 def test_add_contact_works(self):
     contact = Contact.create(groups=["FAKE ARG GROUP"],
                              fields={'fake_field': 'blah'})
     client, _ = make_client_mocks('get_contacts', contact)
     mock_query(client, 'get_groups', "FAKE BOOP GROUP")
     campaign = FollowupCampaign('Boop Group', 'date_of_boop')
     with freeze_time('2018-01-02'):
         campaign.add_contact(client, "Narf Jones", "5551234567")
     client.update_contact.assert_called_once_with(
         contact,
         groups=["FAKE ARG GROUP", "FAKE BOOP GROUP"],
         fields={
             'fake_field': 'blah',
             'date_of_boop': '2018-01-02T00:00:00.000000Z'
         })
Beispiel #4
0
 def test_add_contact_works(self):
     contact = Contact.create(groups=["FAKE ARG GROUP"],
                              fields={"fake_field": "blah"})
     client, _ = make_client_mocks("get_contacts", contact)
     mock_query(client, "get_groups", "FAKE BOOP GROUP")
     campaign = FollowupCampaign("Boop Group", "date_of_boop")
     with freeze_time("2018-01-02"):
         campaign.add_contact(client, "Narf Jones", "5551234567", "en")
     client.update_contact.assert_called_once_with(
         contact,
         groups=["FAKE ARG GROUP", "FAKE BOOP GROUP"],
         fields={
             "fake_field": "blah",
             "date_of_boop": "2018-01-02T00:00:00.000000Z"
         },
     )
Beispiel #5
0
 def test_validate_works(self):
     client, _ = make_client_mocks("get_fields", "FAKE FIELD")
     mock_query(client, "get_groups", "FAKE GROUP")
     campaign = FollowupCampaign("Boop Group", "date_of_boop")
     campaign.validate(client)
Beispiel #6
0
 def test_get_campaign_returns_campaign_if_configured(self, settings):
     settings.RAPIDPRO_FOLLOWUP_CAMPAIGN_RH = "Blarg,date_of_blarg"
     assert DjangoSettingsFollowupCampaigns.get_campaign(
         "RH") == FollowupCampaign("Blarg", "date_of_blarg")
 def test_validate_works(self):
     client, _ = make_client_mocks('get_fields', "FAKE FIELD")
     mock_query(client, 'get_groups', "FAKE GROUP")
     campaign = FollowupCampaign('Boop Group', 'date_of_boop')
     campaign.validate(client)