class UpdateEffectiveContractDiscountTests(TestCase): """ Tests the enrollment code creation command. """ def setUp(self): """ Create test data. """ super(UpdateEffectiveContractDiscountTests, self).setUp() # Set up orders with a enterprise_customer self.enterprise_customer_uuid = '123e4567-e89b-12d3-a456-426655440000' self.unit_price = 100 self.condition = ManualEnrollmentOrderDiscountConditionFactory( enterprise_customer_uuid=self.enterprise_customer_uuid ) self.offer = ConditionalOfferFactory(condition=self.condition, id=9999) self.order = OrderFactory() self.order_discount = OrderDiscountFactory(offer_id=self.offer.id, order=self.order) self.line = OrderLineFactory(order=self.order, unit_price_excl_tax=self.unit_price) self.line.save() self.order_discount = OrderDiscountFactory(offer_id=self.offer.id, order=self.order) self.order.save() self.offer.save() self.condition.save() def test_discount_update(self): discount_percentage = 20 call_command( 'update_effective_contract_discount', '--enterprise-customer={}'.format(self.enterprise_customer_uuid), '--discount-percentage={}'.format(discount_percentage) ) assert self.line.order == self.order
class TestAnOfferChangesStatusWhen(TestCase): def setUp(self): ConditionalOffer = get_model('offer', 'ConditionalOffer') self.offer = ConditionalOfferFactory(offer_type=ConditionalOffer.SITE) def test_the_max_discount_is_exceeded(self): self.offer.max_discount = D('10.00') self.assertTrue(self.offer.is_open) # Now bump the total discount and save to see if the status is # automatically updated. self.offer.total_discount += D('20.00') self.offer.save() self.assertFalse(self.offer.is_open) def test_the_max_global_applications_is_exceeded(self): self.offer.max_global_applications = 5 self.assertTrue(self.offer.is_open) self.offer.num_applications += 10 self.offer.save() self.assertFalse(self.offer.is_open)
class TestAnOfferChangesStatusWhen(TestCase): def setUp(self): ConditionalOffer = get_model('offer', 'ConditionalOffer') self.offer = ConditionalOfferFactory( offer_type=ConditionalOffer.SITE) def test_the_max_discount_is_exceeded(self): self.offer.max_discount = D('10.00') self.assertTrue(self.offer.is_open) # Now bump the total discount and save to see if the status is # automatically updated. self.offer.total_discount += D('20.00') self.offer.save() self.assertFalse(self.offer.is_open) def test_the_max_global_applications_is_exceeded(self): self.offer.max_global_applications = 5 self.assertTrue(self.offer.is_open) self.offer.num_applications += 10 self.offer.save() self.assertFalse(self.offer.is_open)