Ejemplo n.º 1
0
    def test_largerdiscountapplies(self):
        '''
        Create both a $10 discount and a $20 discount, and ensure that the
        larger discount applies
        '''

        updateConstant('general__discountsEnabled', True)
        s = self.create_series(pricingTier=self.defaultPricing)
        test_combo, test_component = self.create_discount(
            discountType=DiscountCombo.DiscountType.dollarDiscount,
            dollarDiscount=10
        )
        bigger_combo, bigger_component = self.create_discount(
            discountType=DiscountCombo.DiscountType.dollarDiscount,
            dollarDiscount=20,
            name='Bigger Discount'
        )

        response = self.register_to_check_discount(s)
        self.assertEqual(response.redirect_chain,[(reverse('showRegSummary'), 302)])
        self.assertEqual(response.context_data.get('totalPrice'), s.getBasePrice())
        self.assertEqual(response.context_data.get('netPrice'),response.context_data.get('totalPrice') - 20)
        self.assertEqual(response.context_data.get('is_free'),False)
        self.assertEqual(response.context_data.get('total_discount_amount'),20)
        self.assertFalse(response.context_data.get('addonItems'))

        discount_codes = response.context_data.get('discount_codes')
        self.assertEqual([x[0] for x in discount_codes], [bigger_combo.name,])
Ejemplo n.º 2
0
    def test_allwithinpointgroup(self):
        '''
        Set a discount to apply to an entire point group and check that the price
        is still the flat price
        '''

        updateConstant('general__discountsEnabled', True)
        test_combo, test_component = self.create_discount(
            quantity=1, allWithinPointGroup=True)
        s = self.create_series(pricingTier=self.defaultPricing)

        response = self.register_to_check_discount(s)
        self.assertEqual(response.redirect_chain,
                         [(reverse('showRegSummary'), 302)])
        self.assertEqual(response.context_data.get('totalPrice'),
                         s.getBasePrice())
        self.assertEqual(response.context_data.get('netPrice'),
                         response.context_data.get('totalPrice') - 5)
        self.assertEqual(response.context_data.get('is_free'), False)
        self.assertEqual(response.context_data.get('total_discount_amount'), 5)
        self.assertFalse(response.context_data.get('addonItems'))

        discount_codes = response.context_data.get('discount_codes')
        self.assertEqual([x[0] for x in discount_codes], [
            test_combo.name,
        ])
Ejemplo n.º 3
0
    def test_largerdiscountapplies(self):
        '''
        Create both a $10 discount and a $20 discount, and ensure that the
        larger discount applies
        '''

        updateConstant('general__discountsEnabled', True)
        s = self.create_series(pricingTier=self.defaultPricing)
        test_combo, test_component = self.create_discount(
            discountType=DiscountCombo.DiscountType.dollarDiscount,
            dollarDiscount=10
        )
        bigger_combo, bigger_component = self.create_discount(
            discountType=DiscountCombo.DiscountType.dollarDiscount,
            dollarDiscount=20,
            name='Bigger Discount'
        )

        response = self.register_to_check_discount(s)
        self.assertEqual(response.redirect_chain,[(reverse('showRegSummary'), 302)])
        self.assertEqual(response.context_data.get('totalPrice'), s.getBasePrice())
        self.assertEqual(response.context_data.get('netPrice'),response.context_data.get('totalPrice') - 20)
        self.assertEqual(response.context_data.get('is_free'),False)
        self.assertEqual(response.context_data.get('total_discount_amount'),20)
        self.assertFalse(response.context_data.get('addonItems'))

        discount_codes = response.context_data.get('discount_codes')
        self.assertEqual([x[0] for x in discount_codes], [bigger_combo.name,])
Ejemplo n.º 4
0
    def test_percentDiscount(self):
        '''
        Create a 50% off discount and check that it applies correctly.
        '''

        updateConstant('general__discountsEnabled', True)
        test_combo, test_component = self.create_discount(
            discountType=DiscountCombo.DiscountType.percentDiscount,
            percentDiscount=50,
            percentUniversallyApplied=False)
        s = self.create_series(pricingTier=self.defaultPricing)

        response = self.register_to_check_discount(s)
        self.assertEqual(response.redirect_chain,
                         [(reverse('showRegSummary'), 302)])
        self.assertEqual(response.context_data.get('totalPrice'),
                         s.getBasePrice())
        self.assertEqual(response.context_data.get('netPrice'),
                         0.5 * response.context_data.get('totalPrice'))
        self.assertEqual(response.context_data.get('is_free'), False)
        self.assertEqual(response.context_data.get('total_discount_amount'),
                         0.5 * response.context_data.get('totalPrice'))
        self.assertFalse(response.context_data.get('addonItems'))

        discount_codes = response.context_data.get('discount_codes')
        self.assertEqual([x[0] for x in discount_codes], [
            test_combo.name,
        ])
