Skip to content

Commit

Permalink
Homee cover-test (#136563)
Browse files Browse the repository at this point in the history
initial cover-test
  • Loading branch information
Taraman17 authored Jan 26, 2025
1 parent 3adbf75 commit 93a231f
Show file tree
Hide file tree
Showing 7 changed files with 551 additions and 10 deletions.
12 changes: 12 additions & 0 deletions tests/components/homee/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
"""Tests for the homee component."""

from homeassistant.core import HomeAssistant

from tests.common import MockConfigEntry


async def setup_integration(hass: HomeAssistant, config_entry: MockConfigEntry) -> None:
"""Set up the component."""
config_entry.add_to_hass(hass)

await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
21 changes: 11 additions & 10 deletions tests/components/homee/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@
TESTPASS = "testpass"


@pytest.fixture
def mock_setup_entry() -> Generator[AsyncMock]:
"""Mock setting up a config entry."""
with patch(
"homeassistant.components.homee.async_setup_entry", return_value=True
) as mock_setup:
yield mock_setup


@pytest.fixture
def mock_config_entry() -> MockConfigEntry:
"""Return the default mocked config entry."""
Expand All @@ -32,15 +41,6 @@ def mock_config_entry() -> MockConfigEntry:
)


@pytest.fixture
def mock_setup_entry() -> Generator[AsyncMock]:
"""Mock setting up a config entry."""
with patch(
"homeassistant.components.homee.async_setup_entry", return_value=True
) as mock_setup:
yield mock_setup


@pytest.fixture
def mock_homee() -> Generator[AsyncMock]:
"""Return a mock Homee instance."""
Expand All @@ -50,7 +50,7 @@ def mock_homee() -> Generator[AsyncMock]:
) as mocked_homee,
patch(
"homeassistant.components.homee.Homee",
autospec=True,
new=mocked_homee,
),
):
homee = mocked_homee.return_value
Expand All @@ -62,6 +62,7 @@ def mock_homee() -> Generator[AsyncMock]:
homee.settings.uid = HOMEE_ID
homee.settings.homee_name = HOMEE_NAME
homee.reconnect_interval = 10
homee.connected = True

homee.get_access_token.return_value = "test_token"

