def add_voucher_to_basket(self, voucher=None): if voucher is None: voucher = factories.create_voucher() basket_page = self.get(reverse('basket:summary')) form = basket_page.forms['voucher_form'] form['code'] = voucher.code form.submit()
def add_voucher_to_basket(self, voucher=None): if voucher is None: voucher = factories.create_voucher() basket_page = self.get(reverse("basket:summary")) form = basket_page.forms["voucher_form"] form["code"] = voucher.code form.submit()
def test_can_be_created_with_a_voucher(self): voucher = create_voucher() order = create_order(number='100002') discount = OrderDiscount.objects.create(order=order, amount=D('10.00'), voucher_id=voucher.id) self.assertEqual(voucher.id, discount.voucher.id) self.assertEqual(voucher.code, discount.voucher_code)
def test_can_be_created_with_a_voucher_and_specidied_voucher_code(self): voucher = create_voucher() order = create_order(number='100002') discount = OrderDiscount.objects.create(order=order, amount=D('10.00'), voucher_id=voucher.id, voucher_code="anothercode") self.assertEqual(voucher.id, discount.voucher.id) self.assertEqual('anothercode', discount.voucher_code)
def test_contains_voucher_details_after_voucher_is_deleted(self): voucher = create_voucher() order = create_order(number="100002") discount = OrderDiscount.objects.create(order=order, amount=D("10.00"), voucher_id=voucher.id) voucher.delete() self.assertTrue(discount.voucher is None) self.assertTrue(discount.offer is None) self.assertEquals(discount.description(), voucher.code)
def setUp(self): super(TestPlacingOrderUsingAVoucher, self).setUp() self.add_product_to_basket() voucher = create_voucher() self.add_voucher_to_basket(voucher) self.complete_shipping_address() self.complete_shipping_method() self.response = self.submit() # Reload voucher self.voucher = Voucher.objects.get(id=voucher.id)
def setUp(self): self.login() self.add_product_to_basket() voucher = create_voucher() self.add_voucher_to_basket(voucher) self.complete_shipping_address() self.complete_shipping_method() self.response = self.submit() # Reload voucher self.voucher = Voucher.objects.get(id=voucher.id)
def test_contains_voucher_details_after_voucher_is_deleted(self): voucher = create_voucher() order = create_order(number='100002') discount = OrderDiscount.objects.create(order=order, amount=D('10.00'), voucher_id=voucher.id) voucher.delete() self.assertTrue(discount.voucher is None) self.assertTrue(discount.offer is None) self.assertEqual(discount.description(), voucher.code)
def add_voucher_to_basket(self, voucher=None): if voucher is None: voucher = create_voucher() self.client.post(reverse('basket:vouchers-add'), {'code': voucher.code})
def setUp(self): self.voucher = factories.create_voucher() super().setUp()
def add_voucher_to_basket(self, voucher=None): if voucher is None: voucher = create_voucher() self.client.post(reverse("basket:vouchers-add"), {"code": voucher.code})