|
1 | 1 | from unittest.mock import ANY, MagicMock, patch |
2 | 2 |
|
| 3 | +import pytest |
| 4 | + |
3 | 5 | from src.config.config_manager import CONFIG |
4 | 6 | from src.config.config_types import PumpConfig |
5 | 7 | from src.machine.controller import MachineController, _build_preparation_data, _PreparationData |
@@ -63,13 +65,13 @@ def test_build_preparation_data(self): |
63 | 65 | # Verify results |
64 | 66 | assert len(prep_data) == 2 |
65 | 67 | assert prep_data[0].pin == 1 |
66 | | - assert prep_data[0].volume_flow == 10.0 |
67 | | - assert prep_data[0].flow_time == 10.0 # 100ml / 10ml/s |
| 68 | + assert prep_data[0].volume_flow == pytest.approx(10.0) |
| 69 | + assert prep_data[0].flow_time == pytest.approx(10.0) # 100ml / 10ml/s |
68 | 70 | assert prep_data[0].recipe_order == 1 |
69 | 71 |
|
70 | 72 | assert prep_data[1].pin == 2 |
71 | | - assert prep_data[1].volume_flow == 10.0 # 20.0 * 0.5 (pump_speed 50%) |
72 | | - assert prep_data[1].flow_time == 20.0 # 200ml / 10ml/s |
| 73 | + assert prep_data[1].volume_flow == pytest.approx(10.0) # 20.0 * 0.5 (pump_speed 50%) |
| 74 | + assert prep_data[1].flow_time == pytest.approx(20.0) # 200ml / 10ml/s |
73 | 75 | assert prep_data[1].recipe_order == 2 |
74 | 76 |
|
75 | 77 | finally: |
@@ -166,8 +168,8 @@ def test_start_preparation(self, mock_time): |
166 | 168 | current_time, max_time = mc._start_preparation(None, prep_data, True) |
167 | 169 |
|
168 | 170 | # Verify the method worked correctly |
169 | | - assert max_time == 2.0 # 1.0s + 1.0s for the two ingredients |
170 | | - assert current_time == 2.0 # Last time value from our mock |
| 171 | + assert max_time == pytest.approx(2.0) # 1.0s + 1.0s for the two ingredients |
| 172 | + assert current_time == pytest.approx(2.0) # Last time value from our mock |
171 | 173 |
|
172 | 174 | # Verify _start_pumps was called for both chunks with correct pins |
173 | 175 | assert mc._start_pumps.call_count == 2 |
|
0 commit comments