mirror of
https://github.com/jpawlowski/hass.tibber_prices.git
synced 2026-03-30 05:13:40 +00:00
Address code review feedback: fix test logic and correct misleading comment
Co-authored-by: jpawlowski <75446+jpawlowski@users.noreply.github.com>
This commit is contained in:
parent
568fb219f2
commit
b790ee1f6c
2 changed files with 9 additions and 6 deletions
|
|
@ -404,7 +404,7 @@ async def handle_chartdata(call: ServiceCall) -> dict[str, Any]: # noqa: PLR091
|
||||||
chart_data.append(connect_point)
|
chart_data.append(connect_point)
|
||||||
else:
|
else:
|
||||||
# Price goes UP or stays same: Add hold point with current price
|
# Price goes UP or stays same: Add hold point with current price
|
||||||
# Then add connect point at next level with higher price
|
# This extends the current level to the boundary before the gap
|
||||||
hold_point = {
|
hold_point = {
|
||||||
start_time_field: next_start_serialized,
|
start_time_field: next_start_serialized,
|
||||||
price_field: converted_price,
|
price_field: converted_price,
|
||||||
|
|
|
||||||
|
|
@ -79,10 +79,12 @@ class TestConnectSegmentsOutput:
|
||||||
next_price = 0.12
|
next_price = 0.12
|
||||||
|
|
||||||
# With connect_segments=True and price going down:
|
# With connect_segments=True and price going down:
|
||||||
# The transition point should use next_price (lower price)
|
# The transition point should use next_price (the lower price)
|
||||||
transition_price = min(current_price, next_price)
|
# This draws the line downward from current segment level
|
||||||
|
is_price_going_down = next_price < current_price
|
||||||
|
transition_price = next_price # Use next price when going down
|
||||||
|
|
||||||
assert transition_price == next_price
|
assert is_price_going_down, "Price should be going down"
|
||||||
assert transition_price == 0.12
|
assert transition_price == 0.12
|
||||||
|
|
||||||
def test_transition_point_up_has_current_price(self) -> None:
|
def test_transition_point_up_has_current_price(self) -> None:
|
||||||
|
|
@ -96,9 +98,10 @@ class TestConnectSegmentsOutput:
|
||||||
|
|
||||||
# With connect_segments=True and price going up:
|
# With connect_segments=True and price going up:
|
||||||
# The hold point should use current_price (extend current level)
|
# The hold point should use current_price (extend current level)
|
||||||
hold_price = min(current_price, next_price)
|
is_price_going_up = next_price >= current_price
|
||||||
|
hold_price = current_price # Extend current level when going up
|
||||||
|
|
||||||
assert hold_price == current_price
|
assert is_price_going_up, "Price should be going up"
|
||||||
assert hold_price == 0.11
|
assert hold_price == 0.11
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue