Replace internal v2/v3 selector with supports_full_config flag#1525
Conversation
Swap the runtime _api_version string for a _supports_full_config bool capability flag. VersionResolver.resolve_config_version is replaced by supports_full_config, and _set_api_version is renamed to _resolve_api_capabilities. _copy_api_config now selects API_V3/API_V2 from the flag and drops the obsolete version-string membership check. Tests are updated to set the boolean flag and assert capability instead of the v2/v3 label. Constant names (API_V2/API_V3) are intentionally kept for Stage 3.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1525 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 10 10
Lines 1236 1230 -6
Branches 142 140 -2
=========================================
- Hits 1236 1230 -6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
There was a problem hiding this comment.
Pull request overview
This PR refactors internal API-selection logic in BSBLAN by replacing the runtime _api_version string selector with a boolean capability flag (_supports_full_config). The intent is to drive API config selection solely from the device’s JSON-API version (/JV) and update tests accordingly.
Changes:
- Replace
_api_versionwith_supports_full_configand rename_set_api_version()→_resolve_api_capabilities(). - Update
_copy_api_config()to selectAPI_V3/API_V2based on the capability flag (and drop the string-membership validation path). - Update test suite to set/assert the boolean capability flag instead of
"v2"/"v3".
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/bsblan/bsblan.py |
Replaces version-string selection with capability-flag selection and updates initialization/config-copy logic accordingly. |
src/bsblan/_version.py |
Changes resolver API from returning "v2"/"v3" to returning a boolean capability (supports_full_config). |
tests/test_version_errors.py |
Updates version/capability tests to assert _supports_full_config and renamed resolver method. |
tests/test_initialization.py |
Updates initialization/config-copy tests to use _supports_full_config and removes unsupported-version test. |
tests/test_thermostat.py |
Updates fixture client setup to set _supports_full_config. |
tests/test_temperature_validation.py |
Updates tests to set _supports_full_config instead of _api_version. |
tests/test_static_state.py |
Updates monkeypatch to set _supports_full_config. |
tests/test_state.py |
Updates monkeypatch to set _supports_full_config. |
tests/test_sensor.py |
Updates monkeypatch to set _supports_full_config. |
tests/test_pps.py |
Updates test setup to set _supports_full_config. |
tests/test_info.py |
Updates test setup to set _supports_full_config. |
tests/test_include_parameter.py |
Updates test setup to set _supports_full_config. |
tests/test_hotwater_state.py |
Updates test setup to set _supports_full_config. |
tests/test_hot_water_additional.py |
Updates test setup to set _supports_full_config in multiple hot water tests. |
tests/test_circuit.py |
Updates test setup to set _supports_full_config. |
tests/test_bsblan_edge_cases.py |
Updates test setup to set _supports_full_config. |
tests/test_api_validation.py |
Updates validator-related tests to set _supports_full_config. |
tests/test_api_initialization.py |
Updates API initialization tests to use _supports_full_config. |
tests/conftest.py |
Updates shared fixture to set _supports_full_config. |
| if self._firmware_version is None: | ||
| device = await self.device() | ||
| self._firmware_version = device.version | ||
| logger.debug("BSBLAN version: %s", self._firmware_version) | ||
| await self._fetch_json_api_version() |
| try: | ||
| parsed = pkg_version.parse(json_api_version) | ||
| except InvalidVersion as exc: | ||
| raise BSBLANVersionError( | ||
| ErrorMsg.VERSION, version=json_api_version | ||
| ) from exc | ||
| if parsed < pkg_version.parse(self._json_api_minimum): | ||
| raise BSBLANVersionError(ErrorMsg.VERSION, version=json_api_version) | ||
| return parsed >= pkg_version.parse(self._json_api_v3_minimum) |
| async def test_copy_api_config_full() -> None: | ||
| """Test _copy_api_config when full config is supported.""" | ||
| async with aiohttp.ClientSession() as session: | ||
| bsblan = BSBLAN(BSBLANConfig(host="example.com"), session=session) | ||
| bsblan._api_version = "v1" | ||
|
|
||
| with pytest.raises(BSBLANVersionError): | ||
| bsblan._copy_api_config() | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_copy_api_config_v3() -> None: | ||
| """Test _copy_api_config with v3 version.""" | ||
| async with aiohttp.ClientSession() as session: | ||
| bsblan = BSBLAN(BSBLANConfig(host="example.com"), session=session) | ||
| bsblan._api_version = "v3" | ||
| bsblan._supports_full_config = True |



Swap the runtime _api_version string for a _supports_full_config bool capability flag. VersionResolver.resolve_config_version is replaced by supports_full_config, and _set_api_version is renamed to _resolve_api_capabilities. _copy_api_config now selects API_V3/API_V2 from the flag and drops the obsolete version-string membership check. Tests are updated to set the boolean flag and assert capability instead of the v2/v3 label. Constant names (API_V2/API_V3) are intentionally kept for Stage 3.