def test_delete_wishlist(self):
     """ Delete a Wishlist """
     wishlist = Wishlist(name="wishlist_name", customer_id=1234)
     wishlist.save()
     self.assertEqual(len(Wishlist.all()), 1)
     # delete the wishlist and make sure it isn't in the database
     wishlist.delete()
     self.assertEqual(len(Wishlist.all()), 0)
    def get(self):
        """ Query a wishlist by its id """
        app.logger.info('Querying Wishlist list')
        wishlist_id = request.args.get('id')
        customer_id = request.args.get('customer_id')
        name = request.args.get('name')

        wishlist = []

        if not wishlist_id and not name and not customer_id:
            wishlist = Wishlist.all()
        else:
            wishlist = Wishlist.find_by_all(wishlist_id=wishlist_id,
                                            customer_id=customer_id,
                                            name=name)

        if not wishlist:
            api.abort(404, "No wishlist found.")

        response_content = [res.serialize() for res in wishlist]

        if response_content is None or len(response_content) == 0:
            api.abort(404, "No wishlist found.")

        return response_content, status.HTTP_200_OK
예제 #3
0
    def test_delete_wishlist_product(self):
        """ Delete a Wishlist Product"""
        wishlist = Wishlist(name="wishlist_name", customer_id=1234)
        wishlist.save()
        self.assertEqual(len(wishlist.all()), 1)

        wishlist_product = WishlistProduct(wishlist_id=1, product_id=1213321,
                                           product_name="Macbook Pro")
        wishlist_product.save()
        self.assertTrue(wishlist_product is not None)
        wishlist_product.delete()
        self.assertEqual(len(WishlistProduct.all()), 0)