def on_put(self, req, resp, userId): try: userId = int(userId) """Skip the validations because we dont have yet way of adding user accounts to the system..""" doc = req.context['doc'] newCart = Cart.from_json(doc) if newCart.userId is None: newCart.userId = userId elif newCart.userId != userId: resp.status = falcon.HTTP_403 return #update product bl.setShoppingCart(newCart) resp.status = falcon.HTTP_200 #Status Ok except: #Return 500 - internal error resp.status = falcon.HTTP_500
def test_cart_add(): print("Testing cart add..") cart = Cart(79) cart.addProduct(1) cart.addProduct(1) db.updateShoppingCart(cart) cart2 = db.getShoppingCart(79) assert(cart2 is not None) bl.setShoppingCart(cart)