Ejemplo n.º 5
0
    def test_maxamountperuse(self):
        '''
        Ensure that a voucher with a max amount per use succeeds, but
        only subtracts the max amount per use.
        '''

        updateConstant('vouchers__enableVouchers', True)
        s = self.create_series(pricingTier=self.defaultPricing)
        v = self.create_voucher(
            expirationDate=timezone.now() + timedelta(days=1),
            maxAmountPerUse=2,
        )

        response = self.register_to_check_voucher(v.voucherId,s)
        self.assertEqual(response.status_code,200)
        self.assertEqual(response.redirect_chain,[(reverse('showRegSummary'), 302)])
        self.assertEqual(response.context_data.get('totalPrice'), s.getBasePrice())
        self.assertEqual(response.context_data.get('netPrice'),response.context_data.get('totalPrice') - v.maxAmountPerUse)
        self.assertEqual(response.context_data.get('is_free'),False)
        self.assertEqual(response.context_data.get('total_voucher_amount'),v.maxAmountPerUse)
        self.assertIn(v.name, response.context_data.get('voucher_names'))

        tvu = v.temporaryvoucheruse_set.filter(registration=response.context_data.get('registration'))
        self.assertTrue(tvu.exists() and tvu.count() == 1)
        self.assertEqual(tvu.first().amount, v.maxAmountPerUse)
Ejemplo n.º 6
0
    def test_fullamountused(self):
        '''
        Remove the max amount per use restriction and ensure that the
        voucher is applied for the full $10
        '''
        updateConstant('vouchers__enableVouchers', True)
        s = self.create_series(pricingTier=self.defaultPricing)
        v = self.create_voucher()

        response = self.register_to_check_voucher(v.voucherId, s)
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.redirect_chain,
                         [(reverse('showRegSummary'), 302)])
        self.assertEqual(response.context_data.get('totalPrice'),
                         s.getBasePrice())
        self.assertEqual(
            response.context_data.get('netPrice'),
            response.context_data.get('totalPrice') - v.originalAmount)
        self.assertEqual(response.context_data.get('is_free'), False)
        self.assertEqual(response.context_data.get('total_voucher_amount'),
                         v.originalAmount)
        self.assertIn(v.name, response.context_data.get('voucher_names'))

        tvu = v.temporaryvoucheruse_set.filter(
            registration=response.context_data.get('registration'))
        self.assertTrue(tvu.exists() and tvu.count() == 1)
        self.assertEqual(tvu.first().amount, v.originalAmount)
Ejemplo n.º 7
0
    def test_vouchermakesitfree(self):
        '''
        Make a voucher larger than the price of the registration
        and ensure that this makes the registration free (and that
        it gets processed as such)
        '''
        updateConstant('vouchers__enableVouchers', True)
        s = self.create_series(pricingTier=self.defaultPricing)
        v = self.create_voucher(
            originalAmount=self.defaultPricing.getBasePrice() + 10,
            maxAmountPerUse=None,
        )

        response = self.register_to_check_voucher(v.voucherId,s)
        self.assertEqual(response.status_code,200)
        self.assertEqual(response.redirect_chain,[(reverse('showRegSummary'), 302)])
        self.assertEqual(response.context_data.get('totalPrice'), s.getBasePrice())
        self.assertEqual(response.context_data.get('netPrice'), 0)
        self.assertEqual(response.context_data.get('is_free'), True)
        self.assertEqual(response.context_data.get('total_voucher_amount'),s.getBasePrice())
        self.assertIn(v.name, response.context_data.get('voucher_names'))

        tr = response.context_data.get('registration')
        tvu = v.temporaryvoucheruse_set.filter(registration=tr)
        self.assertTrue(tvu.exists() and tvu.count() == 1)
        self.assertEqual(tvu.first().amount, s.getBasePrice())

        reg = tr.registration
        self.assertTrue(reg)
        self.assertEqual(reg.netPrice, 0)
        self.assertEqual(reg.totalPrice, s.getBasePrice())

        vu = v.voucheruse_set.filter(registration=reg)
        self.assertTrue(vu.exists() and vu.count() == 1)
        self.assertEqual(vu.first().amount, s.getBasePrice())
