Files
@ 8ad265a65a08
Branch filter:
Location: symposion_app/registrasion/tests/cart_controller_helper.py - annotation
8ad265a65a08
902 B
text/x-python
Fixes tests now that $0 invoices pay themselves
eab1deff7776 eab1deff7776 eab1deff7776 eab1deff7776 eab1deff7776 760996588372 eab1deff7776 eab1deff7776 eab1deff7776 eab1deff7776 eab1deff7776 eab1deff7776 eab1deff7776 eab1deff7776 eab1deff7776 eab1deff7776 eab1deff7776 eab1deff7776 eab1deff7776 eab1deff7776 eab1deff7776 eab1deff7776 eab1deff7776 eab1deff7776 eab1deff7776 eab1deff7776 | from registrasion.controllers.cart import CartController
from registrasion import models as rego
from django.core.exceptions import ObjectDoesNotExist
class TestingCartController(CartController):
def set_quantity(self, product, quantity, batched=False):
''' Sets the _quantity_ of the given _product_ in the cart to the given
_quantity_. '''
self.set_quantities(((product, quantity),))
def add_to_cart(self, product, quantity):
''' Adds _quantity_ of the given _product_ to the cart. Raises
ValidationError if constraints are violated.'''
try:
product_item = rego.ProductItem.objects.get(
cart=self.cart,
product=product)
old_quantity = product_item.quantity
except ObjectDoesNotExist:
old_quantity = 0
self.set_quantity(product, old_quantity + quantity)
|