Skip to content

Commit

Permalink
Test changes for HA changes
Browse files Browse the repository at this point in the history
  • Loading branch information
PeteRager committed Apr 17, 2024
1 parent b09035d commit b136e38
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"python.testing.pytestArgs": [
"tests","--asyncio-mode=auto"
],
"python.experiments.optOutFrom": ["pythonTestAdapter"],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"python.experiments.enabled": false,
"cSpell.words": [
"ASHRAE",
"automations",
Expand Down
22 changes: 9 additions & 13 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from unittest.mock import patch

import pytest
import pytest_socket

from lennoxs30api.s30api_async import (
lennox_system,
Expand Down Expand Up @@ -78,7 +79,9 @@

@pytest.fixture(autouse=True)
def socket_enabled():
pass
pytest_socket.socket_allow_hosts(["127.0.0.1"])
pytest_socket.disable_socket(allow_unix_socket=True)


@pytest.fixture(autouse=True)
def auto_enable_custom_integrations(enable_custom_integrations):
Expand Down Expand Up @@ -131,8 +134,7 @@ def loadfile(name: str, sysId: str = None) -> json:

@pytest.fixture
def config_entry_local() -> config_entries.ConfigEntry:
config = config_entries.ConfigEntry(version=1, domain=DOMAIN, title="10.0.0.1", data={}, source="User")
config.unique_id = "12345"
config = config_entries.ConfigEntry(version=1, minor_version=0, domain=DOMAIN, title="10.0.0.1", data={}, source="User", unique_id="12345")
config.data = {}
config.data[CONF_CLOUD_CONNECTION] = False
config.data[CONF_HOST] = "10.0.0.1"
Expand All @@ -158,8 +160,7 @@ def config_entry_local() -> config_entries.ConfigEntry:

@pytest.fixture
def config_entry_cloud() -> config_entries.ConfigEntry:
config = config_entries.ConfigEntry(version=1, domain=DOMAIN, title="10.0.0.1", data={}, source="User")
config.unique_id = "12345"
config = config_entries.ConfigEntry(version=1, minor_version = 0, domain=DOMAIN, title="10.0.0.1", data={}, source="User", unique_id="12345")
config.data = {}
config.data[CONF_CLOUD_CONNECTION] = True
config.data[CONF_EMAIL] = "pete.rage@rage.com"
Expand Down Expand Up @@ -270,8 +271,7 @@ def manager_us_customary_units(hass: HomeAssistant, config_entry_local) -> Manag

@pytest.fixture
def manager_2_systems(hass) -> Manager:
config = config_entries.ConfigEntry(version=1, domain=DOMAIN, title="10.0.0.1", data={}, source="User")
config.unique_id = "12345"
config = config_entries.ConfigEntry(version=1, minor_version = 0, domain=DOMAIN, title="10.0.0.1", data={}, source="User", unique_id="12345")

manager_to_return = Manager(
hass=hass,
Expand Down Expand Up @@ -326,9 +326,7 @@ def manager_2_systems(hass) -> Manager:

@pytest.fixture
def manager_mz(hass) -> Manager:
config = config_entries.ConfigEntry(version=1, domain=DOMAIN, title="10.0.0.1", data={}, source="User")
config.unique_id = "12345"

config = config_entries.ConfigEntry(version=1, minor_version = 0, domain=DOMAIN, title="10.0.0.1", data={}, source="User", unique_id="12345")
manager_to_return = Manager(
hass=hass,
config=config,
Expand Down Expand Up @@ -371,9 +369,7 @@ def manager_mz(hass) -> Manager:

@pytest.fixture
def manager_system_04_furn_ac_zoning(hass) -> Manager:
config = config_entries.ConfigEntry(version=1, domain=DOMAIN, title="10.0.0.1", data={}, source="User")
config.unique_id = "12345"

config = config_entries.ConfigEntry(version=1, minor_version = 0, domain=DOMAIN, title="10.0.0.1", data={}, source="User", unique_id="12345")
manager_to_return = Manager(
hass=hass,
config=config,
Expand Down
14 changes: 7 additions & 7 deletions tests/test_async_setup_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ async def test_async_setup_entry_local(hass: HomeAssistant, caplog):
}
hass.data[LENNOX_DOMAIN] = {}

config_entry = config_entries.ConfigEntry(1, DOMAIN, "Test", data, "my_source")
config_entry = config_entries.ConfigEntry(version=1, minor_version=0, domain=DOMAIN, title = "Test", data = data, source="my_source")

with patch("custom_components.lennoxs30.Manager.s30_initialize") as s30_initialize:
res = await async_setup_entry(hass, config_entry)
Expand Down Expand Up @@ -182,7 +182,7 @@ async def test_async_setup_entry_cloud(hass, caplog):
}
hass.data[LENNOX_DOMAIN] = {}

config_entry = config_entries.ConfigEntry(1, DOMAIN, "Test", data, "my_source")
config_entry = config_entries.ConfigEntry(version=1, minor_version=0, domain=DOMAIN, title = "Test", data = data, source="my_source")

with patch("custom_components.lennoxs30.Manager.s30_initialize") as s30_initialize:
res = await async_setup_entry(hass, config_entry)
Expand Down Expand Up @@ -236,7 +236,7 @@ async def test_async_setup_entry_multiple(hass, caplog):
}
hass.data[LENNOX_DOMAIN] = {}

config_entry = config_entries.ConfigEntry(1, DOMAIN, "Test", data, "my_source")
config_entry = config_entries.ConfigEntry(version=1, minor_version=0, domain=DOMAIN, title = "Test", data = data, source="my_source", unique_id="12345")

with patch("custom_components.lennoxs30.Manager.s30_initialize") as s30_initialize:
res = await async_setup_entry(hass, config_entry)
Expand Down Expand Up @@ -286,7 +286,7 @@ async def test_async_setup_entry_multiple(hass, caplog):
}
hass.data[LENNOX_DOMAIN] = {}

config_entry = config_entries.ConfigEntry(1, DOMAIN, "Test1", data, "my_source")
config_entry = config_entries.ConfigEntry(version=1, minor_version=0, domain=DOMAIN, title = "Test1", data = data, source="my_source", unique_id="123456")

with patch("custom_components.lennoxs30.Manager.s30_initialize") as s30_initialize:
res = await async_setup_entry(hass, config_entry)
Expand Down Expand Up @@ -337,7 +337,7 @@ async def test_async_setup_entry_multiple(hass, caplog):
}
hass.data[LENNOX_DOMAIN] = {}