Ejemplo n.º 8
0
    def test_earlybird(self):
        '''
        Create an early registration discount that requires three day
        advance registration and ensure that it works more than
        three days in advance.
        '''

        updateConstant('general__discountsEnabled', True)
        test_combo, test_component = self.create_discount(
            daysInAdvanceRequired=3)
        s = self.create_series(pricingTier=self.defaultPricing,
                               startTime=timezone.now() + timedelta(days=4))

        response = self.register_to_check_discount(s)
        self.assertEqual(response.redirect_chain,
                         [(reverse('showRegSummary'), 302)])
        self.assertEqual(response.context_data.get('totalPrice'),
                         s.getBasePrice())
        self.assertEqual(response.context_data.get('netPrice'),
                         response.context_data.get('totalPrice') - 5)
        self.assertEqual(response.context_data.get('is_free'), False)
        self.assertEqual(response.context_data.get('total_discount_amount'), 5)
        self.assertFalse(response.context_data.get('addonItems'))

        discount_codes = response.context_data.get('discount_codes')
        self.assertEqual([x[0] for x in discount_codes], [
            test_combo.name,
        ])
Ejemplo n.º 9
0
    def test_nonexistent_voucher(self):
        ''' Check that entering a non-existent voucher fails '''

        updateConstant('vouchers__enableVouchers', True)
        s = self.create_series(pricingTier=self.defaultPricing)

        response = self.register_to_check_voucher('MADEUP_CODE',s)
        self.assertEqual(response.status_code,200)
        self.assertFalse(response.redirect_chain)
        self.assertTrue(response.context_data['form'].errors.get('gift'))
Ejemplo n.º 10
0
    def test_disabled_voucher(self):
        ''' Create a disabled voucher and ensure that it fails '''

        updateConstant('vouchers__enableVouchers', True)
        s = self.create_series(pricingTier=self.defaultPricing)
        v = self.create_voucher(disabled=True)

        response = self.register_to_check_voucher(v.voucherId,s)
        self.assertEqual(response.status_code,200)
        self.assertFalse(response.redirect_chain)
        self.assertTrue(response.context_data['form'].errors.get('gift'))
Ejemplo n.º 11
0
    def test_expired_voucher(self):
        '''
        Create a voucher that has an expiration date of yesterday
        and ensure that it fails
        '''

        updateConstant('vouchers__enableVouchers', True)
        s = self.create_series(pricingTier=self.defaultPricing)
        v = self.create_voucher(expirationDate=timezone.now() + timedelta(days=-1))

        response = self.register_to_check_voucher(v.voucherId,s)
        self.assertEqual(response.status_code,200)
        self.assertFalse(response.redirect_chain)
        self.assertTrue(response.context_data['form'].errors.get('gift'))
Ejemplo n.º 12
0
    def test_discountmakesitfree(self):
        '''
        Make the dollar discount larger than the base price and check that
        the registration is free, that the registration is processed and that
        a $0 invoice is created.
        '''

        updateConstant('general__discountsEnabled', True)
        s = self.create_series(pricingTier=self.defaultPricing)
        test_combo, test_component = self.create_discount(
            discountType=DiscountCombo.DiscountType.dollarDiscount,
            dollarDiscount=s.getBasePrice() + 10)

        response = self.register_to_check_discount(s)
        self.assertEqual(response.redirect_chain,
                         [(reverse('showRegSummary'), 302)])
        self.assertEqual(response.context_data.get('totalPrice'),
                         s.getBasePrice())
        self.assertEqual(response.context_data.get('netPrice'), 0)
        self.assertEqual(response.context_data.get('is_free'), True)
        self.assertEqual(response.context_data.get('total_discount_amount'),
                         s.getBasePrice())
        self.assertFalse(response.context_data.get('addonItems'))

        discount_codes = response.context_data.get('discount_codes')
        self.assertEqual([x[0] for x in discount_codes], [
            test_combo.name,
        ])

        # Since the above registration was free, check that the registration actually
        # processed, and that there exists a paid Invoice for $0
        finalReg = getattr(response.context_data.get('registration'),
                           'registration')
        self.assertTrue(finalReg)
        self.assertEqual(finalReg.netPrice, 0)
        self.assertTrue(finalReg.invoice)
        self.assertTrue(finalReg.invoice.status == Invoice.PaymentStatus.paid)
        self.assertEqual(finalReg.invoice.outstandingBalance, 0)
        self.assertEqual(finalReg.invoice.total, 0)

        # Check that the associated temporary registration is now expired
        self.assertTrue(
            finalReg.temporaryRegistration.expirationDate <= timezone.now())

        # Show that multiple registrations by the same customer are not permitted
        response = self.register_to_check_discount(s)
        self.assertIn(
            'You are already registered for',
            ' '.join(response.context_data['form'].errors.get('__all__')))
