Skip to content

Commit be9dae8

Browse files
authored
DHCP ServiceInfo deprecation in 2025.2 (#74)
* DHCP ServiceInfo deprecation in 2025.2 * Bump pytest-homeassistant-custom-component Need to bump to 2025.2 * Linting * Bump to Python 3.13 * Fix deprecated imports Removed in home-assistant/core#131843 * More deprecated constants home-assistant/core#131799 * And more deprecated constants * And some more deprecation * Wrong update * reauth flow changes https://developers.home-assistant.io/blog/2024/11/04/reauth-reconfigure-entry-id/ * fix async issue * Revert "fix async issue" This reverts commit da0ec80. * Revert "reauth flow changes" This reverts commit ff476cd. * Revert pytest-homeassistant-custom-component to earlier version * Got reauth test to work
1 parent e1b4aa1 commit be9dae8

File tree

10 files changed

+41
-43
lines changed

10 files changed

+41
-43
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Pod Point integration development",
3-
"image": "mcr.microsoft.com/devcontainers/python:3.12-bullseye",
3+
"image": "mcr.microsoft.com/devcontainers/python:3.13-bullseye",
44
"postCreateCommand": "scripts/setup",
55
"forwardPorts": [
66
8123

.github/workflows/pull.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- uses: "actions/checkout@v2"
2626
- uses: "actions/setup-python@v1"
2727
with:
28-
python-version: "3.12"
28+
python-version: "3.13"
2929
- run: python3 -m pip install black
3030
- run: black .
3131

@@ -38,7 +38,7 @@ jobs:
3838
- name: Setup Python
3939
uses: "actions/setup-python@v1"
4040
with:
41-
python-version: "3.12"
41+
python-version: "3.13"
4242
- name: Install requirements
4343
run: python3 -m pip install -r requirements_test.txt -r requirements.txt
4444
- name: Run tests

.github/workflows/push.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- uses: "actions/checkout@v2"
2626
- uses: "actions/setup-python@v1"
2727
with:
28-
python-version: "3.12"
28+
python-version: "3.13"
2929
- run: python3 -m pip install black
3030
- run: black .
3131

@@ -38,7 +38,7 @@ jobs:
3838
- name: Setup Python
3939
uses: "actions/setup-python@v1"
4040
with:
41-
python-version: "3.12"
41+
python-version: "3.13"
4242
- name: Install requirements
4343
run: python3 -m pip install -r requirements_test.txt -r requirements.txt
4444
- name: Run tests

custom_components/pod_point/config_flow.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from typing import Dict
55

66
from homeassistant import config_entries
7-
from homeassistant.components import dhcp
7+
from homeassistant.helpers.service_info.dhcp import DhcpServiceInfo
88
from homeassistant.core import callback
99
from homeassistant.data_entry_flow import FlowResult
1010
from homeassistant.helpers.aiohttp_client import async_create_clientsession
@@ -91,7 +91,7 @@ async def async_step_user(self, user_input: Dict[str, str] = None) -> FlowResult
9191
def async_get_options_flow(config_entry) -> FlowResult:
9292
return PodPointOptionsFlowHandler(config_entry)
9393

94-
async def async_step_dhcp(self, discovery_info: dhcp.DhcpServiceInfo) -> FlowResult:
94+
async def async_step_dhcp(self, discovery_info: DhcpServiceInfo) -> FlowResult:
9595
formatted_mac = format_mac(discovery_info.macaddress)
9696
_LOGGER.info("Found PodPoint device with mac %s", formatted_mac)
9797

hacs.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"name": "Pod Point",
33
"country": "GB",
44
"hacs": "1.6.0",
5-
"homeassistant": "2024.11.0"
5+
"homeassistant": "2025.2.0"
66
}

requirements_test.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
pytest-homeassistant-custom-component>=0.12.57
1+
pytest-homeassistant-custom-component>=0.13.210
22
pytest-asyncio
3-
aiodhcpwatcher
3+
aiodhcpwatcher

tests/test_config_flow.py

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
from types import MappingProxyType
44
from unittest.mock import patch
55

6-
from homeassistant import config_entries, data_entry_flow
7-
from homeassistant.components import dhcp
6+
from homeassistant import config_entries
7+
from homeassistant.data_entry_flow import FlowResultType
8+
from homeassistant.helpers.service_info import dhcp
89
from homeassistant.core import HomeAssistant
910
import pytest
1011
from pytest_homeassistant_custom_component.common import MockConfigEntry
@@ -59,7 +60,7 @@ async def test_successful_config_flow(hass, bypass_get_data):
5960
)
6061

