Skip to content

Commit c876b5b

Browse files
committed
Updated test cases and scripts around releasing
1 parent 64a7b68 commit c876b5b

16 files changed

+85
-199
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) [year] [fullname]
3+
Copyright (c) 2023 Philipp Dörner
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# myPyllant Home Assistant Component
22

33
[![GitHub Release](https://img.shields.io/github/release/signalkraft/mypyllant-component.svg)](https://github.com/signalkraft/mypyllant-component/releases)
4-
[![License](https://img.shields.io/github/license/signalkraft/mypyllant-component.svg)](LICENSE)
4+
[![License](https://img.shields.io/github/license/signalkraft/mypyllant-component.svg)](https://github.com/signalkraft/mypyllant-component/blob/main/LICENSE)
55
![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/signalkraft/mypyllant-component/build-test.yaml)
66

77
Home Assistant component that interfaces with the myVAILLANT API (and branded versions of it, such as the MiGo Link app

custom_components/mypyllant/manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"iot_class": "cloud_polling",
1111
"issue_tracker": "https://github.com/signalkraft/mypyllant-component/issues",
1212
"requirements": [
13-
"myPyllant==0.9.0b1"
13+
"myPyllant==0.9.0"
1414
],
15-
"version": "v0.9.0b3"
15+
"version": "v0.9.0"
1616
}

dev-requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ PyYAML~=6.0.1
1010
types-PyYAML~=6.0.12.20240311
1111

1212
# Need specific versions
13-
pytest-homeassistant-custom-component==0.13.200
14-
myPyllant==0.9.0b1
13+
pytest-homeassistant-custom-component==0.13.202
14+
myPyllant==0.9.0
1515

1616
# Versions handled by pytest-homeassistant-custom-component
1717
freezegun

hacs.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{
22
"name": "MyVaillant",
33
"render_readme": true,
4-
"homeassistant": "2025.1.0b0"
4+
"homeassistant": "2025.1.0",
5+
"iot_class": "Cloud Polling",
6+
"zip_release": true,
7+
"filename": "mypyllant-component.zip"
58
}

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ addopts = """
1919
--cov=custom_components"""
2020
asyncio_mode = "auto"
2121
asyncio_default_fixture_loop_scope = "function"
22+
filterwarnings = ["ignore:Inheritance class CountingClientSession from ClientSession is discouraged:DeprecationWarning"]
2223

2324
[tool.mypy]
2425
python_version = "3.12"

scripts/release

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@ set -e
44

55
version="$(jq -r .version custom_components/mypyllant/manifest.json)"
66

7-
git push
8-
gh release create "$version" --draft --generate-notes
7+
git tag "$version"
8+
git push origin "$version"
9+
10+
echo "Open release job: $(gh run list -w release --json url --limit 1 | jq -r '.[].url')"

tests/conftest.py

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import uuid
21
from datetime import timedelta
32
from unittest import mock
43

54
import pytest
6-
from homeassistant import config_entries
75

86
from custom_components.mypyllant.coordinator import (
97
SystemCoordinator,
@@ -106,57 +104,3 @@ async def daily_data_coordinator_mock(hass, mocked_api) -> DailyDataCoordinator:
106104
) as entry:
107105
hass.data = {DOMAIN: {entry.entry_id: {}}}
108106
return DailyDataCoordinator(hass, mocked_api, entry, timedelta(seconds=10))
109-
110-
111-
class MockConfigEntry(config_entries.ConfigEntry):
112-
"""Helper for creating config entries that adds some defaults."""
113-
114-
def __init__(
115-
self,
116-
*,
117-
domain="test",
118-
data=None,
119-
version=1,
120-
entry_id=None,
121-
source=config_entries.SOURCE_USER,
122-
title="Mock Title",
123-
state=None,
124-
options={},
125-
discovery_keys={},
126-
pref_disable_new_entities=None,
127-
pref_disable_polling=None,
128-
unique_id=None,
129-
disabled_by=None,
130-
reason=None,
131-
minor_version=None,
132-
):
133-
"""Initialize a mock config entry."""
134-
kwargs = {
135-
"entry_id": entry_id or str(uuid.uuid4()),
136-
"domain": domain,
137-
"data": data or {},
138-
"pref_disable_new_entities": pref_disable_new_entities,
139-
"pref_disable_polling": pref_disable_polling,
140-
"options": options,
141-
"discovery_keys": discovery_keys,
142-
"version": version,
143-
"title": title,
144-
"unique_id": unique_id,
145-
"disabled_by": disabled_by,
146-
"minor_version": minor_version,
147-
}
148-
if source is not None:
149-
kwargs["source"] = source
150-
if state is not None:
151-
kwargs["state"] = state
152-
super().__init__(**kwargs)
153-
if reason is not None:
154-
self.reason = reason
155-
156-
def add_to_hass(self, hass):
157-
"""Test helper to add entry to hass."""
158-
hass.config_entries._entries[self.entry_id] = self
159-
160-
def add_to_manager(self, manager):
161-
"""Test helper to add entry to entry manager."""
162-
manager._entries[self.entry_id] = self

tests/test_binary_sensor.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
)
2121
from custom_components.mypyllant.utils import CircuitEntity
2222
from custom_components.mypyllant.const import DOMAIN
23-
from tests.conftest import MockConfigEntry, TEST_OPTIONS
24-
from tests.test_init import test_user_input
23+
from tests.utils import get_config_entry
2524

2625

2726
@pytest.mark.parametrize("test_data", list_test_data())
@@ -36,12 +35,7 @@ async def test_async_setup_binary_sensors(
3635
hass.data[DATA_INTEGRATIONS] = {}
3736
hass.data[DATA_REGISTRY] = EntityRegistry(hass)
3837
with mypyllant_aioresponses(test_data) as _:
39-
config_entry = MockConfigEntry(
40-
domain=DOMAIN,
41-
title="Mock Title",
42-
data=test_user_input,
43-
options=TEST_OPTIONS,
44-
)
38+
config_entry = get_config_entry()
4539
system_coordinator_mock.data = (
4640
await system_coordinator_mock._async_update_data()
4741
)

tests/test_calendar.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
DomesticHotWaterCirculationCalendar,
1919
AmbisenseCalendar,
2020
)
21-
from tests.conftest import MockConfigEntry, TEST_OPTIONS
22-
from tests.test_init import test_user_input
21+
from tests.utils import get_config_entry
2322

2423

2524
@pytest.mark.parametrize("test_data", list_test_data())
@@ -34,12 +33,7 @@ async def test_async_setup_calendar(
3433
hass.data[DATA_INTEGRATIONS] = {}
3534
hass.data[DATA_REGISTRY] = EntityRegistry(hass)
3635
with mypyllant_aioresponses(test_data) as _:
37-
config_entry = MockConfigEntry(
38-
domain=DOMAIN,
39-
title="Mock Title",
40-
data=test_user_input,
41-
options=TEST_OPTIONS,
42-
)
36+
config_entry = get_config_entry()
4337
system_coordinator_mock.data = (
4438
await system_coordinator_mock._async_update_data()
4539
)

tests/test_climate.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
)
2323
from custom_components.mypyllant.ventilation_climate import VentilationClimate
2424
from tests.utils import get_config_entry
25-
from tests.conftest import MockConfigEntry, TEST_OPTIONS
26-
from tests.test_init import test_user_input
2725

2826

2927
@pytest.mark.parametrize("test_data", list_test_data())
@@ -38,12 +36,7 @@ async def test_async_setup_climate(
3836
hass.data[DATA_INTEGRATIONS] = {}
3937
hass.data[DATA_REGISTRY] = EntityRegistry(hass)
4038
with mypyllant_aioresponses(test_data) as _:
41-
config_entry = MockConfigEntry(
42-
domain=DOMAIN,
43-
title="Mock Title",
44-
data=test_user_input,
45-
options=TEST_OPTIONS,
46-
)
39+
config_entry = get_config_entry()
4740
system_coordinator_mock.data = (
4841
await system_coordinator_mock._async_update_data()
4942
)
@@ -93,7 +86,6 @@ async def test_zone_climate(
9386
await climate.async_set_preset_mode(preset_mode=PRESET_NONE)
9487
system_coordinator_mock._debounced_refresh.async_cancel()
9588

96-
print(system_coordinator_mock.data[0].state["zones"])
9789
zone_state = system_coordinator_mock.data[0].state["zones"][0]
9890
if "currentRoomTemperature" in zone_state:
9991
assert isinstance(climate.current_temperature, float)

tests/test_init.py

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,21 @@
22
import logging
33
from unittest import mock
44

5-
import pytest
65
from homeassistant import data_entry_flow
76
from homeassistant.config_entries import SOURCE_USER
87
from homeassistant.core import HomeAssistant
9-
from homeassistant.helpers.entity_registry import DATA_REGISTRY, EntityRegistry
10-
from homeassistant.loader import DATA_COMPONENTS, DATA_INTEGRATIONS
8+
119
from myPyllant.api import MyPyllantAPI
12-
from myPyllant.tests.utils import list_test_data
10+
from myPyllant.tests.generate_test_data import DATA_DIR
11+
from myPyllant.tests.utils import load_test_data
1312

1413
from custom_components.mypyllant.const import DOMAIN
1514
from custom_components.mypyllant import async_setup_entry, async_unload_entry
1615
from custom_components.mypyllant.config_flow import DATA_SCHEMA
17-
from tests.conftest import TEST_OPTIONS, MockConfigEntry
16+
from tests.utils import get_config_entry, test_user_input
1817

1918
_LOGGER = logging.getLogger(__name__)
2019

21-
test_user_input = {
22-
"username": "username",
23-
"password": "password",
24-
"country": "germany",
25-
"brand": "vaillant",
26-
}
27-
2820

2921
async def test_flow_init(hass):
3022
"""Test the initial flow."""
@@ -63,26 +55,18 @@ async def test_user_flow_minimum_fields(hass: HomeAssistant):
6355
assert result["type"] == data_entry_flow.FlowResultType.FORM
6456

6557

66-
@pytest.mark.parametrize("test_data", list_test_data())
67-
@pytest.mark.skip(
68-
"Broke with upgrade to pytest-homeassistant-custom-component==0.13.142"
69-
)
7058
async def test_async_setup(
7159
hass,
7260
mypyllant_aioresponses,
7361
mocked_api: MyPyllantAPI,
74-
test_data,
7562
):
76-
hass.data[DATA_COMPONENTS] = {}
77-
hass.data[DATA_INTEGRATIONS] = {}
78-
hass.data[DATA_REGISTRY] = EntityRegistry(hass)
63+
test_data = load_test_data(DATA_DIR / "heatpump_heat_curve")
7964
with mypyllant_aioresponses(test_data) as _:
80-
config_entry = MockConfigEntry(
81-
domain=DOMAIN,
82-
title="Mock Title",
83-
data=test_user_input,
84-
options=TEST_OPTIONS,
85-
)
65+
config_entry = get_config_entry()
66+
config_entry.add_to_hass(hass)
67+
await hass.config_entries.async_setup(config_entry.entry_id)
68+
await hass.async_block_till_done()
69+
8670
mock.patch("myPyllant.api.MyPyllantAPI", mocked_api)
8771
result = await async_setup_entry(hass, config_entry)
8872
assert result, "Component did not setup successfully"

tests/test_sensor.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@
3434
SystemDeviceCurrentPowerSensor,
3535
)
3636
from custom_components.mypyllant.const import DOMAIN
37-
from tests.conftest import MockConfigEntry, TEST_OPTIONS
38-
from tests.test_init import test_user_input
37+
from tests.utils import get_config_entry
3938

4039

4140
@pytest.mark.parametrize("test_data", list_test_data())
@@ -50,12 +49,7 @@ async def test_create_system_sensors(
5049
hass.data[DATA_INTEGRATIONS] = {}
5150
hass.data[DATA_REGISTRY] = EntityRegistry(hass)
5251
with mypyllant_aioresponses(test_data) as _:
53-
config_entry = MockConfigEntry(
54-
domain=DOMAIN,
55-
title="Mock Title",
56-
data=test_user_input,
57-
options=TEST_OPTIONS,
58-
)
52+
config_entry = get_config_entry()
5953
system_coordinator_mock.data = (
6054
await system_coordinator_mock._async_update_data()
6155
)

0 commit comments

Comments
 (0)