config_entry = config_entries.ConfigEntry(1, DOMAIN, "Test3", data, "my_source")
config_entry = config_entries.ConfigEntry(version=1, minor_version=0, domain=DOMAIN, title = "Test2", data = data, source="my_source", unique_id="1234567")

with patch("custom_components.lennoxs30.Manager.s30_initialize") as s30_initialize:
res = await async_setup_entry(hass, config_entry)
Expand Down Expand Up @@ -391,7 +391,7 @@ async def test_async_unload_entry_success(hass, caplog):
}
hass.data[LENNOX_DOMAIN] = {}

config_entry = config_entries.ConfigEntry(1, DOMAIN, "Test", data, "my_source")
config_entry = config_entries.ConfigEntry(version=1, minor_version=0, domain=DOMAIN, title = "Test", data = data, source="my_source")

with patch("custom_components.lennoxs30.Manager.s30_initialize") as _:
res = await async_setup_entry(hass, config_entry)
Expand Down Expand Up @@ -437,7 +437,7 @@ async def test_async_unload_entry_unload_fail(hass, caplog):
}
hass.data[LENNOX_DOMAIN] = {}

config_entry = config_entries.ConfigEntry(1, DOMAIN, "Test", data, "my_source")
config_entry = config_entries.ConfigEntry(version=1, minor_version=0, domain=DOMAIN, title = "Test", data = data, source="my_source")

with caplog.at_level(logging.ERROR):
caplog.clear()
Expand Down
12 changes: 6 additions & 6 deletions tests/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ async def test_upgrade_config_v1(hass):
"message_debug_file": "",
}

config_entry = config_entries.ConfigEntry(1, DOMAIN, "Test", data, "my_source")
config_entry = config_entries.ConfigEntry(version=1, minor_version=0, domain=DOMAIN, title = "Test", data = data, source="my_source")
with patch.object(hass.config_entries, "async_update_entry") as update_entry:
await async_migrate_entry(hass, config_entry)
assert update_entry.call_count == 1
Expand Down Expand Up @@ -469,7 +469,7 @@ async def test_upgrade_config_v1(hass):
"message_debug_file": "",
}

config_entry = config_entries.ConfigEntry(1, DOMAIN, "Test", data, "my_source")
config_entry = config_entries.ConfigEntry(version=1, minor_version=0, domain=DOMAIN, title = "Test", data = data, source="my_source")
with patch.object(hass.config_entries, "async_update_entry") as update_entry:
await async_migrate_entry(hass, config_entry)
assert update_entry.call_count == 1
Expand Down Expand Up @@ -516,7 +516,7 @@ async def test_upgrade_config_v2(hass):
"timeout": 30,
}

config_entry = config_entries.ConfigEntry(1, DOMAIN, "Test", data, "my_source")
config_entry = config_entries.ConfigEntry(version=1, minor_version=0, domain=DOMAIN, title = "Test", data = data, source="my_source")
with patch.object(hass.config_entries, "async_update_entry") as update_entry:
await async_migrate_entry(hass, config_entry)
assert update_entry.call_count == 1
Expand Down Expand Up @@ -562,7 +562,7 @@ async def test_upgrade_config_v2(hass):
"timeout": 30,
}

config_entry = config_entries.ConfigEntry(1, DOMAIN, "Test", data, "my_source")
config_entry = config_entries.ConfigEntry(version=1, minor_version=0, domain=DOMAIN, title = "Test", data = data, source="my_source")
with patch.object(hass.config_entries, "async_update_entry") as update_entry:
await async_migrate_entry(hass, config_entry)
assert update_entry.call_count == 1
Expand Down Expand Up @@ -611,7 +611,7 @@ async def test_upgrade_config_v3(hass, caplog):
"timeout": 30,
}

config_entry = config_entries.ConfigEntry(1, DOMAIN, "Test", data, "my_source")
config_entry = config_entries.ConfigEntry(version=1, minor_version=0, domain=DOMAIN, title = "Test", data = data, source="my_source")
with patch.object(hass.config_entries, "async_update_entry") as update_entry:
await async_migrate_entry(hass, config_entry)
assert update_entry.call_count == 1
Expand Down Expand Up @@ -657,7 +657,7 @@ async def test_upgrade_config_v3(hass, caplog):
"timeout": 30,
}

config_entry = config_entries.ConfigEntry(1, DOMAIN, "Test", data, "my_source")
config_entry = config_entries.ConfigEntry(version=1, minor_version=0, domain=DOMAIN, title = "Test", data = data, source="my_source")
with patch.object(hass.config_entries, "async_update_entry") as update_entry:
await async_migrate_entry(hass, config_entry)
assert update_entry.call_count == 1
Expand Down

0 comments on commit b136e38

Please sign in to comment.