def get_product_by_product_id(product_id): return m.find_product('product_id', product_id)
def get_product_by_name(product_name): return_dict = m.find_product('product_name', product_name) return return_dict
'product_id': 9, 'product_name': 'Jasmine Green Tea', 'description': 'With Jasmine Green Tea, enjoy your afternoon.', 'price': Decimal('25.99'), 'priority': 2 } assert c.get_product_by_product_id('9') == { 'product_id': 9, 'product_name': 'Jasmine Green Tea', 'description': 'With Jasmine Green Tea, enjoy your afternoon.', 'price': Decimal('25.99'), 'priority': 2 } assert c.add_product(product_name='Dummy', description='Dummy', categories=[1], price='24.99', priority='12') is None assert m.find_product(method='product_name', param='Dummy') == { 'product_id': 10, 'product_name': 'Dummy', 'description': 'Dummy', 'price': Decimal('24.99'), 'priority': 12 } assert len(c.get_all_products()) == 10 assert c.remove_product('10') is None assert len(c.get_all_products()) == 9 print(' ✓ Product has passed all the tests')
def get_products_by_id(product_id): return_dict = m.find_product('product_id', product_id) if len(return_dict) == 0: return [] return return_dict
def find_product(*args, **kwargs): from models.model_product import find_product return find_product(*args, **kwargs)