Ejemplo n.º 13
0
    def test_discounts_disabled(self):
        ''' Disable discounts and check that they don't work anymore '''

        updateConstant('general__discountsEnabled', False)
        test_combo, test_component = self.create_discount()
        s = self.create_series(pricingTier=self.defaultPricing)

        response = self.register_to_check_discount(s)
        self.assertEqual(response.redirect_chain,[(reverse('showRegSummary'), 302)])
        self.assertEqual(response.context_data.get('totalPrice'), s.getBasePrice())
        self.assertEqual(response.context_data.get('netPrice'),response.context_data.get('totalPrice'))
        self.assertEqual(response.context_data.get('is_free'),False)
        self.assertEqual(response.context_data.get('total_discount_amount'),0)
        self.assertFalse(response.context_data.get('addonItems'))
        self.assertFalse(response.context_data.get('discount_codes'))
Ejemplo n.º 14
0
    def test_discounts_disabled(self):
        ''' Disable discounts and check that they don't work anymore '''

        updateConstant('general__discountsEnabled', False)
        test_combo, test_component = self.create_discount()
        s = self.create_series(pricingTier=self.defaultPricing)

        response = self.register_to_check_discount(s)
        self.assertEqual(response.redirect_chain,[(reverse('showRegSummary'), 302)])
        self.assertEqual(response.context_data.get('totalPrice'), s.getBasePrice())
        self.assertEqual(response.context_data.get('netPrice'),response.context_data.get('totalPrice'))
        self.assertEqual(response.context_data.get('is_free'),False)
        self.assertEqual(response.context_data.get('total_discount_amount'),0)
        self.assertFalse(response.context_data.get('addonItems'))
        self.assertFalse(response.context_data.get('discount_codes'))
Ejemplo n.º 15
0
    def test_existing_customers_voucher(self):
        '''
        Create a voucher for existing customers only and ensure
        that it fails for an anonymous new customer
        '''

        updateConstant('vouchers__enableVouchers', True)
        s = self.create_series(pricingTier=self.defaultPricing)
        v = self.create_voucher(
            forPreviousCustomersOnly=True,
            expirationDate=timezone.now() + timedelta(days=1),
        )

        response = self.register_to_check_voucher(v.voucherId,s)
        self.assertEqual(response.status_code,200)
        self.assertFalse(response.redirect_chain)
        self.assertTrue(response.context_data['form'].errors.get('gift'))
Ejemplo n.º 16
0
    def test_inactive_discount(self):
        '''
        Make a discount inactive and make sure that it doesn't work
        '''

        updateConstant('general__discountsEnabled', True)
        test_combo, test_component = self.create_discount(active=False)
        s = self.create_series(pricingTier=self.defaultPricing)

        response = self.register_to_check_discount(s)
        self.assertEqual(response.redirect_chain,[(reverse('showRegSummary'), 302)])
        self.assertEqual(response.context_data.get('totalPrice'), s.getBasePrice())
        self.assertEqual(response.context_data.get('netPrice'),response.context_data.get('totalPrice'))
        self.assertEqual(response.context_data.get('is_free'),False)
        self.assertEqual(response.context_data.get('total_discount_amount'),0)
        self.assertFalse(response.context_data.get('addonItems'))
        self.assertFalse(response.context_data.get('discount_codes'))
Ejemplo n.º 17
0
    def test_expired_discount(self):
        '''
        Create an expired discount and make sure that it doesn't work.
        '''

        updateConstant('general__discountsEnabled', True)
        test_combo, test_component = self.create_discount(expirationDate=timezone.now() + timedelta(days=-1))
        s = self.create_series(pricingTier=self.defaultPricing)

        response = self.register_to_check_discount(s)
        self.assertEqual(response.redirect_chain,[(reverse('showRegSummary'), 302)])
        self.assertEqual(response.context_data.get('totalPrice'), s.getBasePrice())
        self.assertEqual(response.context_data.get('netPrice'),response.context_data.get('totalPrice'))
        self.assertEqual(response.context_data.get('is_free'),False)
        self.assertEqual(response.context_data.get('total_discount_amount'),0)
        self.assertFalse(response.context_data.get('addonItems'))
        self.assertFalse(response.context_data.get('discount_codes'))
