Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/bsblan/_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ def get_section_params(self, section: SectionLiteral) -> dict[str, str]:
dict[str, str]: Mapping of parameter id to parameter name.

"""
if not self._api_validator:
raise BSBLANError(ErrorMsg.API_VALIDATOR_NOT_INITIALIZED)

return cast("APIValidator", self._api_validator).get_section_params(section)

def apply_bus_specific_api_config(
Expand Down
12 changes: 12 additions & 0 deletions tests/test_api_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,18 @@ async def test_validate_api_section_no_validator() -> None:
await bsblan._validator._validate_api_section("device")


@pytest.mark.asyncio
async def test_get_section_params_no_validator() -> None:
"""Test section parameter lookup with no validator initialized."""
async with aiohttp.ClientSession() as session:
bsblan = BSBLAN(BSBLANConfig(host="example.com"), session=session)

bsblan._validator._api_validator = None

with pytest.raises(BSBLANError, match=ErrorMsg.API_VALIDATOR_NOT_INITIALIZED):
bsblan._validator.get_section_params("device")


@pytest.mark.asyncio
async def test_validate_api_section_no_api_data() -> None:
"""Test API section validation with no API data initialized."""
Expand Down