2016-09-15 00:55:07 +00:00
|
|
|
import datetime
|
|
|
|
|
2016-09-14 23:38:42 +00:00
|
|
|
from registrasion.models import commerce
|
|
|
|
|
|
|
|
from controller_helpers import TestingCartController
|
|
|
|
from controller_helpers import TestingCreditNoteController
|
|
|
|
from controller_helpers import TestingInvoiceController
|
|
|
|
|
2016-09-14 23:29:31 +00:00
|
|
|
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))
|
|
|
|
|
2016-09-15 00:55:07 +00:00
|
|
|
def _manual_invoice(self, value=1):
|
|
|
|
items = [("Item", value)]
|
|
|
|
due = datetime.timedelta(hours=1)
|
|
|
|
inv = TestingInvoiceController.manual_invoice(self.USER_1, due, items)
|
|
|
|
|
|
|
|
return TestingInvoiceController(inv)
|
|
|
|
|
2016-09-14 23:29:31 +00:00
|
|
|
def _credit_note_for_invoice(self, invoice):
|
|
|
|
note = commerce.CreditNote.objects.get(invoice=invoice)
|
|
|
|
return TestingCreditNoteController(note)
|