Ejemplo n.º 18
0
    def test_expired_discount(self):
        '''
        Create an expired discount and make sure that it doesn't work.
        '''

        updateConstant('general__discountsEnabled', True)
        test_combo, test_component = self.create_discount(expirationDate=timezone.now() + timedelta(days=-1))
        s = self.create_series(pricingTier=self.defaultPricing)

        response = self.register_to_check_discount(s)
        self.assertEqual(response.redirect_chain,[(reverse('showRegSummary'), 302)])
        self.assertEqual(response.context_data.get('totalPrice'), s.getBasePrice())
        self.assertEqual(response.context_data.get('netPrice'),response.context_data.get('totalPrice'))
        self.assertEqual(response.context_data.get('is_free'),False)
        self.assertEqual(response.context_data.get('total_discount_amount'),0)
        self.assertFalse(response.context_data.get('addonItems'))
        self.assertFalse(response.context_data.get('discount_codes'))
Ejemplo n.º 19
0
    def test_inactive_discount(self):
        '''
        Make a discount inactive and make sure that it doesn't work
        '''

        updateConstant('general__discountsEnabled', True)
        test_combo, test_component = self.create_discount(active=False)
        s = self.create_series(pricingTier=self.defaultPricing)

        response = self.register_to_check_discount(s)
        self.assertEqual(response.redirect_chain,[(reverse('showRegSummary'), 302)])
        self.assertEqual(response.context_data.get('totalPrice'), s.getBasePrice())
        self.assertEqual(response.context_data.get('netPrice'),response.context_data.get('totalPrice'))
        self.assertEqual(response.context_data.get('is_free'),False)
        self.assertEqual(response.context_data.get('total_discount_amount'),0)
        self.assertFalse(response.context_data.get('addonItems'))
        self.assertFalse(response.context_data.get('discount_codes'))
Ejemplo n.º 20
0
    def test_notenoughpoints(self):
        '''
        Set the discount's components so that this discount is too small to apply, and
        check that it doesn't get applied.
        '''

        updateConstant('general__discountsEnabled', True)
        test_combo, test_component = self.create_discount(quantity=10)
        s = self.create_series(pricingTier=self.defaultPricing)

        response = self.register_to_check_discount(s)
        self.assertEqual(response.redirect_chain,[(reverse('showRegSummary'), 302)])
        self.assertEqual(response.context_data.get('totalPrice'), s.getBasePrice())
        self.assertEqual(response.context_data.get('netPrice'),response.context_data.get('totalPrice'))
        self.assertEqual(response.context_data.get('is_free'),False)
        self.assertEqual(response.context_data.get('total_discount_amount'),0)
        self.assertFalse(response.context_data.get('addonItems'))
        self.assertFalse(response.context_data.get('discount_codes'))
Ejemplo n.º 21
0
    def test_notenoughpoints(self):
        '''
        Set the discount's components so that this discount is too small to apply, and
        check that it doesn't get applied.
        '''

        updateConstant('general__discountsEnabled', True)
        test_combo, test_component = self.create_discount(quantity=10)
        s = self.create_series(pricingTier=self.defaultPricing)

        response = self.register_to_check_discount(s)
        self.assertEqual(response.redirect_chain,[(reverse('showRegSummary'), 302)])
        self.assertEqual(response.context_data.get('totalPrice'), s.getBasePrice())
        self.assertEqual(response.context_data.get('netPrice'),response.context_data.get('totalPrice'))
        self.assertEqual(response.context_data.get('is_free'),False)
        self.assertEqual(response.context_data.get('total_discount_amount'),0)
        self.assertFalse(response.context_data.get('addonItems'))
        self.assertFalse(response.context_data.get('discount_codes'))
