generated from ludeeus/integration_blueprint
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from bluecurrent/development
fixed lint issues
- Loading branch information
Showing
3 changed files
with
35 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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: | ||
|
@@ -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="[email protected]" | ||
), patch( | ||
with patch( | ||
"bluecurrent_api.Client.validate_api_token", | ||
return_value=True, | ||
), patch("bluecurrent_api.Client.get_email", return_value="[email protected]"), patch( | ||
"bluecurrent_api.Client.get_charge_cards", | ||
return_value=[{"name": "card 1", "uid": 1}, {"name": "card 2", "uid": 2}], | ||
), patch( | ||
|
@@ -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="[email protected]" | ||
), patch( | ||
with patch( | ||
"bluecurrent_api.Client.validate_api_token", | ||
return_value=True, | ||
), patch("bluecurrent_api.Client.get_email", return_value="[email protected]"), patch( | ||
"bluecurrent_api.Client.get_charge_cards", | ||
side_effect=NoCardsFound, | ||
): | ||
|
@@ -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="[email protected]" | ||
), patch( | ||
with patch( | ||
"bluecurrent_api.Client.validate_api_token", | ||
return_value=True, | ||
), patch("bluecurrent_api.Client.get_email", return_value="[email protected]"), patch( | ||
"bluecurrent_api.Client.get_charge_cards", | ||
side_effect=WebsocketException, | ||
): | ||
|
@@ -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="[email protected]" | ||
), patch( | ||
with patch( | ||
"bluecurrent_api.Client.validate_api_token", | ||
return_value=True, | ||
), patch("bluecurrent_api.Client.get_email", return_value="[email protected]"), patch( | ||
"bluecurrent_api.Client.get_charge_cards", | ||
side_effect=RequestLimitReached, | ||
): | ||
|
@@ -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="[email protected]" | ||
), patch( | ||
with patch( | ||
"bluecurrent_api.Client.validate_api_token", | ||
return_value=True, | ||
), patch("bluecurrent_api.Client.get_email", return_value="[email protected]"), patch( | ||
"bluecurrent_api.Client.get_charge_cards", | ||
side_effect=AlreadyConnected, | ||
): | ||
|
@@ -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="[email protected]" | ||
), patch( | ||
with patch( | ||
"bluecurrent_api.Client.validate_api_token", | ||
return_value=True, | ||
), patch("bluecurrent_api.Client.get_email", return_value="[email protected]"), patch( | ||
"bluecurrent_api.Client.get_charge_cards", | ||
side_effect=Exception, | ||
): | ||
|
@@ -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() |