コード例 #1
0
ファイル: test_models.py プロジェクト: Chris7/django-referral
 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)
コード例 #2
0
 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)
コード例 #3
0
 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)
コード例 #4
0
 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)
コード例 #5
0
 def test_model(self):
     obj = ReferrerFactory()
     self.assertTrue(obj.pk)