def on_get(self, req, resp): try: name, code, sortBy, minPrice, maxPrice, offset, limit, productIds = restUtils.getQueryParams(req) products = bl.getProducts( name = name, code = code, sortBy = sortBy, minPrice = minPrice, maxPrice = maxPrice, offset = offset, limit = limit, productIds = productIds ) result = {'products':products} print(result) resp.body = json.dumps(result, sort_keys=True, default=Product.serialize) resp.status = falcon.HTTP_200 #Status Ok except: #Return 500 - internal error resp.status = falcon.HTTP_500
def bl_getShopCartProducts(): print("Testing fetching products in shopcart..") a = bl.getProducts(userId=79) assert(a is not None) print(a)
def bl_getProductsJSON(): print("Testing json..") a = bl.getProducts() b = json.dumps(a, default = Product.serialize, sort_keys = True)