Use unicode slugify (#19192)
* Update __init__.py * Update setup.py * Update requirements_all.txt * Update __init__.py * Update __init__.py * Update __init__.py * Update __init__.py * Update __init__.py * remove `-` * fix packages * Update package_constraints.txt * Update __init__.py * Update package_constraints.txt * Update requirements_all.txt * Update setup.py * Fix tests * Fix line issue * fix all test * fix type * Fix lint
This commit is contained in:
1 parent
cc90cba78a
commit
2bf36bb1db
15 files changed
+216
-215
No files matched your search
@@ -8,51 +8,53 @@ from unittest.mock import patch
|
||||
|
||||
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
|
||||
from homeassistant.components.sensor.awair import (
|
||||
ATTR_LAST_API_UPDATE, ATTR_TIMESTAMP, DEVICE_CLASS_CARBON_DIOXIDE,
|
||||
DEVICE_CLASS_PM2_5, DEVICE_CLASS_SCORE,
|
||||
DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS)
|
||||
ATTR_LAST_API_UPDATE,
|
||||
ATTR_TIMESTAMP,
|
||||
DEVICE_CLASS_CARBON_DIOXIDE,
|
||||
DEVICE_CLASS_PM2_5,
|
||||
DEVICE_CLASS_SCORE,
|
||||
DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_TEMPERATURE, STATE_UNAVAILABLE,
|
||||
TEMP_CELSIUS)
|
||||
DEVICE_CLASS_HUMIDITY,
|
||||
DEVICE_CLASS_TEMPERATURE,
|
||||
STATE_UNAVAILABLE,
|
||||
TEMP_CELSIUS,
|
||||
)
|
||||
from homeassistant.setup import async_setup_component
|
||||
from homeassistant.util.dt import parse_datetime, utcnow
|
||||
|
||||
from tests.common import async_fire_time_changed, load_fixture, mock_coro
|
||||
|
||||
DISCOVERY_CONFIG = {
|
||||
'sensor': {
|
||||
'platform': 'awair',
|
||||
'access_token': 'qwerty',
|
||||
}
|
||||
}
|
||||
DISCOVERY_CONFIG = {"sensor": {"platform": "awair", "access_token": "qwerty"}}
|
||||
|
||||
MANUAL_CONFIG = {
|
||||
'sensor': {
|
||||
'platform': 'awair',
|
||||
'access_token': 'qwerty',
|
||||
'devices': [
|
||||
{'uuid': 'awair_foo'}
|
||||
]
|
||||
"sensor": {
|
||||
"platform": "awair",
|
||||
"access_token": "qwerty",
|
||||
"devices": [{"uuid": "awair_foo"}],
|
||||
}
|
||||
}
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
NOW = utcnow()
|
||||
AIR_DATA_FIXTURE = json.loads(load_fixture('awair_air_data_latest.json'))
|
||||
AIR_DATA_FIXTURE = json.loads(load_fixture("awair_air_data_latest.json"))
|
||||
AIR_DATA_FIXTURE[0][ATTR_TIMESTAMP] = str(NOW)
|
||||
AIR_DATA_FIXTURE_UPDATED = json.loads(
|
||||
load_fixture('awair_air_data_latest_updated.json'))
|
||||
load_fixture("awair_air_data_latest_updated.json")
|
||||
)
|
||||
AIR_DATA_FIXTURE_UPDATED[0][ATTR_TIMESTAMP] = str(NOW + timedelta(minutes=5))
|
||||
|
||||
|
||||
@contextmanager
|
||||
def alter_time(retval):
|
||||
"""Manage multiple time mocks."""
|
||||
patch_one = patch('homeassistant.util.dt.utcnow', return_value=retval)
|
||||
patch_two = patch('homeassistant.util.utcnow', return_value=retval)
|
||||
patch_three = patch('homeassistant.components.sensor.awair.dt.utcnow',
|
||||
return_value=retval)
|
||||
patch_one = patch("homeassistant.util.dt.utcnow", return_value=retval)
|
||||
patch_two = patch("homeassistant.util.utcnow", return_value=retval)
|
||||
patch_three = patch(
|
||||
"homeassistant.components.sensor.awair.dt.utcnow", return_value=retval
|
||||
)
|
||||
|
||||
with patch_one, patch_two, patch_three:
|
||||
yield
|
||||
@@ -60,13 +62,14 @@ def alter_time(retval):
|
||||
|
||||
async def setup_awair(hass, config=None):
|
||||
"""Load the Awair platform."""
|
||||
devices_json = json.loads(load_fixture('awair_devices.json'))
|
||||
devices_json = json.loads(load_fixture("awair_devices.json"))
|
||||
devices_mock = mock_coro(devices_json)
|
||||
devices_patch = patch('python_awair.AwairClient.devices',
|
||||
return_value=devices_mock)
|
||||
devices_patch = patch(
|
||||
"python_awair.AwairClient.devices", return_value=devices_mock)
|
||||
air_data_mock = mock_coro(AIR_DATA_FIXTURE)
|
||||
air_data_patch = patch('python_awair.AwairClient.air_data_latest',
|
||||
return_value=air_data_mock)
|
||||
air_data_patch = patch(
|
||||
"python_awair.AwairClient.air_data_latest", return_value=air_data_mock
|
||||
)
|
||||
|
||||
if config is None:
|
||||
config = DISCOVERY_CONFIG
|
||||
@@ -84,8 +87,8 @@ async def test_platform_manually_configured(hass):
|
||||
|
||||
# Ensure that we loaded the device with uuid 'awair_foo', not the
|
||||
# 'awair_12345' device that we stub out for API device discovery
|
||||
entity = hass.data[SENSOR_DOMAIN].get_entity('sensor.awair_co2')
|
||||
assert entity.unique_id == 'awair_foo_CO2'
|
||||
entity = hass.data[SENSOR_DOMAIN].get_entity("sensor.awair_co2")
|
||||
assert entity.unique_id == "awair_foo_CO2"
|
||||
|
||||
|
||||
async def test_platform_automatically_configured(hass):
|
||||
@@ -96,34 +99,40 @@ async def test_platform_automatically_configured(hass):
|
||||
|
||||
# Ensure that we loaded the device with uuid 'awair_12345', which is
|
||||
# the device that we stub out for API device discovery
|
||||
entity = hass.data[SENSOR_DOMAIN].get_entity('sensor.awair_co2')
|
||||
assert entity.unique_id == 'awair_12345_CO2'
|
||||
entity = hass.data[SENSOR_DOMAIN].get_entity("sensor.awair_co2")
|
||||
assert entity.unique_id == "awair_12345_CO2"
|
||||
|
||||
|
||||
async def test_bad_platform_setup(hass):
|
||||
"""Tests that we throw correct exceptions when setting up Awair."""
|
||||
from python_awair import AwairClient
|
||||
|
||||
auth_patch = patch('python_awair.AwairClient.devices',
|
||||
side_effect=AwairClient.AuthError)
|
||||
rate_patch = patch('python_awair.AwairClient.devices',
|
||||
side_effect=AwairClient.RatelimitError)
|
||||
generic_patch = patch('python_awair.AwairClient.devices',
|
||||
side_effect=AwairClient.GenericError)
|
||||
auth_patch = patch(
|
||||
"python_awair.AwairClient.devices",
|
||||
side_effect=AwairClient.AuthError
|
||||
)
|
||||
rate_patch = patch(
|
||||
"python_awair.AwairClient.devices",
|
||||
side_effect=AwairClient.RatelimitError
|
||||
)
|
||||
generic_patch = patch(
|
||||
"python_awair.AwairClient.devices",
|
||||
side_effect=AwairClient.GenericError
|
||||
)
|
||||
|
||||
with auth_patch:
|
||||
assert await async_setup_component(hass, SENSOR_DOMAIN,
|
||||
DISCOVERY_CONFIG)
|
||||
assert await async_setup_component(
|
||||
hass, SENSOR_DOMAIN, DISCOVERY_CONFIG)
|
||||
assert not hass.states.async_all()
|
||||
|
||||
with rate_patch:
|
||||
assert await async_setup_component(hass, SENSOR_DOMAIN,
|
||||
DISCOVERY_CONFIG)
|
||||
assert await async_setup_component(
|
||||
hass, SENSOR_DOMAIN, DISCOVERY_CONFIG)
|
||||
assert not hass.states.async_all()
|
||||
|
||||
with generic_patch:
|
||||
assert await async_setup_component(hass, SENSOR_DOMAIN,
|
||||
DISCOVERY_CONFIG)
|
||||
assert await async_setup_component(
|
||||
hass, SENSOR_DOMAIN, DISCOVERY_CONFIG)
|
||||
assert not hass.states.async_all()
|
||||
|
||||
|
||||
@@ -131,60 +140,62 @@ async def test_awair_misc_attributes(hass):
|
||||
"""Test that desired attributes are set."""
|
||||
await setup_awair(hass)
|
||||
|
||||
attributes = hass.states.get('sensor.awair_co2').attributes
|
||||
assert (attributes[ATTR_LAST_API_UPDATE] ==
|
||||
parse_datetime(AIR_DATA_FIXTURE[0][ATTR_TIMESTAMP]))
|
||||
attributes = hass.states.get("sensor.awair_co2").attributes
|
||||
assert attributes[ATTR_LAST_API_UPDATE] == parse_datetime(
|
||||
AIR_DATA_FIXTURE[0][ATTR_TIMESTAMP]
|
||||
)
|
||||
|
||||
|
||||
async def test_awair_score(hass):
|
||||
"""Test that we create a sensor for the 'Awair score'."""
|
||||
await setup_awair(hass)
|
||||
|
||||
sensor = hass.states.get('sensor.awair_score')
|
||||
assert sensor.state == '78'
|
||||
assert sensor.attributes['device_class'] == DEVICE_CLASS_SCORE
|
||||
assert sensor.attributes['unit_of_measurement'] == '%'
|
||||
sensor = hass.states.get("sensor.awair_score")
|
||||
assert sensor.state == "78"
|
||||
assert sensor.attributes["device_class"] == DEVICE_CLASS_SCORE
|
||||
assert sensor.attributes["unit_of_measurement"] == "%"
|
||||
|
||||
|
||||
async def test_awair_temp(hass):
|
||||
"""Test that we create a temperature sensor."""
|
||||
await setup_awair(hass)
|
||||
|
||||
sensor = hass.states.get('sensor.awair_temperature')
|
||||
assert sensor.state == '22.4'
|
||||
assert sensor.attributes['device_class'] == DEVICE_CLASS_TEMPERATURE
|
||||
assert sensor.attributes['unit_of_measurement'] == TEMP_CELSIUS
|
||||
sensor = hass.states.get("sensor.awair_temperature")
|
||||
assert sensor.state == "22.4"
|
||||
assert sensor.attributes["device_class"] == DEVICE_CLASS_TEMPERATURE
|
||||
assert sensor.attributes["unit_of_measurement"] == TEMP_CELSIUS
|
||||
|
||||
|
||||
async def test_awair_humid(hass):
|
||||
"""Test that we create a humidity sensor."""
|
||||
await setup_awair(hass)
|
||||
|
||||
sensor = hass.states.get('sensor.awair_humidity')
|
||||
assert sensor.state == '32.73'
|
||||
assert sensor.attributes['device_class'] == DEVICE_CLASS_HUMIDITY
|
||||
assert sensor.attributes['unit_of_measurement'] == '%'
|
||||
sensor = hass.states.get("sensor.awair_humidity")
|
||||
assert sensor.state == "32.73"
|
||||
assert sensor.attributes["device_class"] == DEVICE_CLASS_HUMIDITY
|
||||
assert sensor.attributes["unit_of_measurement"] == "%"
|
||||
|
||||
|
||||
async def test_awair_co2(hass):
|
||||
"""Test that we create a CO2 sensor."""
|
||||
await setup_awair(hass)
|
||||
|
||||
sensor = hass.states.get('sensor.awair_co2')
|
||||
assert sensor.state == '612'
|
||||
assert sensor.attributes['device_class'] == DEVICE_CLASS_CARBON_DIOXIDE
|
||||
assert sensor.attributes['unit_of_measurement'] == 'ppm'
|
||||
sensor = hass.states.get("sensor.awair_co2")
|
||||
assert sensor.state == "612"
|
||||
assert sensor.attributes["device_class"] == \
|
||||
DEVICE_CLASS_CARBON_DIOXIDE
|
||||
assert sensor.attributes["unit_of_measurement"] == "ppm"
|
||||
|
||||
|
||||
async def test_awair_voc(hass):
|
||||
"""Test that we create a CO2 sensor."""
|
||||
await setup_awair(hass)
|
||||
|
||||
sensor = hass.states.get('sensor.awair_voc')
|
||||
assert sensor.state == '1012'
|
||||
assert (sensor.attributes['device_class'] ==
|
||||
DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS)
|
||||
assert sensor.attributes['unit_of_measurement'] == 'ppb'
|
||||
sensor = hass.states.get("sensor.awair_voc")
|
||||
assert sensor.state == "1012"
|
||||
assert sensor.attributes["device_class"] == \
|
||||
DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS
|
||||
assert sensor.attributes["unit_of_measurement"] == "ppb"
|
||||
|
||||
|
||||
async def test_awair_dust(hass):
|
||||
@@ -193,10 +204,10 @@ async def test_awair_dust(hass):
|
||||
|
||||
# The Awair Gen1 that we mock actually returns 'DUST', but that
|
||||
# is mapped to pm25 internally so that it shows up in Homekit
|
||||
sensor = hass.states.get('sensor.awair_pm25')
|
||||
assert sensor.state == '6.2'
|
||||
assert sensor.attributes['device_class'] == DEVICE_CLASS_PM2_5
|
||||
assert sensor.attributes['unit_of_measurement'] == 'µg/m3'
|
||||
sensor = hass.states.get("sensor.awair_pm2_5")
|
||||
assert sensor.state == "6.2"
|
||||
assert sensor.attributes["device_class"] == DEVICE_CLASS_PM2_5
|
||||
assert sensor.attributes["unit_of_measurement"] == "µg/m3"
|
||||
|
||||
|
||||
async def test_awair_unsupported_sensors(hass):
|
||||
@@ -206,36 +217,40 @@ async def test_awair_unsupported_sensors(hass):
|
||||
# Our tests mock an Awair Gen 1 device, which should never return
|
||||
# PM10 sensor readings. Assert that we didn't create a pm10 sensor,
|
||||
# which could happen if someone were ever to refactor incorrectly.
|
||||
assert hass.states.get('sensor.awair_pm10') is None
|
||||
assert hass.states.get("sensor.awair_pm10") is None
|
||||
|
||||
|
||||
async def test_availability(hass):
|
||||
"""Ensure that we mark the component available/unavailable correctly."""
|
||||
await setup_awair(hass)
|
||||
|
||||
assert hass.states.get('sensor.awair_score').state == '78'
|
||||
assert hass.states.get("sensor.awair_score").state == "78"
|
||||
|
||||
future = NOW + timedelta(minutes=30)
|
||||
data_patch = patch('python_awair.AwairClient.air_data_latest',
|
||||
return_value=mock_coro(AIR_DATA_FIXTURE))
|
||||
data_patch = patch(
|
||||
"python_awair.AwairClient.air_data_latest",
|
||||
return_value=mock_coro(AIR_DATA_FIXTURE),
|
||||
)
|
||||
|
||||
with data_patch, alter_time(future):
|
||||
async_fire_time_changed(hass, future)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert hass.states.get('sensor.awair_score').state == STATE_UNAVAILABLE
|
||||
assert hass.states.get("sensor.awair_score").state == STATE_UNAVAILABLE
|
||||
|
||||
future = NOW + timedelta(hours=1)
|
||||
fixture = AIR_DATA_FIXTURE_UPDATED
|
||||
fixture[0][ATTR_TIMESTAMP] = str(future)
|
||||
data_patch = patch('python_awair.AwairClient.air_data_latest',
|
||||
return_value=mock_coro(fixture))
|
||||
data_patch = patch(
|
||||
"python_awair.AwairClient.air_data_latest",
|
||||
return_value=mock_coro(fixture)
|
||||
)
|
||||
|
||||
with data_patch, alter_time(future):
|
||||
async_fire_time_changed(hass, future)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert hass.states.get('sensor.awair_score').state == '79'
|
||||
assert hass.states.get("sensor.awair_score").state == "79"
|
||||
|
||||
|
||||
async def test_async_update(hass):
|
||||
@@ -243,21 +258,23 @@ async def test_async_update(hass):
|
||||
await setup_awair(hass)
|
||||
|
||||
future = NOW + timedelta(minutes=10)
|
||||
data_patch = patch('python_awair.AwairClient.air_data_latest',
|
||||
return_value=mock_coro(AIR_DATA_FIXTURE_UPDATED))
|
||||
data_patch = patch(
|
||||
"python_awair.AwairClient.air_data_latest",
|
||||
return_value=mock_coro(AIR_DATA_FIXTURE_UPDATED),
|
||||
)
|
||||
|
||||
with data_patch, alter_time(future):
|
||||
async_fire_time_changed(hass, future)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
score_sensor = hass.states.get('sensor.awair_score')
|
||||
assert score_sensor.state == '79'
|
||||
score_sensor = hass.states.get("sensor.awair_score")
|
||||
assert score_sensor.state == "79"
|
||||
|
||||
assert hass.states.get('sensor.awair_temperature').state == '23.4'
|
||||
assert hass.states.get('sensor.awair_humidity').state == '33.73'
|
||||
assert hass.states.get('sensor.awair_co2').state == '613'
|
||||
assert hass.states.get('sensor.awair_voc').state == '1013'
|
||||
assert hass.states.get('sensor.awair_pm25').state == '7.2'
|
||||
assert hass.states.get("sensor.awair_temperature").state == "23.4"
|
||||
assert hass.states.get("sensor.awair_humidity").state == "33.73"
|
||||
assert hass.states.get("sensor.awair_co2").state == "613"
|
||||
assert hass.states.get("sensor.awair_voc").state == "1013"
|
||||
assert hass.states.get("sensor.awair_pm2_5").state == "7.2"
|
||||
|
||||
|
||||
async def test_throttle_async_update(hass):
|
||||
@@ -265,18 +282,20 @@ async def test_throttle_async_update(hass):
|
||||
await setup_awair(hass)
|
||||
|
||||
future = NOW + timedelta(minutes=1)
|
||||
data_patch = patch('python_awair.AwairClient.air_data_latest',
|
||||
return_value=mock_coro(AIR_DATA_FIXTURE_UPDATED))
|
||||
data_patch = patch(
|
||||
"python_awair.AwairClient.air_data_latest",
|
||||
return_value=mock_coro(AIR_DATA_FIXTURE_UPDATED),
|
||||
)
|
||||
|
||||
with data_patch, alter_time(future):
|
||||
async_fire_time_changed(hass, future)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert hass.states.get('sensor.awair_score').state == '78'
|
||||
assert hass.states.get("sensor.awair_score").state == "78"
|
||||
|
||||
future = NOW + timedelta(minutes=15)
|
||||
with data_patch, alter_time(future):
|
||||
async_fire_time_changed(hass, future)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert hass.states.get('sensor.awair_score').state == '79'
|
||||
assert hass.states.get("sensor.awair_score").state == "79"
|
||||
@@ -8,12 +8,12 @@ from tests.common import get_test_home_assistant
|
||||
|
||||
|
||||
TEST_DIR = os.path.join(os.path.dirname(__file__))
|
||||
TEST_FILE = os.path.join(TEST_DIR, 'mock_file_test_filesize.txt')
|
||||
TEST_FILE = os.path.join(TEST_DIR, "mock_file_test_filesize.txt")
|
||||
|
||||
|
||||
def create_file(path):
|
||||
"""Create a test file."""
|
||||
with open(path, 'w') as test_file:
|
||||
with open(path, "w") as test_file:
|
||||
test_file.write("test")
|
||||
|
||||
|
||||
@@ -34,23 +34,23 @@ class TestFileSensor(unittest.TestCase):
|
||||
def test_invalid_path(self):
|
||||
"""Test that an invalid path is caught."""
|
||||
config = {
|
||||
'sensor': {
|
||||
'platform': 'filesize',
|
||||
CONF_FILE_PATHS: ['invalid_path']}
|
||||
"sensor": {
|
||||
"platform": "filesize", CONF_FILE_PATHS: ["invalid_path"]
|
||||
}
|
||||
}
|
||||
assert setup_component(self.hass, 'sensor', config)
|
||||
assert setup_component(self.hass, "sensor", config)
|
||||
assert len(self.hass.states.entity_ids()) == 0
|
||||
|
||||
def test_valid_path(self):
|
||||
"""Test for a valid path."""
|
||||
create_file(TEST_FILE)
|
||||
config = {
|
||||
'sensor': {
|
||||
'platform': 'filesize',
|
||||
CONF_FILE_PATHS: [TEST_FILE]}
|
||||
"sensor": {
|
||||
"platform": "filesize", CONF_FILE_PATHS: [TEST_FILE]
|
||||
}
|
||||
}
|
||||
assert setup_component(self.hass, 'sensor', config)
|
||||
assert setup_component(self.hass, "sensor", config)
|
||||
assert len(self.hass.states.entity_ids()) == 1
|
||||
state = self.hass.states.get('sensor.mock_file_test_filesizetxt')
|
||||
assert state.state == '0.0'
|
||||
assert state.attributes.get('bytes') == 4
|
||||
state = self.hass.states.get("sensor.mock_file_test_filesize_txt")
|
||||
assert state.state == "0.0"
|
||||
assert state.attributes.get("bytes") == 4
|
||||
@@ -32,7 +32,7 @@ async def test_default_setup(hass, aioclient_mock):
|
||||
metrics = {'co2': ['1232.0', 'ppm'],
|
||||
'temperature': ['21.1', TEMP_CELSIUS],
|
||||
'humidity': ['49.5', '%'],
|
||||
'pm25': ['144.8', 'µg/m3'],
|
||||
'pm2_5': ['144.8', 'µg/m3'],
|
||||
'voc': ['340.7', 'ppb'],
|
||||
'index': ['138.9', '%']}
|
||||
|
||||
|
||||
@@ -155,7 +155,7 @@ class TestHDDTempSensor(unittest.TestCase):
|
||||
"""Test hddtemp one disk configuration."""
|
||||
assert setup_component(self.hass, 'sensor', VALID_CONFIG_ONE_DISK)
|
||||
|
||||
state = self.hass.states.get('sensor.hd_temperature_devsdd1')
|
||||
state = self.hass.states.get('sensor.hd_temperature_dev_sdd1')
|
||||
|
||||
reference = self.reference[state.attributes.get('device')]
|
||||
|
||||
@@ -173,7 +173,7 @@ class TestHDDTempSensor(unittest.TestCase):
|
||||
assert setup_component(self.hass, 'sensor', VALID_CONFIG_WRONG_DISK)
|
||||
|
||||
assert len(self.hass.states.all()) == 1
|
||||
state = self.hass.states.get('sensor.hd_temperature_devsdx1')
|
||||
state = self.hass.states.get('sensor.hd_temperature_dev_sdx1')
|
||||
assert state.attributes.get('friendly_name') == \
|
||||
'HD Temperature ' + '/dev/sdx1'
|
||||
|
||||
@@ -183,9 +183,9 @@ class TestHDDTempSensor(unittest.TestCase):
|
||||
assert setup_component(self.hass,
|
||||
'sensor', VALID_CONFIG_MULTIPLE_DISKS)
|
||||
|
||||
for sensor in ['sensor.hd_temperature_devsda1',
|
||||
'sensor.hd_temperature_devsdb1',
|
||||
'sensor.hd_temperature_devsdc1']:
|
||||
for sensor in ['sensor.hd_temperature_dev_sda1',
|
||||
'sensor.hd_temperature_dev_sdb1',
|
||||
'sensor.hd_temperature_dev_sdc1']:
|
||||
|
||||
state = self.hass.states.get(sensor)
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ class TestOpenHardwareMonitorSetup(unittest.TestCase):
|
||||
assert len(entities) == 38
|
||||
|
||||
state = self.hass.states.get(
|
||||
'sensor.testpc_intel_core_i77700_clocks_bus_speed')
|
||||
'sensor.test_pc_intel_core_i7_7700_clocks_bus_speed')
|
||||
|
||||
assert state is not None
|
||||
assert state.state == '100'
|
||||
@@ -47,51 +47,51 @@ def test_capped_setup(hass, aioclient_mock):
|
||||
|
||||
yield from async_setup_component(hass, 'sensor', {'sensor': config})
|
||||
|
||||
state = hass.states.get('sensor.startca_usage_ratio')
|
||||
state = hass.states.get('sensor.start_ca_usage_ratio')
|
||||
assert state.attributes.get('unit_of_measurement') == '%'
|
||||
assert state.state == '76.24'
|
||||
|
||||
state = hass.states.get('sensor.startca_usage')
|
||||
state = hass.states.get('sensor.start_ca_usage')
|
||||
assert state.attributes.get('unit_of_measurement') == 'GB'
|
||||
assert state.state == '304.95'
|
||||
|
||||
state = hass.states.get('sensor.startca_data_limit')
|
||||
state = hass.states.get('sensor.start_ca_data_limit')
|
||||
assert state.attributes.get('unit_of_measurement') == 'GB'
|
||||
assert state.state == '400'
|
||||
|
||||
state = hass.states.get('sensor.startca_used_download')
|
||||
state = hass.states.get('sensor.start_ca_used_download')
|
||||
assert state.attributes.get('unit_of_measurement') == 'GB'
|
||||
assert state.state == '304.95'
|
||||
|
||||
state = hass.states.get('sensor.startca_used_upload')
|
||||
state = hass.states.get('sensor.start_ca_used_upload')
|
||||
assert state.attributes.get('unit_of_measurement') == 'GB'
|
||||
assert state.state == '6.48'
|
||||
|
||||
state = hass.states.get('sensor.startca_used_total')
|
||||
state = hass.states.get('sensor.start_ca_used_total')
|
||||
assert state.attributes.get('unit_of_measurement') == 'GB'
|
||||
assert state.state == '311.43'
|
||||
|
||||
state = hass.states.get('sensor.startca_grace_download')
|
||||
state = hass.states.get('sensor.start_ca_grace_download')
|
||||
assert state.attributes.get('unit_of_measurement') == 'GB'
|
||||
assert state.state == '304.95'
|
||||
|
||||
state = hass.states.get('sensor.startca_grace_upload')
|
||||
state = hass.states.get('sensor.start_ca_grace_upload')
|
||||
assert state.attributes.get('unit_of_measurement') == 'GB'
|
||||
assert state.state == '6.48'
|
||||
|
||||
state = hass.states.get('sensor.startca_grace_total')
|
||||
state = hass.states.get('sensor.start_ca_grace_total')
|
||||
assert state.attributes.get('unit_of_measurement') == 'GB'
|
||||
assert state.state == '311.43'
|
||||
|
||||
state = hass.states.get('sensor.startca_total_download')
|
||||
state = hass.states.get('sensor.start_ca_total_download')
|
||||
assert state.attributes.get('unit_of_measurement') == 'GB'
|
||||
assert state.state == '304.95'
|
||||
|
||||
state = hass.states.get('sensor.startca_total_upload')
|
||||
state = hass.states.get('sensor.start_ca_total_upload')
|
||||
assert state.attributes.get('unit_of_measurement') == 'GB'
|
||||
assert state.state == '6.48'
|
||||
|
||||
state = hass.states.get('sensor.startca_remaining')
|
||||
state = hass.states.get('sensor.start_ca_remaining')
|
||||
assert state.attributes.get('unit_of_measurement') == 'GB'
|
||||
assert state.state == '95.05'
|
||||
|
||||
@@ -138,51 +138,51 @@ def test_unlimited_setup(hass, aioclient_mock):
|
||||
|
||||
yield from async_setup_component(hass, 'sensor', {'sensor': config})
|
||||
|
||||
state = hass.states.get('sensor.startca_usage_ratio')
|
||||
state = hass.states.get('sensor.start_ca_usage_ratio')
|
||||
assert state.attributes.get('unit_of_measurement') == '%'
|
||||
assert state.state == '0'
|
||||
|
||||
state = hass.states.get('sensor.startca_usage')
|
||||
state = hass.states.get('sensor.start_ca_usage')
|
||||
assert state.attributes.get('unit_of_measurement') == 'GB'
|
||||
assert state.state == '0.0'
|
||||
|
||||
state = hass.states.get('sensor.startca_data_limit')
|
||||
state = hass.states.get('sensor.start_ca_data_limit')
|
||||
assert state.attributes.get('unit_of_measurement') == 'GB'
|
||||
assert state.state == 'inf'
|
||||
|
||||
state = hass.states.get('sensor.startca_used_download')
|
||||
state = hass.states.get('sensor.start_ca_used_download')
|
||||
assert state.attributes.get('unit_of_measurement') == 'GB'
|
||||
assert state.state == '0.0'
|
||||
|
||||
state = hass.states.get('sensor.startca_used_upload')
|
||||
state = hass.states.get('sensor.start_ca_used_upload')
|
||||
assert state.attributes.get('unit_of_measurement') == 'GB'
|
||||
assert state.state == '0.0'
|
||||
|
||||
state = hass.states.get('sensor.startca_used_total')
|
||||
state = hass.states.get('sensor.start_ca_used_total')
|
||||
assert state.attributes.get('unit_of_measurement') == 'GB'
|
||||
assert state.state == '0.0'
|
||||
|
||||
state = hass.states.get('sensor.startca_grace_download')
|
||||
state = hass.states.get('sensor.start_ca_grace_download')
|
||||
assert state.attributes.get('unit_of_measurement') == 'GB'
|
||||
assert state.state == '304.95'
|
||||
|
||||
state = hass.states.get('sensor.startca_grace_upload')
|
||||
state = hass.states.get('sensor.start_ca_grace_upload')
|
||||
assert state.attributes.get('unit_of_measurement') == 'GB'
|
||||
assert state.state == '6.48'
|
||||
|
||||
state = hass.states.get('sensor.startca_grace_total')
|
||||
state = hass.states.get('sensor.start_ca_grace_total')
|
||||
assert state.attributes.get('unit_of_measurement') == 'GB'
|
||||
assert state.state == '311.43'
|
||||
|
||||
state = hass.states.get('sensor.startca_total_download')
|
||||
state = hass.states.get('sensor.start_ca_total_download')
|
||||
assert state.attributes.get('unit_of_measurement') == 'GB'
|
||||
assert state.state == '304.95'
|
||||
|
||||
state = hass.states.get('sensor.startca_total_upload')
|
||||
state = hass.states.get('sensor.start_ca_total_upload')
|
||||
assert state.attributes.get('unit_of_measurement') == 'GB'
|
||||
assert state.state == '6.48'
|
||||
|
||||
state = hass.states.get('sensor.startca_remaining')
|
||||
state = hass.states.get('sensor.start_ca_remaining')
|
||||
assert state.attributes.get('unit_of_measurement') == 'GB'
|
||||
assert state.state == 'inf'
|
||||
|
||||
|
||||
Reference in new issue
Block a user