def test_match_campaign(self): obj = ReferrerFactory() obj.match_campaign() CampaignFactory() self.assertIsNone(obj.campaign) campaign = CampaignFactory(pattern="Test Referrer") obj.match_campaign() self.assertEqual(obj.campaign, campaign)
def test_count_users(self): obj = CampaignFactory() self.assertEqual(obj.count_users(), 0) ReferrerFactory(campaign=obj) self.assertEqual(obj.count_users(), 0) ref = ReferrerFactory(campaign=obj) UserReferrerFactory(referrer=ref) self.assertEqual(obj.count_users(), 1)
def test_manager_apply_referrer(self): referrer = ReferrerFactory() user = UserFactory() request = HttpRequest() request.session = {settings.SESSION_KEY: referrer.pk} UserReferrer.objects.apply_referrer(user, request) self.assertEqual(user.user_referrer.referrer, referrer)
def test_model(self): obj = ReferrerFactory() self.assertTrue(obj.pk)