From 20c796eb9f9728ff4042f3caf2e0ff11012e12f5 Mon Sep 17 00:00:00 2001 From: Simone Chemelli Date: Thu, 3 Oct 2024 12:25:12 +0200 Subject: [PATCH] chore(cloud)!: rename MSmartHome (#306) Closes #286 --- .vscode/launch.json | 2 +- midealocal/cloud.py | 8 ++++---- tests/cli_test.py | 8 ++++---- tests/cloud_test.py | 22 +++++++++++----------- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 86269376..8395090a 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -97,7 +97,7 @@ "type": "pickString", "options": [ "美的美居", - "MSmartHome", + "SmartHome", "Midea Air", "NetHome Plus", "Ariston Clima" diff --git a/midealocal/cloud.py b/midealocal/cloud.py index 9771f12d..bb1626fa 100644 --- a/midealocal/cloud.py +++ b/midealocal/cloud.py @@ -42,9 +42,9 @@ ).decode(), "api_url": "https://mp-prod.smartmidea.net/mas/v5/app/proxy?alias=", }, - "MSmartHome": { + "SmartHome": { "default": True, - "class_name": "MSmartHomeCloud", + "class_name": "SmartHomeCloud", "app_id": "1010", "app_key": "ac21b9f9cbfe4ca5a88562ef25e2b768", "iot_key": bytes.fromhex(format(7882822598523843940, "x")).decode(), @@ -540,7 +540,7 @@ async def download_lua( return str(fnm) if fnm else None -class MSmartHomeCloud(MideaCloud): +class SmartHomeCloud(MideaCloud): """MSmart Home Cloud.""" def __init__( @@ -650,7 +650,7 @@ async def login(self) -> bool: response["randomData"], ) return True - _LOGGER.warning("MSmartHome Cloud login failed for device %s", self._device_id) + _LOGGER.warning("SmartHome Cloud login failed for device %s", self._device_id) return False async def list_appliances( diff --git a/tests/cli_test.py b/tests/cli_test.py index 74fa8458..22af1104 100644 --- a/tests/cli_test.py +++ b/tests/cli_test.py @@ -13,7 +13,7 @@ MideaCLI, get_config_file_path, ) -from midealocal.cloud import MSmartHomeCloud +from midealocal.cloud import SmartHomeCloud from midealocal.const import ProtocolVersion from midealocal.device import AuthException, NoSupportedProtocol from midealocal.exceptions import SocketException @@ -26,7 +26,7 @@ def setUp(self) -> None: """Create namespace for testing.""" self.cli = MideaCLI() self.namespace = Namespace( - cloud_name="MSmartHome", + cloud_name="SmartHome", username="user", password="pass", host="192.168.0.1", @@ -50,14 +50,14 @@ async def test_get_cloud(self) -> None: ): cloud = await self.cli._get_cloud() - assert isinstance(cloud, MSmartHomeCloud) + assert isinstance(cloud, SmartHomeCloud) assert cloud._account == self.namespace.username assert cloud._password == self.namespace.password assert cloud._session == mock_session_instance self.namespace.cloud_name = None cloud = await self.cli._get_cloud() - assert isinstance(cloud, MSmartHomeCloud) + assert isinstance(cloud, SmartHomeCloud) assert cloud._session == mock_session_instance async def test_get_keys(self) -> None: diff --git a/tests/cloud_test.py b/tests/cloud_test.py index e8959913..dbfae2a8 100644 --- a/tests/cloud_test.py +++ b/tests/cloud_test.py @@ -14,7 +14,7 @@ MeijuCloud, MideaAirCloud, MideaCloud, - MSmartHomeCloud, + SmartHomeCloud, get_default_cloud, get_midea_cloud, get_preset_account_cloud, @@ -42,8 +42,8 @@ def test_get_midea_cloud(self) -> None: session = AsyncMock() assert isinstance(get_midea_cloud("美的美居", session, "", ""), MeijuCloud) assert isinstance( - get_midea_cloud("MSmartHome", session, "", ""), - MSmartHomeCloud, + get_midea_cloud("SmartHome", session, "", ""), + SmartHomeCloud, ) assert isinstance(get_midea_cloud("Midea Air", session, "", ""), MideaAirCloud) assert isinstance( @@ -60,7 +60,7 @@ def test_get_midea_cloud(self) -> None: async def test_get_default_cloud(self) -> None: """Test get default cloud name.""" default_cloud = get_default_cloud() - assert default_cloud == "MSmartHome" + assert default_cloud == "SmartHome" async def test_get_cloud_servers(self) -> None: """Test get cloud servers.""" @@ -72,7 +72,7 @@ async def test_get_preset_account_cloud(self) -> None: credentials = get_preset_account_cloud() assert credentials["username"] == "c414e631394b8639@outlook.com" assert credentials["password"] == "a0d6e30c94b15" - assert credentials["cloud_name"] == "MSmartHome" + assert credentials["cloud_name"] == "SmartHome" async def test_midea_cloud_unimplemented(self) -> None: """Test unimplemented MideaCloud methods.""" @@ -380,7 +380,7 @@ async def test_msmartcloud_login_success(self) -> None: ) session.request = AsyncMock(return_value=response) cloud = get_midea_cloud( - "MSmartHome", + "SmartHome", session=session, account="account", password="password", @@ -397,7 +397,7 @@ async def test_msmartcloud_login_invalid_user(self) -> None: ) session.request = AsyncMock(return_value=response) cloud = get_midea_cloud( - "MSmartHome", + "SmartHome", session=session, account="account", password="password", @@ -409,7 +409,7 @@ async def test_msmartcloud_list_home(self) -> None: """Test MSmartCloud list_home.""" session = Mock() cloud = get_midea_cloud( - "MSmartHome", + "SmartHome", session=session, account="account", password="password", @@ -434,7 +434,7 @@ async def test_msmartcloud_list_appliances(self) -> None: ) session.request = AsyncMock(return_value=response) cloud = get_midea_cloud( - "MSmartHome", + "SmartHome", session=session, account="account", password="password", @@ -485,7 +485,7 @@ async def test_msmartcloud_get_device_info(self) -> None: ) session.request = AsyncMock(return_value=response) cloud = get_midea_cloud( - "MSmartHome", + "SmartHome", session=session, account="account", password="password", @@ -525,7 +525,7 @@ async def test_msmartcloud_download_lua(self) -> None: res.text = AsyncMock(return_value="4ABE0FE395F3AD3B6BC4D223F1ADFA7C") session.get = AsyncMock(return_value=res) cloud = get_midea_cloud( - "MSmartHome", + "SmartHome", session=session, account="account", password="password",