Ejemplo n.º 1
0
 def test_find_by_customer_id(self):
     """ Find a Wishlist by Customer_id """
     Wishlist("fido", "1").save()
     Wishlist("Bags", "2").save()
     wishlists = Wishlist.find_by_customer_id("1")
     self.assertNotEqual(len(wishlists), 0)
     self.assertEqual(wishlists[0].customer_id, "1")
     self.assertEqual(wishlists[0].name, "fido")
Ejemplo n.º 2
0
def list_wishlists():
    """ Returns all of the Wishlists """
    app.logger.info('Request to list Wishlists...')
    wishlists = []
    customer_id = request.args.get('customer_id')
    name = request.args.get('name')
    if customer_id:
        app.logger.info('Find by customer_id')
        wishlists = Wishlist.find_by_customer_id(customer_id)
    elif name:
        app.logger.info('Find by name')
        wishlists = Wishlist.find_by_name(name)
    else:
        app.logger.info('Find all')
        wishlists = Wishlist.all()

    app.logger.info('[%s] Wishlists returned', len(wishlists))
    results = [wishlist.serialize() for wishlist in wishlists]
    return make_response(jsonify(results), status.HTTP_200_OK)