def add_preference(self, preferencesToAdd): ingredientsExistence = tools.checkIfIngredientsExist(preferencesToAdd) res = [[], [], []] res[2] = ingredientsExistence[1] for preference in ingredientsExistence[0]: if not (preference in self.preferences): self.preferences.append(preference) res[0].append(preference) else: res[1].append(preference) # add row in csv file data base tools.addInFile(self, User_Profil.resource_file_path, 'preferences', ingredientsExistence[0]) return res
def remove_ingredients_fridge(self, ingredients_to_remove): ingredientsExistence = tools.checkIfIngredientsExist( ingredients_to_remove) res = [[], [], []] res[2] = ingredientsExistence[1] for ingredient in ingredientsExistence[0]: if ingredient in self.frigo.get_content(): self.frigo.remove_ingredient(ingredient) res[0].append(ingredient) else: res[1].append(ingredient) tools.removeInFile(self, User_Profil.resource_file_fridge_path, 'content', ingredientsExistence[0]) return res
def add_ingredients_fridge(self, ingredients_to_add): ingredientsExistence = tools.checkIfIngredientsExist( ingredients_to_add) res = [[], [], []] res[2] = ingredientsExistence[1] for ingredient in ingredientsExistence[0]: if not (ingredient in self.frigo.get_content()): self.frigo.add_in_fridge(ingredient) res[0].append(ingredient) else: res[1].append(ingredient) # add row in csv file data base tools.addInFile(self, User_Profil.resource_file_fridge_path, 'content', ingredientsExistence[0]) return res
def add_allergies(self, allergiesToAdd): ingredientsExistence = tools.checkIfIngredientsExist(allergiesToAdd) res = [[], [], []] res[2] = ingredientsExistence[1] for allergie in ingredientsExistence[0]: if not (allergie in self.allergies): self.allergies.append(allergie) res[0].append(allergie) else: res[1].append(allergie) # add row in csv file data base tools.addInFile(self, User_Profil.resource_file_path, 'undesirable', ingredientsExistence[0]) return res
def remove_allergies(self, allergiesToRemove): ingredientsExistence = tools.checkIfIngredientsExist(allergiesToRemove) res = [[], [], []] res[2] = ingredientsExistence[1] # list of not found allergies to delete #not_found = [] for allergie in ingredientsExistence[0]: if allergie in self.allergies: self.allergies.remove(allergie) res[0].append(allergie) else: #not_found.append(allergie) res[1].append(allergie) # add row in csv file data base tools.removeInFile(self, User_Profil.resource_file_path, 'undesirable', ingredientsExistence[0]) return res
def remove_preferences(self, preferencesToRemove): ingredientsExistence = tools.checkIfIngredientsExist( preferencesToRemove) res = [[], [], []] res[2] = ingredientsExistence[1] # list of not found preferences to delete #not_found = [] for preference in ingredientsExistence[0]: if preference in self.preferences: self.preferences.remove(preference) res[0].append(preference) else: #not_found.append(preference) res[1].append(preference) # add row in csv file data base tools.removeInFile(self, User_Profil.resource_file_path, 'preferences', ingredientsExistence[0]) return res
def test_existance(self): res = tools.checkIfIngredientsExist(self.aliments_a_testes) self.assertTrue(len(res) == 2) self.assertTrue(len(res[0]) == 5) self.assertTrue(len(res[1]) == 3)
def test_ingredients_inexitants(self): res = tools.checkIfIngredientsExist(self.aliments_a_testes) for aliment in res[1]: self.assertTrue(aliment in self.aliments_inexistants)