Ejemplo n.º 22
0
    def test_noearlybird(self):
        '''
        Create an early registration discount that requires three day
        advance registration and ensure that it does not work less than
        three days in advance.
        '''

        updateConstant('general__discountsEnabled', True)
        test_combo, test_component = self.create_discount(daysInAdvanceRequired=3)
        s = self.create_series(pricingTier=self.defaultPricing,startTime=timezone.now() + timedelta(days=1))

        response = self.register_to_check_discount(s)
        self.assertEqual(response.redirect_chain,[(reverse('showRegSummary'), 302)])
        self.assertEqual(response.context_data.get('totalPrice'), s.getBasePrice())
        self.assertEqual(response.context_data.get('netPrice'),response.context_data.get('totalPrice'))
        self.assertEqual(response.context_data.get('is_free'),False)
        self.assertEqual(response.context_data.get('total_discount_amount'),0)
        self.assertFalse(response.context_data.get('addonItems'))
        self.assertFalse(response.context_data.get('discount_codes'))
Ejemplo n.º 23
0
    def test_dollarDiscount(self):
        '''
        Create a $10 off discount and check that it applies appropriately
        '''

        updateConstant('general__discountsEnabled', True)
        test_combo, test_component = self.create_discount(discountType=DiscountCombo.DiscountType.dollarDiscount, dollarDiscount=10)
        s = self.create_series(pricingTier=self.defaultPricing)

        response = self.register_to_check_discount(s)
        self.assertEqual(response.redirect_chain,[(reverse('showRegSummary'), 302)])
        self.assertEqual(response.context_data.get('totalPrice'), s.getBasePrice())
        self.assertEqual(response.context_data.get('netPrice'),response.context_data.get('totalPrice') - 10)
        self.assertEqual(response.context_data.get('is_free'),False)
        self.assertEqual(response.context_data.get('total_discount_amount'),10)
        self.assertFalse(response.context_data.get('addonItems'))

        discount_codes = response.context_data.get('discount_codes')
        self.assertEqual([x[0] for x in discount_codes], [test_combo.name,])
Ejemplo n.º 24
0
    def test_discount_applies(self):
        '''
        Create a flat $5 discount and test that it applies
        '''

        updateConstant('general__discountsEnabled', True)
        test_combo, test_component = self.create_discount()
        s = self.create_series(pricingTier=self.defaultPricing)

        response = self.register_to_check_discount(s)
        self.assertEqual(response.redirect_chain,[(reverse('showRegSummary'), 302)])
        self.assertEqual(response.context_data.get('totalPrice'), s.getBasePrice())
        self.assertEqual(response.context_data.get('netPrice'),response.context_data.get('totalPrice') - 5)
        self.assertEqual(response.context_data.get('is_free'),False)
        self.assertEqual(response.context_data.get('total_discount_amount'),5)
        self.assertFalse(response.context_data.get('addonItems'))

        discount_codes = response.context_data.get('discount_codes')
        self.assertEqual([x[0] for x in discount_codes], [test_combo.name,])
Ejemplo n.º 25
0
    def test_allwithinpointgroup(self):
        '''
        Set a discount to apply to an entire point group and check that the price
        is still the flat price
        '''

        updateConstant('general__discountsEnabled', True)
        test_combo, test_component = self.create_discount(quantity=1, allWithinPointGroup=True)
        s = self.create_series(pricingTier=self.defaultPricing)

        response = self.register_to_check_discount(s)
        self.assertEqual(response.redirect_chain,[(reverse('showRegSummary'), 302)])
        self.assertEqual(response.context_data.get('totalPrice'), s.getBasePrice())
        self.assertEqual(response.context_data.get('netPrice'),response.context_data.get('totalPrice') - 5)
        self.assertEqual(response.context_data.get('is_free'),False)
        self.assertEqual(response.context_data.get('total_discount_amount'),5)
        self.assertFalse(response.context_data.get('addonItems'))

        discount_codes = response.context_data.get('discount_codes')
        self.assertEqual([x[0] for x in discount_codes], [test_combo.name,])
Ejemplo n.º 26
0
    def test_addOnItem(self):
        '''
        Create a free add-on item and ensure that it is applied correctly.
        '''

        updateConstant('general__discountsEnabled', True)
        test_combo, test_component = self.create_discount(
            discountType=DiscountCombo.DiscountType.addOn,
            name='Test Free Add-On',
        )
        s = self.create_series(pricingTier=self.defaultPricing)

        response = self.register_to_check_discount(s)

        self.assertEqual(response.redirect_chain,[(reverse('showRegSummary'), 302)])
        self.assertEqual(response.context_data.get('totalPrice'), s.getBasePrice())
        self.assertEqual(response.context_data.get('netPrice'), response.context_data.get('totalPrice'))
        self.assertEqual(response.context_data.get('is_free'),False)
        self.assertEqual(response.context_data.get('total_discount_amount'),0)
        self.assertTrue(response.context_data.get('addonItems'))
        self.assertFalse(response.context_data.get('discount_codes'))
