def get(self, name): """ Possible to search with wild card also /products/na*. If star is is missing then the exact match will be searched """ try: if name.endswith('*'): result = [ i for i in DatabaseInterface.search_product_by_substring( name[:-1]) ] if not result: abort(404, message="Product with name {} does not exist".format( name)) return result else: return DatabaseInterface.search_product_by_name(name) except ProductNotFoundException: abort(404, message="Product with name {} does not exist".format(name))
def test_search_product_by_substring_not_found(cls): cls._create_dummy_basket() result = [ p for p in DatabaseInterface.search_product_by_substring('ka') ] assert not result