def cli(self): Display.greeting() continu = True while continu: substitutes = self.database.get_substitute() self.control.substitution(substitutes) records_cat = self.database.get_infos_category() Display.display_categories(records_cat) choice = self.control.check_input( "\nChoose the index of one of the categories:", records_cat, ) records_prod = self.database.get_infos_product(choice) records_prod_cleaned = ProductsCleaned().clean(records_prod) sampling = Display.display_category_product( choice, records_cat, records_prod_cleaned) choice_prod = self.control.check_input( "\nChoose the index of one of the products:", sampling, ) records_prod = Display.display_products(choice_prod, records_prod_cleaned) choice_subs = self.control.check_input( "\nChoose the index of a product to substitute: ", records_prod, ) selec = [(1, 1), (2, 2)] choice = self.control.check_input( "\nDo you want to register this substitute " "in the database?\n\n1:no\n2:yes\n\nYour answer: ", selec, ) if choice == 2: self.database.update_data(choice_prod, choice_subs) else: pass choice = self.control.check_input( "\nDo you want to search other products?" "\n\n1:no\n2:yes\n\nYour answer: ", selec, ) if choice == 1: self.database.cursor.close() break
def test_display_products(): database = Db() display = Display() rec_prod = [ ( 31, "Ice Tea saveur Pêche", "d", 82, "Auchan", "https://fr-en.openfoodfacts.org/product/7622210601988/yahourt", ), ( 32, "Ice Tea pêche", "d", 82, "Auchan", "https://fr-en.openfoodfacts.org/product/7622210601988/yahourt", ), ( 33, "Thé glacé pêche intense", "d", 79, "Auchan", "https://fr-en.openfoodfacts.org/product/7622210601988/yahourt", ), ( 34, "Thé infusé glacé, Thé noir parfum pêche blanche", "d", 84, "Auchan", "https://fr-en.openfoodfacts.org/product/7622210601988/yahourt", ), ( 35, "Thé vert infusé glacé saveur Menthe", "d", 84, "Auchan", "https://fr-en.openfoodfacts.org/product/7622210601988/yahourt", ), ( 36, "Thé noir évasion pêche & saveur hibiscus", "d", 79, "Auchan", "https://fr-en.openfoodfacts.org/product/7622210601988/yahourt", ), ( 37, "Thé glacé pêche intense", "d", 79, "Auchan", "https://fr-en.openfoodfacts.org/product/7622210601988/yahourt", ), ( 38, "FROSTIES", "d", 1569, "Auchan", "https://fr-en.openfoodfacts.org/product/7622210601988/yahourt", ), ( 39, "Sucre glace", "d", 1674, "Auchan", "https://fr-en.openfoodfacts.org/product/7622210601988/yahourt", ), ( 40, "fuze tea pêche intense (thé glacé)", "d", 79, "Auchan", "https://fr-en.openfoodfacts.org/product/7622210601988/yahourt", ), ] prod_displayed = display.display_products(38, rec_prod) for prod in prod_displayed: assert prod[0] != 38