@@ -32,26 +32,52 @@ def test_get_cocktail(self, db_commander: DatabaseCommander):
3232 def test_get_all_cocktails (self , db_commander : DatabaseCommander ):
3333 """Test the get_all_cocktails method."""
3434 cocktails = db_commander .get_all_cocktails ()
35- assert len (cocktails ) == 4
36- cocktail = cocktails [0 ]
37- assert cocktail .name == "Cuba Libre"
38- assert cocktail .alcohol == 11
39- assert cocktail .amount == 290
40- assert cocktail .enabled is True
41- assert cocktail .virgin_available is False
42- assert len (cocktail .ingredients ) == 2
35+ assert len (cocktails ) == 5
36+
37+ cuba_libre = next ((c for c in cocktails if c .name == "Cuba Libre" ), None )
38+ assert cuba_libre is not None
39+ assert cuba_libre .alcohol == 11
40+ assert cuba_libre .amount == 290
41+ assert cuba_libre .enabled is True
42+ assert cuba_libre .virgin_available is False
43+ assert len (cuba_libre .ingredients ) == 2
4344
4445 def test_get_possible_cocktails (self , db_commander : DatabaseCommander ):
4546 """Test the get_possible_cocktails method."""
4647 possible_cocktails = db_commander .get_possible_cocktails (max_hand_ingredients = 1 )
47- assert len (possible_cocktails ) == 2
48- assert possible_cocktails [0 ].name == "Cuba Libre"
48+ # Now we should have 3 possible cocktails: Cuba Libre, With Handadd, and Virgin Only Possible
49+ assert len (possible_cocktails ) == 3
50+ # Check that Cuba Libre is in the list
51+ cuba_libre = next ((c for c in possible_cocktails if c .name == "Cuba Libre" ), None )
52+ assert cuba_libre is not None
53+ assert cuba_libre .only_virgin is False
54+
55+ def test_get_possible_cocktail_virgin_only (self , db_commander : DatabaseCommander ):
56+ """Test that a cocktail that can only be made in virgin form is properly flagged."""
57+ possible_cocktails = db_commander .get_possible_cocktails (max_hand_ingredients = 1 )
58+
59+ virgin_only = next ((c for c in possible_cocktails if c .name == "Virgin Only Possible" ), None )
60+ assert virgin_only is not None
61+ assert virgin_only .only_virgin is True
62+
63+ # Verify that this cocktail has an alcoholic ingredient that's not available
64+ alcoholic_ingredients = [ing for ing in virgin_only .ingredients if ing .alcohol > 0 ]
65+ assert len (alcoholic_ingredients ) > 0
66+
67+ # Check that the virgin ingredients are available either via machine or hand
68+ virgin_ingredients = [ing for ing in virgin_only .ingredients if ing .alcohol == 0 ]
69+ assert len (virgin_ingredients ) > 0
70+
71+ for ing in virgin_ingredients :
72+ # Either the ingredient is connected to a bottle or it's in the available handadd list
73+ assert ing .bottle is not None or ing .id in db_commander .get_available_ids ()
4974
5075 def test_get_disabled_cocktails (self , db_commander : DatabaseCommander ):
5176 """Test that we can get only not enabled cocktails."""
5277 disabled_cocktails = db_commander .get_all_cocktails (status = "disabled" )
5378 assert len (disabled_cocktails ) == 1
54- assert disabled_cocktails [0 ].name == "Tequila Sunrise"
79+ tequila_sunrise = next ((c for c in disabled_cocktails if c .name == "Tequila Sunrise" ), None )
80+ assert tequila_sunrise is not None
5581
5682 def test_increment_recipe_counter (self , db_commander : DatabaseCommander ):
5783 """Test the increment_recipe_counter method."""
@@ -157,28 +183,31 @@ def test_get_ingredient(self, db_commander: DatabaseCommander):
157183 def test_get_all_ingredients (self , db_commander : DatabaseCommander ):
158184 """Test the get_all_ingredients method."""
159185 ingredients = db_commander .get_all_ingredients ()
160- assert len (ingredients ) == 6
161- ingredient = ingredients [1 ]
162- assert ingredient .name == "Cola"
163- assert ingredient .alcohol == 0
164- assert ingredient .bottle_volume == 1000
165- assert ingredient .fill_level == 0
166- assert ingredient .hand is False
167- assert ingredient .pump_speed == 100
186+ assert len (ingredients ) == 7
187+
188+ cola = next ((i for i in ingredients if i .name == "Cola" ), None )
189+ assert cola is not None
190+ assert cola .alcohol == 0
191+ assert cola .bottle_volume == 1000
192+ assert cola .fill_level == 0
193+ assert cola .hand is False
194+ assert cola .pump_speed == 100
168195
169196 def test_get_all_machine_ingredients (self , db_commander : DatabaseCommander ):
170197 """Test the get_all_machine_ingredients method."""
171198 ingredients = db_commander .get_all_ingredients (get_hand = False )
172- assert len (ingredients ) == 5
173- ingredient = ingredients [1 ]
174- assert ingredient .name == "Cola"
199+ assert len (ingredients ) == 6
200+
201+ cola = next ((i for i in ingredients if i .name == "Cola" ), None )
202+ assert cola is not None
175203
176204 def test_get_all_hand_ingredients (self , db_commander : DatabaseCommander ):
177205 """Test the get_all_hand_ingredients method."""
178206 ingredients = db_commander .get_all_ingredients (get_machine = False )
179207 assert len (ingredients ) == 1
180- ingredient = ingredients [0 ]
181- assert ingredient .name == "Blue Curacao"
208+
209+ blue_curacao = next ((i for i in ingredients if i .name == "Blue Curacao" ), None )
210+ assert blue_curacao is not None
182211
183212 def test_get_all_ingredients_return_empty_if_both_false (self , db_commander : DatabaseCommander ):
184213 """Test the get_all_ingredients method."""
0 commit comments