Skip to content

Commit

Permalink
fix: add __str__ for configuration and add debug log
Browse files Browse the repository at this point in the history
muhlba91 committed Dec 15, 2023
1 parent c43a8e6 commit 4659ee3
Showing 3 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions custom_components/hella_onyx/__init__.py
Original file line number Diff line number Diff line change
@@ -88,6 +88,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
fingerprint,
token,
)
_LOGGER.debug("using config: %s", onyx_config)
onyx_api = APIConnector(hass, onyx_config)
await onyx_api.async_config_entry_first_refresh()
onyx_timezone = await onyx_api.get_timezone()
3 changes: 3 additions & 0 deletions custom_components/hella_onyx/configuration.py
Original file line number Diff line number Diff line change
@@ -20,3 +20,6 @@ def __init__(
self.force_update = force_update
self.fingerprint = fingerprint
self.token = token

def __str__(self) -> str:
return f"Configuration(scan_interval={self.scan_interval}, min_dim_duration={self.min_dim_duration}, max_dim_duration={self.max_dim_duration}, force_update={self.force_update}, fingerprint={self.fingerprint})"
14 changes: 14 additions & 0 deletions tests/test_configuration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""Test for the ONYX Configuration."""
import pytest

from custom_components.hella_onyx.configuration import Configuration


class TestConfiguration:
@pytest.mark.asyncio
async def test_str(self):
config = Configuration(1, 2, 3, False, "finger", "token")
assert (
str(config)
== "Configuration(scan_interval=1, min_dim_duration=2, max_dim_duration=3, force_update=False, fingerprint=finger)"
)

0 comments on commit 4659ee3

Please sign in to comment.