def test_available(self): Product(0, 'Asus2500', 'Laptop', '234', 'laptop', 'blue', 4).save() Product(0, 'GE4509', 'Microwave', '34324', 'microwave', 'black', 0).save() products = Product.available() self.assertEqual(len(products), 1) self.assertIsNot(products[0], None) self.assertEqual(products[0].id, 1) self.assertEqual(products[0].name, "Asus2500")
def list_available_products(): results = Product.available() return make_response(jsonify([p.serialize() for p in results]), HTTP_200_OK)
def list_available_products(): """ Retrieves a list of available products from the database """ results = [] results = Product.available() return jsonify([p.serialize() for p in results]), HTTP_200_OK