Exemplo n.º 1
0
    def test_find_by_name(self):
        """ Find by name """
        order = self._create_order()
        order.create()

        # Fetch it back by name
        same_order = Order.find_by_name(order.name)[0]
        self.assertEqual(same_order.id, order.id)
        self.assertEqual(same_order.name, order.name)
Exemplo n.º 2
0
def list_orders():
    """ Returns all of the Orders """
    app.logger.info("Request for orders list")  # pylint: disable=maybe-no-member
    orders = []
    name = request.args.get("name")
    if name:
        orders = Order.find_by_name(name)
    else:
        orders = Order.all()

    results = [order.serialize() for order in orders]
    return make_response(jsonify(results), status.HTTP_200_OK)