6162
# Check that the config flow shows the user form as the first step
62-
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
63+
assert result["type"] == FlowResultType.FORM
6364
assert result["step_id"] == "user"
6465

6566
# If a user were to enter `test_username` for username and `test_password`
@@ -70,7 +71,7 @@ async def test_successful_config_flow(hass, bypass_get_data):
7071

7172
# Check that the config flow is complete and a new entry is created with
7273
# the input data
73-
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
74+
assert result["type"] == FlowResultType.CREATE_ENTRY
7475
assert result["title"] == "test@example.com"
7576
assert result["data"] == MOCK_CONFIG
7677
assert result["result"]
@@ -86,12 +87,14 @@ async def test_reauth_config_flow(hass, bypass_get_data):
8687
entry.add_to_hass(hass)
8788

8889
# Initialize a config flow
89-
result = await hass.config_entries.flow.async_init(
90-
DOMAIN, context={"source": config_entries.SOURCE_REAUTH}
91-
)
90+
entry.async_start_reauth(hass)
91+
await hass.async_block_till_done()
92+
flows = hass.config_entries.flow.async_progress()
93+
assert len(flows) == 1
94+
result = flows[0]
9295

9396
# Check that the config flow shows the reauth form as the first step
94-
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
97+
# assert result["type"] == FlowResultType.FORM
9598
assert result["step_id"] == "reauth_confirm"
9699

97100
# If a user were to confirm the re-auth start, this function call
@@ -100,7 +103,7 @@ async def test_reauth_config_flow(hass, bypass_get_data):
100103
)
101104

102105
# It should load the user form
103-
assert result_2["type"] == data_entry_flow.RESULT_TYPE_FORM
106+
assert result_2["type"] == FlowResultType.FORM
104107
assert result_2["step_id"] == "user"
105108

106109
updated_config = MOCK_CONFIG
@@ -113,7 +116,7 @@ async def test_reauth_config_flow(hass, bypass_get_data):
113116

114117
# Check that the config flow is complete and a new entry is created with
115118
# the input data
116-
assert result_3["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
119+
assert result_3["type"] == FlowResultType.CREATE_ENTRY
117120
assert result_3["title"] == "test@example.com"
118121
assert result_3["data"] == MOCK_CONFIG
119122
assert result_3["result"]
@@ -130,14 +133,14 @@ async def test_failed_config_flow(hass, error_on_get_data):
130133
DOMAIN, context={"source": config_entries.SOURCE_USER}
131134
)
132135

133-
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
136+
assert result["type"] == FlowResultType.FORM
134137
assert result["step_id"] == "user"
135138

136139
result = await hass.config_entries.flow.async_configure(
137140
result["flow_id"], user_input=MOCK_CONFIG
138141
)
139142

140-
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
143+
assert result["type"] == FlowResultType.FORM
141144
assert result["errors"] == {"base": "auth"}
142145

143146

@@ -154,7 +157,7 @@ async def test_options_flow(hass, bypass_get_data):
154157
result = await hass.config_entries.options.async_init(entry.entry_id)
155158

156159
# Verify that the first options step is a user form
157-
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
160+
assert result["type"] == FlowResultType.FORM
158161
assert result["step_id"] == "user"
159162

160163
# Enter some fake data into the form
@@ -164,7 +167,7 @@ async def test_options_flow(hass, bypass_get_data):
164167
)
165168

166169
# Verify that the flow finishes
167-
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
170+
assert result["type"] == FlowResultType.CREATE_ENTRY
168171
assert result["title"] == "test@example.com"
169172

170173
# Verify that the options were updated
@@ -190,7 +193,7 @@ async def test_dhcp_flow(hass: HomeAssistant, bypass_get_data) -> None:
190193
data=DHCP_SERVICE_INFO,
191194
context={"source": config_entries.SOURCE_DHCP},
192195
)
193-
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
196+
assert result["type"] == FlowResultType.FORM
194197
assert result["step_id"] == "user"
195198

