def setUp(self): """ Setup the test data """ super(UpdateOfferAssignmentEmailBounceStatusTests, self).setUp() for x in range(3): assignment = OfferAssignmentFactory( code='test-code{}'.format(x), user_email='test{}@example.com'.format(x)) assignment.status = OFFER_ASSIGNED assignment.save()
def test_update_assigned_voucher_offer_assignment(self, __): """ Verify the "update_assigned_voucher_offer_assignment" works as expected. """ enterprise_offer = EnterpriseOfferFactory() voucher = VoucherFactory() voucher.offers.add(enterprise_offer) basket = create_basket(owner=self.user, site=self.site) basket.vouchers.add(voucher) order = create_order(user=self.user, basket=basket) voucher_application = VoucherApplication.objects.create(voucher=voucher, user=self.user, order=order) offer_assignment = OfferAssignmentFactory(offer=enterprise_offer, code=voucher.code, user_email=self.user.email) EdxOrderPlacementMixin().update_assigned_voucher_offer_assignment(order) offer_assignment = OfferAssignment.objects.get(id=offer_assignment.id) assert offer_assignment.status == OFFER_REDEEMED assert offer_assignment.voucher_application == voucher_application
def test_update_assigned_voucher_offer_assignment(self, __): """ Verify the "update_assigned_voucher_offer_assignment" works as expected. """ enterprise_offer = EnterpriseOfferFactory() voucher = VoucherFactory() voucher.offers.add(enterprise_offer) basket = create_basket(owner=self.user, site=self.site) basket.vouchers.add(voucher) order = create_order(user=self.user, basket=basket) voucher_application = VoucherApplication.objects.create( voucher=voucher, user=self.user, order=order) offer_assignment = OfferAssignmentFactory(offer=enterprise_offer, code=voucher.code, user_email=self.user.email) # create nudge email templates and subscription records for email_type in (DAY3, DAY10, DAY19): nudge_email_template = CodeAssignmentNudgeEmailTemplatesFactory( email_type=email_type) nudge_email = CodeAssignmentNudgeEmailsFactory( email_template=nudge_email_template, user_email=self.user.email, code=voucher.code) # verify subscription is active assert nudge_email.is_subscribed EdxOrderPlacementMixin().update_assigned_voucher_offer_assignment( order) offer_assignment = OfferAssignment.objects.get(id=offer_assignment.id) assert offer_assignment.status == OFFER_REDEEMED assert offer_assignment.voucher_application == voucher_application # verify that nudge emails subscriptions are inactive assert CodeAssignmentNudgeEmails.objects.filter( is_subscribed=True).count() == 0 assert CodeAssignmentNudgeEmails.objects.filter( code__in=[voucher.code], user_email__in=[self.user.email], is_subscribed=False).count() == 3
def setUp(self): """ Setup the test data """ super(SendCodeAssignmentNudgeEmailsTests, self).setUp() # Create a voucher with valid offer so we can get voucher = VoucherFactory() voucher.offers.add(EnterpriseOfferFactory(max_global_applications=98)) self.total_nudge_emails_for_today = 5 self.nudge_emails = CodeAssignmentNudgeEmailsFactory.create_batch( self.total_nudge_emails_for_today, code=voucher.code) CodeAssignmentNudgeEmailsFactory(email_date=datetime.datetime.now() + relativedelta(days=1)) CodeAssignmentNudgeEmailsFactory(email_date=datetime.datetime.now() + relativedelta(days=2)) for nudge_email in self.nudge_emails: OfferAssignmentFactory(code=nudge_email.code, user_email=nudge_email.user_email)