def test_deserialize_cart(self): """ Deserializes a ShopCart """ item = self._create_item() shopcart = self._create_shopcart(items=[item]) serial_shopcart = shopcart.serialize() new_shopcart = ShopCart() new_shopcart.deserialize(serial_shopcart) self.assertEqual(new_shopcart.id, shopcart.id)
def create_shopcarts(): """ Creates a shopping cart This endpoint will create a Shopcart based the data in the body that is posted """ app.logger.info("Request to create a ShopCart") app.logger.info(request.get_json()) check_content_type("application/json") shopcart = ShopCart() shopcart.deserialize(request.get_json()) shopcart.create() message = shopcart.serialize() location_url = url_for("get_shopcarts", shopcart_id=shopcart.id, _external=True) return make_response( jsonify(message), status.HTTP_201_CREATED, {"Location": location_url} )