From 23658be49a76f46021a77ff83d3ad6c536b4e46e Mon Sep 17 00:00:00 2001 From: Christopher Neugebauer Date: Thu, 15 Sep 2016 09:29:31 +1000 Subject: [PATCH] Starts test_helpers.py, so we can get credit note testing stuff into its own module. --- registrasion/tests/test_helpers.py | 11 +++++++++++ registrasion/tests/test_invoice.py | 13 ++----------- 2 files changed, 13 insertions(+), 11 deletions(-) create mode 100644 registrasion/tests/test_helpers.py diff --git a/registrasion/tests/test_helpers.py b/registrasion/tests/test_helpers.py new file mode 100644 index 00000000..cdd23de2 --- /dev/null +++ b/registrasion/tests/test_helpers.py @@ -0,0 +1,11 @@ +class TestHelperMixin(object): + + 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 _credit_note_for_invoice(self, invoice): + note = commerce.CreditNote.objects.get(invoice=invoice) + return TestingCreditNoteController(note) diff --git a/registrasion/tests/test_invoice.py b/registrasion/tests/test_invoice.py index 4f73bf3c..334db137 100644 --- a/registrasion/tests/test_invoice.py +++ b/registrasion/tests/test_invoice.py @@ -10,23 +10,14 @@ from registrasion.models import inventory from controller_helpers import TestingCartController from controller_helpers import TestingCreditNoteController from controller_helpers import TestingInvoiceController +from test_helpers import TestHelperMixin from test_cart import RegistrationCartTestCase UTC = pytz.timezone('UTC') -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 _credit_note_for_invoice(self, invoice): - note = commerce.CreditNote.objects.get(invoice=invoice) - return TestingCreditNoteController(note) +class InvoiceTestCase(TestHelperMixin, RegistrationCartTestCase): def test_create_invoice(self): current_cart = TestingCartController.for_user(self.USER_1)