Skip to content

Replace internal v2/v3 selector with supports_full_config flag#1525

Merged
liudger merged 1 commit into
mainfrom
refactor/drop-api-version-stage-2
Jun 8, 2026
Merged

Replace internal v2/v3 selector with supports_full_config flag#1525
liudger merged 1 commit into
mainfrom
refactor/drop-api-version-stage-2

Conversation

@liudger

@liudger liudger commented Jun 8, 2026

Copy link
Copy Markdown
Owner

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.

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.
Copilot AI review requested due to automatic review settings June 8, 2026 14:35
@liudger liudger added the refactor Improvement of existing code, not introducing new features. label Jun 8, 2026
@codecov

codecov Bot commented Jun 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (7263e2b) to head (22486a3).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sonarqubecloud

sonarqubecloud Bot commented Jun 8, 2026

Copy link
Copy Markdown

@liudger liudger merged commit 664f4eb into main Jun 8, 2026
18 checks passed
@liudger liudger deleted the refactor/drop-api-version-stage-2 branch June 8, 2026 14:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_version with _supports_full_config and rename _set_api_version()_resolve_api_capabilities().
  • Update _copy_api_config() to select API_V3/API_V2 based 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.

Comment thread src/bsblan/bsblan.py
Comment on lines 343 to 347
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()
Comment thread src/bsblan/_version.py
Comment on lines +69 to +77
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)
Comment on lines +23 to +27
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
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 10, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

refactor Improvement of existing code, not introducing new features.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants