Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(deps): bump pytest-homeassistant-custom-component from 0.13.49 to 0.13.72 #958

Merged
11 changes: 2 additions & 9 deletions custom_components/ocpp/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Custom integration for Chargers that support the Open Charge Point Protocol."""

import asyncio
import logging

from homeassistant.config_entries import ConfigEntry
Expand Down Expand Up @@ -106,14 +105,8 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
central_sys._server.close()
await central_sys._server.wait_closed()

unloaded = all(
await asyncio.gather(
*(
hass.config_entries.async_forward_entry_unload(entry, platform)
for platform in PLATFORMS
)
)
)
unloaded = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)

if unloaded:
hass.data[DOMAIN].pop(entry.entry_id)

Expand Down
5 changes: 2 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ ocpp==0.21.0
websockets==12.0
jsonschema==4.19.2
pre-commit
pytest-homeassistant-custom-component==0.13.49
pytest-cov
setuptools>=65.5.1 # not directly required, pinned by Snyk to avoid a vulnerability
pytest-homeassistant-custom-component==0.13.72
setuptools>=65.5.1 # not directly required, pinned by Snyk to avoid a vulnerability
7 changes: 7 additions & 0 deletions tests/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@
CONF_WEBSOCKET_PING_TIMEOUT: 1,
}

# different port
MOCK_CONFIG_DATA_1 = {
**MOCK_CONFIG_DATA,
CONF_PORT: 9001,
CONF_CPID: "test_cpid_1",
}

# configuration with skip schema validation enabled
MOCK_CONFIG_DATA_2 = {
**MOCK_CONFIG_DATA,
Expand Down
10 changes: 8 additions & 2 deletions tests/test_charge_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,13 @@ async def test_services(hass, socket_enabled):
if True:
# Create a mock entry so we don't have to go through config flow
config_entry2 = MockConfigEntry(
domain=OCPP_DOMAIN, data=MOCK_CONFIG_DATA_2, entry_id="test_cms2"
domain=OCPP_DOMAIN,
data=MOCK_CONFIG_DATA_2,
entry_id="test_cms2",
title="test_cms2",
)
config_entry2.add_to_hass(hass)

assert await async_setup_entry(hass, config_entry2)
await hass.async_block_till_done()

Expand Down Expand Up @@ -161,8 +166,9 @@ async def test_services(hass, socket_enabled):

# Create a mock entry so we don't have to go through config flow
config_entry = MockConfigEntry(
domain=OCPP_DOMAIN, data=MOCK_CONFIG_DATA, entry_id="test_cms"
domain=OCPP_DOMAIN, data=MOCK_CONFIG_DATA, entry_id="test_cms", title="test_cms"
)
config_entry.add_to_hass(hass)
assert await async_setup_entry(hass, config_entry)
await hass.async_block_till_done()

Expand Down
12 changes: 9 additions & 3 deletions tests/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
)
from custom_components.ocpp.const import DOMAIN

from .const import MOCK_CONFIG_DATA
from .const import MOCK_CONFIG_DATA_1


# We can pass fixtures as defined in conftest.py to tell pytest to use the fixture
Expand All @@ -23,13 +23,17 @@ async def test_setup_unload_and_reload_entry(hass, bypass_get_data):
"""Test entry setup and unload."""
# Create a mock entry so we don't have to go through config flow
config_entry = MockConfigEntry(
domain=DOMAIN, data=MOCK_CONFIG_DATA, entry_id="test"
domain=DOMAIN, data=MOCK_CONFIG_DATA_1, entry_id="test_cms1", title="test_cms1"
)
# config_entry.add_to_hass(hass);
hass.config_entries._entries[config_entry.entry_id] = config_entry

# Set up the entry and assert that the values set during setup are where we expect
# them to be. Because we have patched the ocppDataUpdateCoordinator.async_get_data
# call, no code from custom_components/ocpp/api.py actually runs.
assert await async_setup_entry(hass, config_entry)
await hass.async_block_till_done()

assert DOMAIN in hass.data and config_entry.entry_id in hass.data[DOMAIN]
assert type(hass.data[DOMAIN][config_entry.entry_id]) == CentralSystem

Expand All @@ -39,7 +43,8 @@ async def test_setup_unload_and_reload_entry(hass, bypass_get_data):
assert type(hass.data[DOMAIN][config_entry.entry_id]) == CentralSystem

# Unload the entry and verify that the data has been removed
assert await async_unload_entry(hass, config_entry)
unloaded = await async_unload_entry(hass, config_entry)
assert unloaded
assert config_entry.entry_id not in hass.data[DOMAIN]


Expand All @@ -48,6 +53,7 @@ async def test_setup_unload_and_reload_entry(hass, bypass_get_data):
# config_entry = MockConfigEntry(
# domain=DOMAIN, data=MOCK_CONFIG_DATA, entry_id="test"
# )
# config_entry.add_to_hass(config_entry)
#
# # In this case we are testing the condition where async_setup_entry raises
# # ConfigEntryNotReady using the `error_on_get_data` fixture which simulates
Expand Down