Skip to content

Commit

Permalink
Merge pull request #13 from bluecurrent/development
Browse files Browse the repository at this point in the history
fixed lint issues
  • Loading branch information
Floris272 authored May 5, 2023
2 parents 8ae73f8 + 49edc6e commit c4bf561
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 26 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Integration Blueprint
# Blue Current Home Assistant integration

[![hacs_badge](https://img.shields.io/badge/HACS-Custom-41BDF5.svg?style=for-the-badge)](https://github.com/hacs/integration)

Expand Down
3 changes: 2 additions & 1 deletion custom_components/blue_current/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/blue_current",
"iot_class": "cloud_push",
"issue_tracker": "https://github.com/bluecurrent/ha-bluecurrent/issues",
"requirements": ["bluecurrent-api==1.0.3"],
"version": 1
"version": "1.0.0"
}
56 changes: 32 additions & 24 deletions tests/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
from pytest_homeassistant_custom_component.common import MockConfigEntry

from custom_components.blue_current import DOMAIN
from custom_components.blue_current.config_flow import (AlreadyConnected,
InvalidApiToken,
NoCardsFound,
RequestLimitReached,
WebsocketException)
from custom_components.blue_current.config_flow import (
AlreadyConnected,
InvalidApiToken,
NoCardsFound,
RequestLimitReached,
WebsocketException,
)


async def test_form(hass: HomeAssistant) -> None:
Expand Down Expand Up @@ -57,9 +59,10 @@ async def test_user_card(hass: HomeAssistant) -> None:
)
assert result["errors"] == {}

with patch("bluecurrent_api.Client.validate_api_token", return_value=True,), patch(
"bluecurrent_api.Client.get_email", return_value="test@email.com"
), patch(
with patch(
"bluecurrent_api.Client.validate_api_token",
return_value=True,
), patch("bluecurrent_api.Client.get_email", return_value="test@email.com"), patch(
"bluecurrent_api.Client.get_charge_cards",
return_value=[{"name": "card 1", "uid": 1}, {"name": "card 2", "uid": 2}],
), patch(
Expand Down Expand Up @@ -163,9 +166,10 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
async def test_form_no_cards_found(hass: HomeAssistant) -> None:
"""Test if a no cards error is handled."""

with patch("bluecurrent_api.Client.validate_api_token", return_value=True,), patch(
"bluecurrent_api.Client.get_email", return_value="test@email.com"
), patch(
with patch(
"bluecurrent_api.Client.validate_api_token",
return_value=True,
), patch("bluecurrent_api.Client.get_email", return_value="test@email.com"), patch(
"bluecurrent_api.Client.get_charge_cards",
side_effect=NoCardsFound,
):
Expand All @@ -181,9 +185,10 @@ async def test_form_no_cards_found(hass: HomeAssistant) -> None:
async def test_form_cannot_connect_card(hass: HomeAssistant) -> None:
"""Test if a connection error on get_charge_cards is handled."""

with patch("bluecurrent_api.Client.validate_api_token", return_value=True,), patch(
"bluecurrent_api.Client.get_email", return_value="test@email.com"
), patch(
with patch(
"bluecurrent_api.Client.validate_api_token",
return_value=True,
), patch("bluecurrent_api.Client.get_email", return_value="test@email.com"), patch(
"bluecurrent_api.Client.get_charge_cards",
side_effect=WebsocketException,
):
Expand All @@ -198,9 +203,10 @@ async def test_form_cannot_connect_card(hass: HomeAssistant) -> None:

async def test_form_limit_reached_card(hass: HomeAssistant) -> None:
"""Test if an limit reached error is handled."""
with patch("bluecurrent_api.Client.validate_api_token", return_value=True,), patch(
"bluecurrent_api.Client.get_email", return_value="test@email.com"
), patch(
with patch(
"bluecurrent_api.Client.validate_api_token",
return_value=True,
), patch("bluecurrent_api.Client.get_email", return_value="test@email.com"), patch(
"bluecurrent_api.Client.get_charge_cards",
side_effect=RequestLimitReached,
):
Expand All @@ -214,9 +220,10 @@ async def test_form_limit_reached_card(hass: HomeAssistant) -> None:

async def test_form_already_connected_card(hass: HomeAssistant) -> None:
"""Test if an already connected error is handled."""
with patch("bluecurrent_api.Client.validate_api_token", return_value=True,), patch(
"bluecurrent_api.Client.get_email", return_value="test@email.com"
), patch(
with patch(
"bluecurrent_api.Client.validate_api_token",
return_value=True,
), patch("bluecurrent_api.Client.get_email", return_value="test@email.com"), patch(
"bluecurrent_api.Client.get_charge_cards",
side_effect=AlreadyConnected,
):
Expand All @@ -230,9 +237,10 @@ async def test_form_already_connected_card(hass: HomeAssistant) -> None:

async def test_form_exception_card(hass: HomeAssistant) -> None:
"""Test if an exception is handled."""
with patch("bluecurrent_api.Client.validate_api_token", return_value=True,), patch(
"bluecurrent_api.Client.get_email", return_value="test@email.com"
), patch(
with patch(
"bluecurrent_api.Client.validate_api_token",
return_value=True,
), patch("bluecurrent_api.Client.get_email", return_value="test@email.com"), patch(
"bluecurrent_api.Client.get_charge_cards",
side_effect=Exception,
):
Expand Down Expand Up @@ -279,4 +287,4 @@ async def test_flow_reauth(hass: HomeAssistant) -> None:
assert entry.data.copy() == {"api_token": "1234567890"}

assert await entry.async_unload(hass)
await hass.async_block_till_done()
await hass.async_block_till_done()

0 comments on commit c4bf561

Please sign in to comment.