Untitled

mail@pastecode.io avatar
unknown
python
2 years ago
1.4 kB
2
Indexable
Never
    def test_get_active_referral_campaigns__no_country_filter(self):
        retailer = RetailerFactory()
        voucher_template_1 = AdHocVoucherTemplateFactory(retailer_id=retailer.id)
        referee_validation_reward_1 = YoyoReward.objects.create(
            quantity=2, scheme=voucher_template_1
        )
        campaign_1 = ReferralCampaignFactory(
            retailer=retailer,
            referee_validation_reward_id=referee_validation_reward_1.id,
        )

        retailer_app_name = 'my_app'
        RetailerApiClientNameFactory(name=retailer_app_name, retailer_id=retailer.id)
        context.api_client_name = retailer_app_name

        voucher_template_2 = AdHocVoucherTemplateFactory(retailer_id=retailer.id)
        referee_completion_reward_2 = YoyoReward.objects.create(
            quantity=2, scheme=voucher_template_2
        )
        campaign_2 = ReferralCampaignFactory(
            retailer=retailer,
            referee_completion_reward_id=referee_completion_reward_2.id,
            countries='PL',
        )
        referral_campaigns = self.service.get_active_referral_campaigns(all_campaigns=True)

        referral_campaign_1 = referral_campaigns[0]
        referral_campaign_2 = referral_campaigns[1]

        self.testcase.assertEqual(len(referral_campaigns), 2)
        self.testcase.assertEqual(referral_campaign_1, campaign_1)
        self.testcase.assertEqual(referral_campaign_2, campaign_2)