Skip to content

Commit dcc4b30

Browse files
Add failing tests for formula composition
Signed-off-by: Matthias Wende <[email protected]>
1 parent d47c657 commit dcc4b30

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tests/timeseries/_formula_engine/test_formula_composition.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import math
88

9+
import pytest
910
from pytest_mock import MockerFixture
1011

1112
from frequenz.sdk import microgrid
@@ -219,6 +220,20 @@ async def test_formula_composition_constant(self, mocker: MockerFixture) -> None
219220
50.0,
220221
)
221222

223+
# Test multiplication with a Quantity
224+
with pytest.raises(RuntimeError):
225+
engine_assert = (
226+
logical_meter.grid_power * Power.from_watts(2.0) # type: ignore
227+
).build("grid_power_multiplication")
228+
await engine_assert.new_receiver().receive()
229+
230+
# Test addition with a float
231+
with pytest.raises(RuntimeError):
232+
engine_assert = (logical_meter.grid_power + 2.0).build( # type: ignore
233+
"grid_power_multiplication"
234+
)
235+
await engine_assert.new_receiver().receive()
236+
222237
await engine_add._stop() # pylint: disable=protected-access
223238
await engine_sub._stop() # pylint: disable=protected-access
224239
await engine_mul._stop() # pylint: disable=protected-access

0 commit comments

Comments
 (0)