From b790ee1f6c524cff0434f4df7edd4c749aa5bd90 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 1 Dec 2025 01:25:17 +0000 Subject: [PATCH] Address code review feedback: fix test logic and correct misleading comment Co-authored-by: jpawlowski <75446+jpawlowski@users.noreply.github.com> --- .../tibber_prices/services/get_chartdata.py | 2 +- tests/test_connect_segments.py | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/custom_components/tibber_prices/services/get_chartdata.py b/custom_components/tibber_prices/services/get_chartdata.py index 456afa1..4633c37 100644 --- a/custom_components/tibber_prices/services/get_chartdata.py +++ b/custom_components/tibber_prices/services/get_chartdata.py @@ -404,7 +404,7 @@ async def handle_chartdata(call: ServiceCall) -> dict[str, Any]: # noqa: PLR091 chart_data.append(connect_point) else: # 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 = { start_time_field: next_start_serialized, price_field: converted_price, diff --git a/tests/test_connect_segments.py b/tests/test_connect_segments.py index 49bcf03..3de6015 100644 --- a/tests/test_connect_segments.py +++ b/tests/test_connect_segments.py @@ -79,10 +79,12 @@ class TestConnectSegmentsOutput: next_price = 0.12 # With connect_segments=True and price going down: - # The transition point should use next_price (lower price) - transition_price = min(current_price, next_price) + # The transition point should use next_price (the lower 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 def test_transition_point_up_has_current_price(self) -> None: @@ -96,9 +98,10 @@ class TestConnectSegmentsOutput: # With connect_segments=True and price going up: # 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