Changeset - 9a4574ef2c3b
[Not reviewed]
0 1 0
Christopher Neugebauer - 8 years ago 2016-04-24 22:25:19
chrisjrn@gmail.com
DRYs up test_invoice a bit
1 file changed with 25 insertions and 73 deletions:
0 comments (0 inline, 0 general)
registrasion/tests/test_invoice.py
Show inline comments
...
 
@@ -20,2 +20,8 @@ class InvoiceTestCase(RegistrationCartTestCase):
 

	
 
    def _invoice_containing_prod_1(self, qty=1):
 
        cart = TestingCartController.for_user(self.USER_1)
 
        cart.add_to_cart(self.PROD_1, qty)
 

	
 
        return TestingInvoiceController.for_cart(self.reget(cart.cart))
 

	
 
    def test_create_invoice(self):
...
 
@@ -56,6 +62,3 @@ class InvoiceTestCase(RegistrationCartTestCase):
 
    def test_invoice_controller_for_id_works(self):
 
        current_cart = TestingCartController.for_user(self.USER_1)
 
        current_cart.add_to_cart(self.PROD_1, 1)
 

	
 
        invoice = TestingInvoiceController.for_cart(current_cart.cart)
 
        invoice = self._invoice_containing_prod_1(1)
 

	
...
 
@@ -84,6 +87,4 @@ class InvoiceTestCase(RegistrationCartTestCase):
 
    def test_paying_invoice_makes_new_cart(self):
 
        current_cart = TestingCartController.for_user(self.USER_1)
 
        current_cart.add_to_cart(self.PROD_1, 1)
 
        invoice = self._invoice_containing_prod_1(1)
 

	
 
        invoice = TestingInvoiceController.for_cart(current_cart.cart)
 
        invoice.pay("A payment!", invoice.invoice.value)
...
 
@@ -98,3 +99,3 @@ class InvoiceTestCase(RegistrationCartTestCase):
 
        new_cart = TestingCartController.for_user(self.USER_1)
 
        self.assertNotEqual(current_cart.cart, new_cart.cart)
 
        self.assertNotEqual(invoice.invoice.cart, new_cart.cart)
 

	
...
 
@@ -183,7 +184,3 @@ class InvoiceTestCase(RegistrationCartTestCase):
 
    def test_voiding_invoice_creates_new_invoice(self):
 
        current_cart = TestingCartController.for_user(self.USER_1)
 

	
 
        # Should be able to create an invoice after the product is added
 
        current_cart.add_to_cart(self.PROD_1, 1)
 
        invoice_1 = TestingInvoiceController.for_cart(current_cart.cart)
 
        invoice_1 = self._invoice_containing_prod_1(1)
 

	
...
 
@@ -192,3 +189,3 @@ class InvoiceTestCase(RegistrationCartTestCase):
 

	
 
        invoice_2 = TestingInvoiceController.for_cart(current_cart.cart)
 
        invoice_2 = TestingInvoiceController.for_cart(invoice_1.invoice.cart)
 
        self.assertNotEqual(invoice_1.invoice, invoice_2.invoice)
...
 
@@ -196,7 +193,3 @@ class InvoiceTestCase(RegistrationCartTestCase):
 
    def test_cannot_pay_void_invoice(self):
 
        current_cart = TestingCartController.for_user(self.USER_1)
 

	
 
        # Should be able to create an invoice after the product is added
 
        current_cart.add_to_cart(self.PROD_1, 1)
 
        invoice_1 = TestingInvoiceController.for_cart(current_cart.cart)
 
        invoice_1 = self._invoice_containing_prod_1(1)
 

	
...
 
@@ -208,7 +201,3 @@ class InvoiceTestCase(RegistrationCartTestCase):
 
    def test_cannot_void_paid_invoice(self):
 
        current_cart = TestingCartController.for_user(self.USER_1)
 

	
 
        # Should be able to create an invoice after the product is added
 
        current_cart.add_to_cart(self.PROD_1, 1)
 
        invoice = TestingInvoiceController.for_cart(current_cart.cart)
 
        invoice = self._invoice_containing_prod_1(1)
 

	
...
 
@@ -220,7 +209,3 @@ class InvoiceTestCase(RegistrationCartTestCase):
 
    def test_cannot_void_partially_paid_invoice(self):
 
        current_cart = TestingCartController.for_user(self.USER_1)
 

	
 
        # Should be able to create an invoice after the product is added
 
        current_cart.add_to_cart(self.PROD_1, 1)
 
        invoice = TestingInvoiceController.for_cart(current_cart.cart)
 
        invoice = self._invoice_containing_prod_1(1)
 

	
...
 
@@ -249,6 +234,3 @@ class InvoiceTestCase(RegistrationCartTestCase):
 
    def test_overpaid_invoice_results_in_credit_note(self):
 
        cart = TestingCartController.for_user(self.USER_1)
 
        cart.add_to_cart(self.PROD_1, 1)
 

	
 
        invoice = TestingInvoiceController.for_cart(self.reget(cart.cart))
 
        invoice = self._invoice_containing_prod_1(1)
 

	