Expand Down
101 changes: 101 additions & 0 deletions tests/components/homee/fixtures/cover1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
{
"id": 3,
"name": "Test%20Cover",
"profile": 2002,
"image": "default",
"favorite": 0,
"order": 4,
"protocol": 23,
"routing": 0,
"state": 1,
"state_changed": 1687175681,
"added": 1672086680,
"history": 1,
"cube_type": 14,
"note": "TestCoverDevice",
"services": 7,
"phonetic_name": "",
"owner": 2,
"security": 0,
"attributes": [
{
"id": 1,
"node_id": 3,
"instance": 0,
"minimum": 0,
"maximum": 4,
"current_value": 1.0,
"target_value": 1.0,
"last_value": 4.0,
"unit": "n%2Fa",
"step_value": 1.0,
"editable": 1,
"type": 135,
"state": 1,
"last_changed": 1687175680,
"changed_by": 1,
"changed_by_id": 0,
"based_on": 1,
"data": "",
"name": "",
"options": {
"can_observe": [300],
"observes": [75],
"automations": ["toggle"]
}
},
{
"id": 2,
"node_id": 3,
"instance": 0,
"minimum": 0,
"maximum": 100,
"current_value": 0.0,
"target_value": 0.0,
"last_value": 0.0,
"unit": "%25",
"step_value": 0.5,
"editable": 1,
"type": 15,
"state": 1,
"last_changed": 1687175680,
"changed_by": 1,
"changed_by_id": 0,
"based_on": 1,
"data": "",
"name": "",
"options": {
"automations": ["step"],
"history": {
"day": 35,
"week": 5,
"month": 1
}
}
},
{
"id": 3,
"node_id": 3,
"instance": 0,
"minimum": -45,
"maximum": 90,
"current_value": -45.0,
"target_value": 0.0,
"last_value": -45.0,
"unit": "%C2%B0",
"step_value": 1.0,
"editable": 1,
"type": 113,
"state": 1,
"last_changed": 1678284920,
"changed_by": 1,
"changed_by_id": 0,
"based_on": 1,
"data": "",
"name": "",
"options": {
"automations": ["step"]
}
}
]
}
101 changes: 101 additions & 0 deletions tests/components/homee/fixtures/cover2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
{
"id": 1,
"name": "Test%20Cover",
"profile": 2002,
"image": "default",
"favorite": 0,
"order": 4,
"protocol": 23,
"routing": 0,
"state": 1,
"state_changed": 1687175681,
"added": 1672086680,
"history": 1,
"cube_type": 14,
"note": "TestCoverDevice",
"services": 7,
"phonetic_name": "",
"owner": 2,
"security": 0,
"attributes": [
{
"id": 1,
"node_id": 1,
"instance": 0,
"minimum": 0,
"maximum": 4,
"current_value": 1.0,
"target_value": 1.0,
"last_value": 0.0,
"unit": "n%2Fa",
"step_value": 1.0,
"editable": 1,
"type": 135,
"state": 1,
"last_changed": 1687175680,
"changed_by": 1,
"changed_by_id": 0,
"based_on": 1,
"data": "",
"name": "",
"options": {
"can_observe": [300],
"observes": [75],
"automations": ["toggle"]
}
},
{
"id": 2,
"node_id": 1,
"instance": 0,
"minimum": 0,
"maximum": 100,
"current_value": 100.0,
"target_value": 0.0,
"last_value": 0.0,
"unit": "%25",
"step_value": 0.5,
"editable": 1,
"type": 15,
"state": 1,
"last_changed": 1687175680,
"changed_by": 1,
"changed_by_id": 0,
"based_on": 1,
"data": "",
"name": "",
"options": {
"automations": ["step"],
"history": {
"day": 35,
"week": 5,
"month": 1
}
}
},
{
"id": 3,
"node_id": 1,
"instance": 0,
"minimum": -45,
"maximum": 90,
"current_value": 90.0,
"target_value": 0.0,
"last_value": -45.0,
"unit": "%C2%B0",
"step_value": 1.0,
"editable": 1,
"type": 113,
"state": 1,
"last_changed": 1678284920,
"changed_by": 1,
"changed_by_id": 0,
"based_on": 1,
"data": "",
"name": "",
"options": {
"automations": ["step"]
}
}
]
}
101 changes: 101 additions & 0 deletions tests/components/homee/fixtures/cover3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
{
"id": 3,
"name": "Test%20Cover",
"profile": 2002,
"image": "default",
"favorite": 0,
"order": 4,
"protocol": 23,
"routing": 0,
"state": 1,
"state_changed": 1687175681,
"added": 1672086680,
"history": 1,
"cube_type": 14,
"note": "TestCoverDevice",
"services": 7,
"phonetic_name": "",
"owner": 2,
"security": 0,
"attributes": [
{
"id": 1,
"node_id": 3,
"instance": 0,
"minimum": 0,
"maximum": 4,
"current_value": 3.0,
"target_value": 0.0,
"last_value": 1.0,
"unit": "n%2Fa",
"step_value": 1.0,
"editable": 1,
"type": 135,
"state": 1,
"last_changed": 1687175680,
"changed_by": 1,
"changed_by_id": 0,
"based_on": 1,
"data": "",
"name": "",
"options": {
"can_observe": [300],
"observes": [75],
"automations": ["toggle"]
}
},
{
"id": 2,
"node_id": 3,
"instance": 0,
"minimum": 0,
"maximum": 100,
"current_value": 75.0,
"target_value": 0.0,
"last_value": 100.0,
"unit": "%25",
"step_value": 0.5,
"editable": 1,
"type": 15,
"state": 1,
"last_changed": 1687175680,
"changed_by": 1,
"changed_by_id": 0,
"based_on": 1,
"data": "",
"name": "",
"options": {
"automations": ["step"],
"history": {
"day": 35,
"week": 5,
"month": 1
}
}
},
{
"id": 3,
"node_id": 3,
"instance": 0,
"minimum": -45,
"maximum": 90,
"current_value": 56.0,
"target_value": 56.0,
"last_value": 0.0,
"unit": "%C2%B0",
"step_value": 1.0,
"editable": 1,
"type": 113,
"state": 1,
"last_changed": 1678284920,
"changed_by": 1,
"changed_by_id": 0,
"based_on": 1,
"data": "",
"name": "",
"options": {
"automations": ["step"]
}
}
]
}
Loading

0 comments on commit 93a231f

Please sign in to comment.