add validation check that choice options are correctly set

This commit is contained in:
mcbloch 2022-05-15 00:04:50 +02:00
parent b5202a9de6
commit 02d52f08dd

View file

@ -88,6 +88,12 @@ class Dish:
) )
def _sum_f_option_prices(self, f): def _sum_f_option_prices(self, f):
for (_, choice) in self.choices:
if len(choice.options) == 0:
print((f"[PARSE ERROR] At least 1 option expected in dish choice.\n"
f"\tDish:\t'{self.name}'\n"
f"\tChoice:\t'{choice.name}'\n"))
exit(1)
return sum( return sum(
f(option.price for option in choice.options) f(option.price for option in choice.options)
for (choice_type, choice) in self.choices for (choice_type, choice) in self.choices