Skip to content

Commit 09e66c8

Browse files
authored
Merge pull request #815 from plugwise/test_main
Improve testing
2 parents afc9a02 + 7fce160 commit 09e66c8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+5808
-5906
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## Ongoing
4+
5+
- Improve testing: compare internal and code testcounters, line up fixture and test-json format, fix a missed count.
6+
37
## v1.9.0
48

59
- Add support for Anna P1 via PR [#809](https://github.com/plugwise/python-plugwise/pull/809)

plugwise/data.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ def _update_for_cooling(self, entity: GwEntityData) -> None:
129129
and entity["dev_class"] == "thermostat"
130130
):
131131
thermostat = entity["thermostat"]
132-
sensors = entity["sensors"]
133132
temp_dict: ActuatorData = {
134133
"setpoint_low": thermostat["setpoint"],
135134
"setpoint_high": MAX_SETPOINT,
@@ -139,14 +138,21 @@ def _update_for_cooling(self, entity: GwEntityData) -> None:
139138
"setpoint_low": MIN_SETPOINT,
140139
"setpoint_high": thermostat["setpoint"],
141140
}
142-
thermostat.pop("setpoint")
141+
thermostat.pop("setpoint") # Add 2 keys, remove 1
143142
temp_dict.update(thermostat)
144143
entity["thermostat"] = temp_dict
145-
if "setpoint" in sensors:
146-
sensors.pop("setpoint")
144+
145+
sensors = entity["sensors"]
147146
sensors["setpoint_low"] = temp_dict["setpoint_low"]
148147
sensors["setpoint_high"] = temp_dict["setpoint_high"]
149-
self._count += 2 # add 4, remove 2
148+
# Add 2 more keys, remove 1 when required
149+
if "setpoint" in sensors:
150+
sensors.pop("setpoint")
151+
self._count -= 1
152+
153+
self._count += (
154+
3 # add 4 total, remove 1, count the conditional remove separately
155+
)
150156

151157
def _get_location_data(self, loc_id: str) -> GwEntityData:
152158
"""Helper-function for _all_entity_data() and async_update().
@@ -164,8 +170,9 @@ def _get_location_data(self, loc_id: str) -> GwEntityData:
164170
):
165171
data["control_state"] = str(ctrl_state)
166172

167-
data["sensors"].pop("setpoint") # remove, only used in _control_state()
168-
self._count -= 1
173+
if "setpoint" in data["sensors"]:
174+
data["sensors"].pop("setpoint") # remove, only used in _control_state()
175+
self._count -= 1
169176

170177
# Thermostat data (presets, temperatures etc)
171178
self._climate_data(loc_id, zone, data)
@@ -238,6 +245,7 @@ def _get_adam_data(self, entity: GwEntityData, data: GwEntityData) -> None:
238245
and self._cooling_present
239246
):
240247
data["binary_sensors"]["cooling_enabled"] = self._cooling_enabled
248+
self._count += 1
241249

242250
# Show the allowed regulation_modes and gateway_modes
243251
if entity["dev_class"] == "gateway":

scripts/tests_and_coverage.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ set +u
5858

5959
if [ -z "${GITHUB_ACTIONS}" ] || [ "$1" == "test_and_coverage" ] ; then
6060
# Python tests (rerun with debug if failures)
61-
PYTHONPATH=$(pwd) pytest -qx tests/ --cov='.' --no-cov-on-fail --cov-report term-missing || PYTHONPATH=$(pwd) pytest -xrpP --log-level debug tests/
61+
# PYTHONPATH=$(pwd) pytest -qx tests/ --cov='.' --no-cov-on-fail --cov-report term-missing ||
62+
PYTHONPATH=$(pwd) pytest -xrpP --log-level debug tests/
6263
handle_command_error "python code testing"
6364
fi
6465

0 commit comments

Comments
 (0)