...
 
@@ -270,6 +252,3 @@ class InvoiceTestCase(RegistrationCartTestCase):
 
    def test_full_paid_invoice_does_not_generate_credit_note(self):
 
        cart = TestingCartController.for_user(self.USER_1)
 
        cart.add_to_cart(self.PROD_1, 1)
 

	
 
        invoice = TestingInvoiceController.for_cart(self.reget(cart.cart))
 
        invoice = self._invoice_containing_prod_1(1)
 

	
...
 
@@ -289,6 +268,3 @@ class InvoiceTestCase(RegistrationCartTestCase):
 
    def test_refund_partially_paid_invoice_generates_correct_credit_note(self):
 
        cart = TestingCartController.for_user(self.USER_1)
 
        cart.add_to_cart(self.PROD_1, 1)
 

	
 
        invoice = TestingInvoiceController.for_cart(self.reget(cart.cart))
 
        invoice = self._invoice_containing_prod_1(1)
 

	
...
 
@@ -311,6 +287,3 @@ class InvoiceTestCase(RegistrationCartTestCase):
 
    def test_refund_fully_paid_invoice_generates_correct_credit_note(self):
 
        cart = TestingCartController.for_user(self.USER_1)
 
        cart.add_to_cart(self.PROD_1, 1)
 

	
 
        invoice = TestingInvoiceController.for_cart(self.reget(cart.cart))
 
        invoice = self._invoice_containing_prod_1(1)
 

	
...
 
@@ -334,6 +307,3 @@ class InvoiceTestCase(RegistrationCartTestCase):
 
    def test_apply_credit_note_pays_invoice(self):
 
        cart = TestingCartController.for_user(self.USER_1)
 
        cart.add_to_cart(self.PROD_1, 1)
 

	
 
        invoice = TestingInvoiceController.for_cart(self.reget(cart.cart))
 
        invoice = self._invoice_containing_prod_1(1)
 

	
...
 
@@ -365,6 +335,3 @@ class InvoiceTestCase(RegistrationCartTestCase):
 
    def test_apply_credit_note_generates_new_credit_note_if_overpaying(self):
 
        cart = TestingCartController.for_user(self.USER_1)
 
        cart.add_to_cart(self.PROD_1, 2)
 

	
 
        invoice = TestingInvoiceController.for_cart(self.reget(cart.cart))
 
        invoice = self._invoice_containing_prod_1(2)
 

	
...
 
@@ -407,6 +374,3 @@ class InvoiceTestCase(RegistrationCartTestCase):
 
    def test_cannot_apply_credit_note_on_invalid_invoices(self):
 
        cart = TestingCartController.for_user(self.USER_1)
 
        cart.add_to_cart(self.PROD_1, 1)
 

	
 
        invoice = TestingInvoiceController.for_cart(self.reget(cart.cart))
 
        invoice = self._invoice_containing_prod_1(1)
 

	
...
 
@@ -423,6 +387,3 @@ class InvoiceTestCase(RegistrationCartTestCase):
 
        # Create a new cart with invoice, pay it
 
        cart = TestingCartController.for_user(self.USER_1)
 
        cart.add_to_cart(self.PROD_1, 1)
 

	
 
        invoice_2 = TestingInvoiceController.for_cart(self.reget(cart.cart))
 
        invoice_2 = self._invoice_containing_prod_1(1)
 
        invoice_2.pay("LOL", invoice_2.invoice.value)
...
 
@@ -439,6 +400,3 @@ class InvoiceTestCase(RegistrationCartTestCase):
 
        # Create a new cart with invoice
 
        cart = TestingCartController.for_user(self.USER_1)
 
        cart.add_to_cart(self.PROD_1, 1)
 

	
 
        invoice_2 = TestingInvoiceController.for_cart(self.reget(cart.cart))
 
        invoice_2 = self._invoice_containing_prod_1(1)
 
        invoice_2.void()
...
 
@@ -449,6 +407,3 @@ class InvoiceTestCase(RegistrationCartTestCase):
 
    def test_cannot_apply_a_refunded_credit_note(self):
 
        cart = TestingCartController.for_user(self.USER_1)
 
        cart.add_to_cart(self.PROD_1, 1)
 

	
 
        invoice = TestingInvoiceController.for_cart(self.reget(cart.cart))
 
        invoice = self._invoice_containing_prod_1(1)
 

	
...
 
@@ -481,6 +436,3 @@ class InvoiceTestCase(RegistrationCartTestCase):
 
    def test_cannot_refund_an_applied_credit_note(self):
 
        cart = TestingCartController.for_user(self.USER_1)
 
        cart.add_to_cart(self.PROD_1, 1)
 

	
 
        invoice = TestingInvoiceController.for_cart(self.reget(cart.cart))
 
        invoice = self._invoice_containing_prod_1(1)
 

	
0 comments (0 inline, 0 general)