Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed Jan 14, 2024
1 parent 021f7fb commit 4a4493d
Show file tree
Hide file tree
Showing 5 changed files with 212 additions and 186 deletions.
3 changes: 2 additions & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@


class FakeQuasar(YandexQuasar):
def __init__(self, data: dict):
def __init__(self, data: dict = None):
super().__init__(None)
self.data = data

async def get_device(self, *args):
Expand Down
20 changes: 10 additions & 10 deletions tests/test_climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def test_thermostat_remote_rf():
},
}

state = update_ha_state(YandexClimate, device)
state = update_ha_state(YandexClimate, device, config={})
assert state.state == "cool"
assert state.attributes == {
"current_temperature": None,
Expand Down Expand Up @@ -189,7 +189,7 @@ def test_thermostat_haier():
],
}

state = update_ha_state(YandexClimate, device)
state = update_ha_state(YandexClimate, device, config={})
assert state.state == "cool"
assert state.attributes == {
"current_temperature": 23,
Expand Down Expand Up @@ -262,7 +262,7 @@ def test_thermostat_tion():
"properties": [],
}

state = update_ha_state(YandexClimate, device)
state = update_ha_state(YandexClimate, device, config={})
assert state.state == "auto"
assert state.attributes == {
"current_temperature": None,
Expand Down Expand Up @@ -326,7 +326,7 @@ def test_thermostat_ecto():
},
}

state = update_ha_state(YandexClimate, device)
state = update_ha_state(YandexClimate, device, config={})
assert state.state == "auto"
assert state.attributes == {
"current_temperature": None,
Expand Down Expand Up @@ -389,7 +389,7 @@ def test_thermostat_heat():
"state": "online",
}

state = update_ha_state(YandexClimate, device)
state = update_ha_state(YandexClimate, device, config={})
assert state.state == "heat"
assert state.attributes == {
"current_temperature": None,
Expand Down Expand Up @@ -471,7 +471,7 @@ def test_thermostat_aqara():
"favorite": false,
}

state = update_ha_state(YandexClimate, device)
state = update_ha_state(YandexClimate, device, config={})
assert state.state == "auto"
assert state.attributes == {
"current_temperature": 20.7,
Expand Down Expand Up @@ -567,7 +567,7 @@ def test_purifier_ballu():
"favorite": false,
}

state = update_ha_state(YandexClimate, device)
state = update_ha_state(YandexClimate, device, config={})
assert state.state == "fan_only"
assert state.attributes == {
"current_temperature": 11,
Expand Down Expand Up @@ -658,7 +658,7 @@ def test_purifier_xiaomi():
},
}

state = update_ha_state(YandexClimate, device)
state = update_ha_state(YandexClimate, device, config={})
assert state.state == "fan_only"
assert state.attributes == {
"current_humidity": 28,
Expand Down Expand Up @@ -741,7 +741,7 @@ def test_humidifier_deerma():
},
}

state = update_ha_state(YandexClimate, device)
state = update_ha_state(YandexClimate, device, config={})
assert state.state == "dry"
assert state.attributes == {
"current_humidity": 52,
Expand Down Expand Up @@ -867,7 +867,7 @@ def test_humidifier_polaris():
},
}

state = update_ha_state(YandexClimate, device)
state = update_ha_state(YandexClimate, device, config={})
assert state.state == "dry"
assert state.attributes == {
"current_humidity": 0,
Expand Down
8 changes: 4 additions & 4 deletions tests/test_sensor.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from homeassistant.components.sensor import SensorStateClass
from homeassistant.const import UnitOfTemperature

from custom_components.yandex_station.sensor import YandexSensor
from custom_components.yandex_station.sensor import YandexCustomSensor
from . import true, null, update_ha_state


Expand Down Expand Up @@ -54,15 +54,15 @@ def test_sensor():
},
}

prop = next(
config = next(
i for i in device["properties"] if i["parameters"]["instance"] == "temperature"
)

state = update_ha_state(YandexSensor, device, prop=prop)
state = update_ha_state(YandexCustomSensor, device, config=config)
assert state.state == "19.5"
assert state.attributes == {
"device_class": "temperature",
"friendly_name": "Кабинет Градусник: температура",
"friendly_name": "Кабинет Градусник температура",
"state_class": SensorStateClass.MEASUREMENT,
"unit_of_measurement": UnitOfTemperature.CELSIUS,
}
Loading

0 comments on commit 4a4493d

Please sign in to comment.