Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor drop sensor tests #106965

Merged
merged 3 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
167 changes: 167 additions & 0 deletions tests/components/drop_connect/common.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
"""Define common test values."""

from homeassistant.components.drop_connect.const import (
CONF_COMMAND_TOPIC,
CONF_DATA_TOPIC,
CONF_DEVICE_DESC,
CONF_DEVICE_ID,
CONF_DEVICE_NAME,
CONF_DEVICE_OWNER_ID,
CONF_DEVICE_TYPE,
CONF_HUB_ID,
DOMAIN,
)
from homeassistant.config_entries import ConfigEntry

from tests.common import MockConfigEntry

TEST_DATA_HUB_TOPIC = "drop_connect/DROP-1_C0FFEE/255"
TEST_DATA_HUB = (
'{"curFlow":5.77,"peakFlow":13.8,"usedToday":232.77,"avgUsed":76,"psi":62.2,"psiLow":61,"psiHigh":62,'
Expand Down Expand Up @@ -49,3 +64,155 @@
TEST_DATA_RO_FILTER_RESET = (
'{"leak":0,"tdsIn":0,"tdsOut":0,"cart1":0,"cart2":0,"cart3":0}'
)


def config_entry_hub() -> ConfigEntry:
"""Config entry version 1 fixture."""
return MockConfigEntry(
domain=DOMAIN,
unique_id="DROP-1_C0FFEE_255",
data={
CONF_COMMAND_TOPIC: "drop_connect/DROP-1_C0FFEE/255/cmd",
CONF_DATA_TOPIC: "drop_connect/DROP-1_C0FFEE/255/#",
CONF_DEVICE_DESC: "Hub",
CONF_DEVICE_ID: 255,
CONF_DEVICE_NAME: "Hub DROP-1_C0FFEE",
CONF_DEVICE_TYPE: "hub",
CONF_HUB_ID: "DROP-1_C0FFEE",
CONF_DEVICE_OWNER_ID: "DROP-1_C0FFEE_255",
},
version=1,
)


def config_entry_salt() -> ConfigEntry:
"""Config entry version 1 fixture."""
return MockConfigEntry(
domain=DOMAIN,
unique_id="DROP-1_C0FFEE_8",
data={
CONF_COMMAND_TOPIC: "drop_connect/DROP-1_C0FFEE/8/cmd",
CONF_DATA_TOPIC: "drop_connect/DROP-1_C0FFEE/8/#",
CONF_DEVICE_DESC: "Salt Sensor",
CONF_DEVICE_ID: 8,
CONF_DEVICE_NAME: "Salt Sensor",
CONF_DEVICE_TYPE: "salt",
CONF_HUB_ID: "DROP-1_C0FFEE",
CONF_DEVICE_OWNER_ID: "DROP-1_C0FFEE_255",
},
version=1,
)


def config_entry_leak() -> ConfigEntry:
"""Config entry version 1 fixture."""
return MockConfigEntry(
domain=DOMAIN,
unique_id="DROP-1_C0FFEE_20",
data={
CONF_COMMAND_TOPIC: "drop_connect/DROP-1_C0FFEE/20/cmd",
CONF_DATA_TOPIC: "drop_connect/DROP-1_C0FFEE/20/#",
CONF_DEVICE_DESC: "Leak Detector",
CONF_DEVICE_ID: 20,
CONF_DEVICE_NAME: "Leak Detector",
CONF_DEVICE_TYPE: "leak",
CONF_HUB_ID: "DROP-1_C0FFEE",
CONF_DEVICE_OWNER_ID: "DROP-1_C0FFEE_255",
},
version=1,
)


def config_entry_softener() -> ConfigEntry:
"""Config entry version 1 fixture."""
return MockConfigEntry(
domain=DOMAIN,
unique_id="DROP-1_C0FFEE_0",
data={
CONF_COMMAND_TOPIC: "drop_connect/DROP-1_C0FFEE/0/cmd",
CONF_DATA_TOPIC: "drop_connect/DROP-1_C0FFEE/0/#",
CONF_DEVICE_DESC: "Softener",
CONF_DEVICE_ID: 0,
CONF_DEVICE_NAME: "Softener",
CONF_DEVICE_TYPE: "soft",
CONF_HUB_ID: "DROP-1_C0FFEE",
CONF_DEVICE_OWNER_ID: "DROP-1_C0FFEE_255",
},
version=1,
)


def config_entry_filter() -> ConfigEntry:
"""Config entry version 1 fixture."""
return MockConfigEntry(
domain=DOMAIN,
unique_id="DROP-1_C0FFEE_4",
data={
CONF_COMMAND_TOPIC: "drop_connect/DROP-1_C0FFEE/4/cmd",
CONF_DATA_TOPIC: "drop_connect/DROP-1_C0FFEE/4/#",
CONF_DEVICE_DESC: "Filter",
CONF_DEVICE_ID: 4,
CONF_DEVICE_NAME: "Filter",
CONF_DEVICE_TYPE: "filt",
CONF_HUB_ID: "DROP-1_C0FFEE",
CONF_DEVICE_OWNER_ID: "DROP-1_C0FFEE_255",
},
version=1,
)


def config_entry_protection_valve() -> ConfigEntry:
"""Config entry version 1 fixture."""
return MockConfigEntry(
domain=DOMAIN,
unique_id="DROP-1_C0FFEE_78",
data={
CONF_COMMAND_TOPIC: "drop_connect/DROP-1_C0FFEE/78/cmd",
CONF_DATA_TOPIC: "drop_connect/DROP-1_C0FFEE/78/#",
CONF_DEVICE_DESC: "Protection Valve",
CONF_DEVICE_ID: 78,
CONF_DEVICE_NAME: "Protection Valve",
CONF_DEVICE_TYPE: "pv",
CONF_HUB_ID: "DROP-1_C0FFEE",
CONF_DEVICE_OWNER_ID: "DROP-1_C0FFEE_255",
},
version=1,
)


def config_entry_pump_controller() -> ConfigEntry:
"""Config entry version 1 fixture."""
return MockConfigEntry(
domain=DOMAIN,
unique_id="DROP-1_C0FFEE_83",
data={
CONF_COMMAND_TOPIC: "drop_connect/DROP-1_C0FFEE/83/cmd",
CONF_DATA_TOPIC: "drop_connect/DROP-1_C0FFEE/83/#",
CONF_DEVICE_DESC: "Pump Controller",
CONF_DEVICE_ID: 83,
CONF_DEVICE_NAME: "Pump Controller",
CONF_DEVICE_TYPE: "pc",
CONF_HUB_ID: "DROP-1_C0FFEE",
CONF_DEVICE_OWNER_ID: "DROP-1_C0FFEE_255",
},
version=1,
)


def config_entry_ro_filter() -> ConfigEntry:
"""Config entry version 1 fixture."""
return MockConfigEntry(
domain=DOMAIN,
unique_id="DROP-1_C0FFEE_255",
data={
CONF_COMMAND_TOPIC: "drop_connect/DROP-1_C0FFEE/95/cmd",
CONF_DATA_TOPIC: "drop_connect/DROP-1_C0FFEE/95/#",
CONF_DEVICE_DESC: "RO Filter",
CONF_DEVICE_ID: 95,
CONF_DEVICE_NAME: "RO Filter",
CONF_DEVICE_TYPE: "ro",
CONF_HUB_ID: "DROP-1_C0FFEE",
CONF_DEVICE_OWNER_ID: "DROP-1_C0FFEE_255",
},
version=1,
)
Loading