Ejemplo n.º 27
0
    def test_addOnItem(self):
        '''
        Create a free add-on item and ensure that it is applied correctly.
        '''

        updateConstant('general__discountsEnabled', True)
        test_combo, test_component = self.create_discount(
            discountType=DiscountCombo.DiscountType.addOn,
            name='Test Free Add-On',
        )
        s = self.create_series(pricingTier=self.defaultPricing)

        response = self.register_to_check_discount(s)

        self.assertEqual(response.redirect_chain,[(reverse('showRegSummary'), 302)])
        self.assertEqual(response.context_data.get('totalPrice'), s.getBasePrice())
        self.assertEqual(response.context_data.get('netPrice'), response.context_data.get('totalPrice'))
        self.assertEqual(response.context_data.get('is_free'),False)
        self.assertEqual(response.context_data.get('total_discount_amount'),0)
        self.assertTrue(response.context_data.get('addonItems'))
        self.assertFalse(response.context_data.get('discount_codes'))
Ejemplo n.º 28
0
    def test_discountmakesitfree(self):
        '''
        Make the dollar discount larger than the base price and check that
        the registration is free, that the registration is processed and that
        a $0 invoice is created.
        '''

        updateConstant('general__discountsEnabled', True)
        s = self.create_series(pricingTier=self.defaultPricing)
        test_combo, test_component = self.create_discount(discountType=DiscountCombo.DiscountType.dollarDiscount, dollarDiscount=s.getBasePrice() + 10)

        response = self.register_to_check_discount(s)
        self.assertEqual(response.redirect_chain,[(reverse('showRegSummary'), 302)])
        self.assertEqual(response.context_data.get('totalPrice'), s.getBasePrice())
        self.assertEqual(response.context_data.get('netPrice'),0)
        self.assertEqual(response.context_data.get('is_free'),True)
        self.assertEqual(response.context_data.get('total_discount_amount'),s.getBasePrice())
        self.assertFalse(response.context_data.get('addonItems'))

        discount_codes = response.context_data.get('discount_codes')
        self.assertEqual([x[0] for x in discount_codes], [test_combo.name,])

        # Since the above registration was free, check that the registration actually
        # processed, and that there exists a paid Invoice for $0
        finalReg = getattr(response.context_data.get('registration'),'registration')
        self.assertTrue(finalReg)
        self.assertEqual(finalReg.netPrice, 0)
        self.assertTrue(finalReg.invoice)
        self.assertTrue(finalReg.invoice.status == Invoice.PaymentStatus.paid)
        self.assertEqual(finalReg.invoice.outstandingBalance, 0)
        self.assertEqual(finalReg.invoice.total, 0)

        # Check that the associated temporary registration is now expired
        self.assertTrue(finalReg.temporaryRegistration.expirationDate <= timezone.now())

        # Show that multiple registrations by the same customer are not permitted
        response = self.register_to_check_discount(s)
        self.assertIn('You are already registered for',' '.join(response.context_data['form'].errors.get('__all__')))
Ejemplo n.º 29
0
    def test_dollarDiscount(self):
        '''
        Create a $10 off discount and check that it applies appropriately
        '''

        updateConstant('general__discountsEnabled', True)
        test_combo, test_component = self.create_discount(
            discountType=DiscountCombo.DiscountType.dollarDiscount,
            dollarDiscount=10)
        s = self.create_series(pricingTier=self.defaultPricing)

        response = self.register_to_check_discount(s)
        self.assertEqual(response.redirect_chain,
                         [(reverse('showRegSummary'), 302)])
        self.assertEqual(response.context_data.get('totalPrice'),
                         s.getBasePrice())
        self.assertEqual(response.context_data.get('netPrice'),
                         response.context_data.get('totalPrice') - 10)
        self.assertEqual(response.context_data.get('is_free'), False)
        self.assertEqual(response.context_data.get('total_discount_amount'),
                         10)
        self.assertFalse(response.context_data.get('addonItems'))
        self.assertEqual(response.context_data.get('discount_code_name'),
                         test_combo.name)