Skip to content

Commit 3f561a8

Browse files
tests: clarify inverter mode contract coverage (#334)
1 parent d26920a commit 3f561a8

2 files changed

Lines changed: 21 additions & 12 deletions

File tree

tests/batcontrol/inverter/test_dummy.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@
66

77

88
class TestDummyInverter:
9-
"""Test the Dummy inverter implementation"""
9+
"""Test the Dummy inverter implementation.
10+
11+
These tests are implementation-specific, but they also act as one anchor
12+
for the shared inverter mode semantics expected from backend
13+
implementations.
14+
"""
1015

1116
def test_dummy_initialization(self):
1217
"""Test that dummy inverter initializes with correct default values"""
@@ -19,8 +24,8 @@ def test_dummy_initialization(self):
1924
assert dummy.min_soc == 10
2025
assert dummy.max_soc == 95
2126

22-
def test_dummy_mode_changes(self):
23-
"""Test that mode changes work correctly"""
27+
def test_dummy_implements_expected_inverter_mode_semantics(self):
28+
"""Test that Dummy implements the expected shared inverter mode semantics."""
2429
config = {'max_grid_charge_rate': 5000}
2530
dummy = Dummy(config)
2631

tests/batcontrol/inverter/test_mqtt_inverter.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66

77

88
class TestMqttInverter:
9-
"""Test the MQTT inverter implementation"""
9+
"""Test the MQTT inverter implementation.
10+
11+
These tests are implementation-specific, but they also make the shared
12+
inverter command semantics explicit for MQTT-backed control.
13+
"""
1014

1115
def test_mqtt_inverter_initialization(self):
1216
"""Test that MQTT inverter initializes with correct configuration"""
@@ -177,8 +181,8 @@ def test_mqtt_message_updates_max_charge_rate(self):
177181
# Verify max_charge_rate was updated
178182
assert inverter.max_grid_charge_rate == 6000
179183

180-
def test_set_mode_force_charge_publishes_command(self):
181-
"""Test that force charge mode publishes correct MQTT commands"""
184+
def test_force_charge_matches_inverter_mode_command_contract(self):
185+
"""Test that MQTT force charge matches the expected inverter command contract."""
182186
config = {
183187
'base_topic': 'inverter',
184188
'capacity': 10000,
@@ -207,8 +211,8 @@ def test_set_mode_force_charge_publishes_command(self):
207211
rate_call = call('inverter/command/charge_rate', '3000', qos=1, retain=False)
208212
assert rate_call in mock_client.publish.call_args_list
209213

210-
def test_set_mode_allow_discharge_publishes_command(self):
211-
"""Test that allow discharge mode publishes correct MQTT command"""
214+
def test_allow_discharge_matches_inverter_mode_command_contract(self):
215+
"""Test that MQTT allow discharge matches the expected inverter command contract."""
212216
config = {
213217
'base_topic': 'inverter',
214218
'capacity': 10000,
@@ -234,8 +238,8 @@ def test_set_mode_allow_discharge_publishes_command(self):
234238
retain=False
235239
)
236240

237-
def test_set_mode_avoid_discharge_publishes_command(self):
238-
"""Test that avoid discharge mode publishes correct MQTT command"""
241+
def test_avoid_discharge_matches_inverter_mode_command_contract(self):
242+
"""Test that MQTT avoid discharge matches the expected inverter command contract."""
239243
config = {
240244
'base_topic': 'inverter',
241245
'capacity': 10000,
@@ -261,8 +265,8 @@ def test_set_mode_avoid_discharge_publishes_command(self):
261265
retain=False
262266
)
263267

264-
def test_set_mode_limit_battery_charge_publishes_commands(self):
265-
"""Test that limit battery charge mode publishes correct MQTT commands"""
268+
def test_limit_battery_charge_matches_inverter_mode_command_contract(self):
269+
"""Test that MQTT limit battery charge matches the expected inverter command contract."""
266270
config = {
267271
'base_topic': 'inverter',
268272
'capacity': 10000,

0 commit comments

Comments
 (0)