From 0030acb0eee5edf3e20c4ab1f040c8ed3b900282 Mon Sep 17 00:00:00 2001 From: Filip Lajszczak Date: Tue, 14 Apr 2026 07:04:46 +0000 Subject: [PATCH] tests: clarify inverter mode contract coverage --- tests/batcontrol/inverter/test_dummy.py | 11 +++++++--- .../batcontrol/inverter/test_mqtt_inverter.py | 22 +++++++++++-------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/tests/batcontrol/inverter/test_dummy.py b/tests/batcontrol/inverter/test_dummy.py index 97385b1..18c3f20 100644 --- a/tests/batcontrol/inverter/test_dummy.py +++ b/tests/batcontrol/inverter/test_dummy.py @@ -6,7 +6,12 @@ class TestDummyInverter: - """Test the Dummy inverter implementation""" + """Test the Dummy inverter implementation. + + These tests are implementation-specific, but they also act as one anchor + for the shared inverter mode semantics expected from backend + implementations. + """ def test_dummy_initialization(self): """Test that dummy inverter initializes with correct default values""" @@ -19,8 +24,8 @@ def test_dummy_initialization(self): assert dummy.min_soc == 10 assert dummy.max_soc == 95 - def test_dummy_mode_changes(self): - """Test that mode changes work correctly""" + def test_dummy_implements_expected_inverter_mode_semantics(self): + """Test that Dummy implements the expected shared inverter mode semantics.""" config = {'max_grid_charge_rate': 5000} dummy = Dummy(config) diff --git a/tests/batcontrol/inverter/test_mqtt_inverter.py b/tests/batcontrol/inverter/test_mqtt_inverter.py index ec02227..58adbc3 100644 --- a/tests/batcontrol/inverter/test_mqtt_inverter.py +++ b/tests/batcontrol/inverter/test_mqtt_inverter.py @@ -6,7 +6,11 @@ class TestMqttInverter: - """Test the MQTT inverter implementation""" + """Test the MQTT inverter implementation. + + These tests are implementation-specific, but they also make the shared + inverter command semantics explicit for MQTT-backed control. + """ def test_mqtt_inverter_initialization(self): """Test that MQTT inverter initializes with correct configuration""" @@ -177,8 +181,8 @@ def test_mqtt_message_updates_max_charge_rate(self): # Verify max_charge_rate was updated assert inverter.max_grid_charge_rate == 6000 - def test_set_mode_force_charge_publishes_command(self): - """Test that force charge mode publishes correct MQTT commands""" + def test_force_charge_matches_inverter_mode_command_contract(self): + """Test that MQTT force charge matches the expected inverter command contract.""" config = { 'base_topic': 'inverter', 'capacity': 10000, @@ -207,8 +211,8 @@ def test_set_mode_force_charge_publishes_command(self): rate_call = call('inverter/command/charge_rate', '3000', qos=1, retain=False) assert rate_call in mock_client.publish.call_args_list - def test_set_mode_allow_discharge_publishes_command(self): - """Test that allow discharge mode publishes correct MQTT command""" + def test_allow_discharge_matches_inverter_mode_command_contract(self): + """Test that MQTT allow discharge matches the expected inverter command contract.""" config = { 'base_topic': 'inverter', 'capacity': 10000, @@ -234,8 +238,8 @@ def test_set_mode_allow_discharge_publishes_command(self): retain=False ) - def test_set_mode_avoid_discharge_publishes_command(self): - """Test that avoid discharge mode publishes correct MQTT command""" + def test_avoid_discharge_matches_inverter_mode_command_contract(self): + """Test that MQTT avoid discharge matches the expected inverter command contract.""" config = { 'base_topic': 'inverter', 'capacity': 10000, @@ -261,8 +265,8 @@ def test_set_mode_avoid_discharge_publishes_command(self): retain=False ) - def test_set_mode_limit_battery_charge_publishes_commands(self): - """Test that limit battery charge mode publishes correct MQTT commands""" + def test_limit_battery_charge_matches_inverter_mode_command_contract(self): + """Test that MQTT limit battery charge matches the expected inverter command contract.""" config = { 'base_topic': 'inverter', 'capacity': 10000,