From 9b6acfb0f2be417262f09e386ce4e2c957cf4148 Mon Sep 17 00:00:00 2001 From: Floris272 Date: Fri, 5 May 2023 09:53:39 +0000 Subject: [PATCH 1/2] fixed lint issues --- custom_components/blue_current/manifest.json | 3 +- tests/test_config_flow.py | 56 +++++++++++--------- 2 files changed, 34 insertions(+), 25 deletions(-) diff --git a/custom_components/blue_current/manifest.json b/custom_components/blue_current/manifest.json index da9aecf..759f7ea 100755 --- a/custom_components/blue_current/manifest.json +++ b/custom_components/blue_current/manifest.json @@ -4,7 +4,8 @@ "codeowners": ["@Floris272", "@gleeuwen"], "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/blue_current", + "issue_tracker": "https://github.com/bluecurrent/ha-bluecurrent/issues", "iot_class": "cloud_push", "requirements": ["bluecurrent-api==1.0.3"], - "version": 1 + "version": "1.0.0" } diff --git a/tests/test_config_flow.py b/tests/test_config_flow.py index e049636..7ba6c94 100755 --- a/tests/test_config_flow.py +++ b/tests/test_config_flow.py @@ -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="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( @@ -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, ): @@ -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, ): @@ -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, ): @@ -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, ): @@ -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, ): @@ -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() \ No newline at end of file + await hass.async_block_till_done() From 49edc6ed95baafaad0f3c869b77ab8b7a63313f3 Mon Sep 17 00:00:00 2001 From: Floris272 Date: Fri, 5 May 2023 09:59:20 +0000 Subject: [PATCH 2/2] fixed manifest order --- README.md | 2 +- custom_components/blue_current/manifest.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9ead7db..caeb118 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/custom_components/blue_current/manifest.json b/custom_components/blue_current/manifest.json index 759f7ea..eec2dde 100755 --- a/custom_components/blue_current/manifest.json +++ b/custom_components/blue_current/manifest.json @@ -4,8 +4,8 @@ "codeowners": ["@Floris272", "@gleeuwen"], "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/blue_current", - "issue_tracker": "https://github.com/bluecurrent/ha-bluecurrent/issues", "iot_class": "cloud_push", + "issue_tracker": "https://github.com/bluecurrent/ha-bluecurrent/issues", "requirements": ["bluecurrent-api==1.0.3"], "version": "1.0.0" }