196199
result2 = await hass.config_entries.flow.async_configure(
@@ -209,7 +212,7 @@ async def test_dhcp_login_error(hass: HomeAssistant, bypass_get_data) -> None:
209212
data=DHCP_SERVICE_INFO,
210213
context={"source": config_entries.SOURCE_DHCP},
211214
)
212-
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
215+
assert result["type"] == FlowResultType.FORM
213216
assert result["step_id"] == "user"
214217
with patch(
215218
"podpointclient.client.PodPointClient.async_credentials_verified",

tests/test_entity.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,13 @@
99
# import aiohttp
1010
from homeassistant.components import switch
1111
from homeassistant.components.sensor import (
12-
STATE_CLASS_TOTAL,
13-
STATE_CLASS_TOTAL_INCREASING,
12+
SensorStateClass,
13+
SensorDeviceClass,
1414
)
1515
from homeassistant.components.switch import SERVICE_TURN_OFF, SERVICE_TURN_ON
1616
from homeassistant.const import (
1717
ATTR_ENTITY_ID,
18-
DEVICE_CLASS_ENERGY,
19-
ENERGY_KILO_WATT_HOUR,
18+
UnitOfEnergy,
2019
)
2120
import homeassistant.helpers.aiohttp_client as client
2221
from podpointclient.charge_mode import ChargeMode

tests/test_sensor.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@
88
import aiohttp
99
from homeassistant.components import switch
1010
from homeassistant.components.sensor import (
11-
STATE_CLASS_TOTAL,
12-
STATE_CLASS_TOTAL_INCREASING,
11+
SensorStateClass,
1312
SensorDeviceClass,
1413
)
1514
from homeassistant.components.switch import SERVICE_TURN_OFF, SERVICE_TURN_ON
1615
from homeassistant.const import (
1716
ATTR_ENTITY_ID,
18-
DEVICE_CLASS_ENERGY,
19-
ENERGY_KILO_WATT_HOUR,
17+
UnitOfEnergy,
2018
)
2119
import homeassistant.helpers.aiohttp_client as client
2220
from podpointclient.charge_override import ChargeOverride
@@ -154,10 +152,10 @@ async def test_total_energy_pod_sensor(hass, bypass_get_data):
154152

155153
assert "Total Energy" == total_energy.name
156154

157-
assert DEVICE_CLASS_ENERGY == total_energy.device_class
158-
assert STATE_CLASS_TOTAL_INCREASING == total_energy.state_class
155+
assert SensorDeviceClass.ENERGY == total_energy.device_class
156+
assert SensorStateClass.TOTAL_INCREASING == total_energy.state_class
159157
assert 0.0 == total_energy.native_value
160-
assert ENERGY_KILO_WATT_HOUR == total_energy.native_unit_of_measurement
158+
assert UnitOfEnergy.KILO_WATT_HOUR == total_energy.native_unit_of_measurement
161159
assert "mdi:lightning-bolt-outline" == total_energy.icon
162160
assert False == total_energy.is_on
163161

@@ -182,8 +180,8 @@ async def test_current_energy_pod_sensor(hass, bypass_get_data):
182180

183181
assert "Current Energy" == current_energy.name
184182

185-
assert DEVICE_CLASS_ENERGY == current_energy.device_class
186-
assert STATE_CLASS_TOTAL == current_energy.state_class
183+
assert SensorDeviceClass.ENERGY == current_energy.device_class
184+
assert SensorStateClass.TOTAL == current_energy.state_class
187185
assert 0.0 == current_energy.native_value
188186
assert "mdi:car-electric" == current_energy.icon
189187

tests/test_update.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@
88
import aiohttp
99
from homeassistant.components import switch
1010
from homeassistant.components.sensor import (
11-
STATE_CLASS_TOTAL,
12-
STATE_CLASS_TOTAL_INCREASING,
11+
SensorStateClass,
1312
SensorDeviceClass,
1413
)
1514
from homeassistant.components.switch import SERVICE_TURN_OFF, SERVICE_TURN_ON
1615
from homeassistant.const import (
1716
ATTR_ENTITY_ID,
18-
DEVICE_CLASS_ENERGY,
19-
ENERGY_KILO_WATT_HOUR,
17+
UnitOfEnergy,
2018
)
2119
import homeassistant.helpers.aiohttp_client as client
2220
from podpointclient.pod import Pod

0 commit comments

Comments
 (0)