Skip to content

Commit

Permalink
fix linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
lbbrhzn committed Nov 8, 2023
1 parent f180e59 commit d4b5824
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ your changes to the integration.
## Pre-commit

You can use the [pre-commit](https://pre-commit.com/) settings included in the
repostory to have code style and linting checks.
repository to have code style and linting checks.

With `pre-commit` tool already installed,
activate the settings of the repository:
Expand Down
3 changes: 2 additions & 1 deletion custom_components/ocpp/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ def __init__(

async def post_connect(self):
"""Logic to be executed right after a charger connects."""

# Define custom service handles for charge point
async def handle_clear_profile(call):
"""Handle the clear profile service call."""
Expand Down Expand Up @@ -493,7 +494,7 @@ async def handle_data_transfer(call):
if self.received_boot_notification is False:
await self.trigger_boot_notification()
await self.trigger_status_notification()
except (NotImplementedError) as e:
except NotImplementedError as e:
_LOGGER.error("Configuration of the charger failed: %s", e)

async def get_supported_features(self):
Expand Down
2 changes: 1 addition & 1 deletion scripts/setup
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ cd "$(dirname "$0")/.."

python3 -m pip install --requirement requirements.txt
pre-commit install
precommit run --all
pre-commit run --all
5 changes: 4 additions & 1 deletion tests/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
@pytest.fixture(autouse=True)
def bypass_setup_fixture():
"""Prevent setup."""
with patch("custom_components.ocpp.async_setup", return_value=True,), patch(
with patch(
"custom_components.ocpp.async_setup",
return_value=True,
), patch(
"custom_components.ocpp.async_setup_entry",
return_value=True,
):
Expand Down
11 changes: 8 additions & 3 deletions tests/test_init.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
"""Test ocpp setup process."""
# from homeassistant.exceptions import ConfigEntryNotReady
# import pytest
from typing import AsyncGenerator

from homeassistant.core import HomeAssistant
from pytest_homeassistant_custom_component.common import MockConfigEntry

from custom_components.ocpp import (
Expand All @@ -19,7 +22,9 @@
# Home Assistant using the pytest_homeassistant_custom_component plugin.
# Assertions allow you to verify that the return value of whatever is on the left
# side of the assertion matches with the right side.
async def test_setup_unload_and_reload_entry(hass, bypass_get_data):
async def test_setup_unload_and_reload_entry(
hass: AsyncGenerator[HomeAssistant, None], bypass_get_data: None
):
"""Test entry setup and unload."""
# Create a mock entry so we don't have to go through config flow
config_entry = MockConfigEntry(
Expand All @@ -35,12 +40,12 @@ async def test_setup_unload_and_reload_entry(hass, bypass_get_data):
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
assert type(hass.data[DOMAIN][config_entry.entry_id]) is CentralSystem

# Reload the entry and assert that the data from above is still there
assert await async_reload_entry(hass, config_entry) is None
assert DOMAIN in hass.data and config_entry.entry_id in hass.data[DOMAIN]
assert type(hass.data[DOMAIN][config_entry.entry_id]) == CentralSystem
assert type(hass.data[DOMAIN][config_entry.entry_id]) is CentralSystem

# Unload the entry and verify that the data has been removed
unloaded = await async_unload_entry(hass, config_entry)
Expand Down

0 comments on commit d4b5824

Please sign in to comment.