async def test_srp_entity_no_coord_data(hass): """Test the SrpEntity.""" fake_coordinator = MagicMock(data=False) srp_entity = SrpEntity(fake_coordinator) srp_entity.hass = hass assert srp_entity.usage is None
async def test_srp_entity_async_update(hass): """Test the SrpEntity.""" async def async_magic(): pass MagicMock.__await__ = lambda x: async_magic().__await__() fake_coordinator = MagicMock(data=False) srp_entity = SrpEntity(fake_coordinator) srp_entity.hass = hass await srp_entity.async_update() assert fake_coordinator.async_request_refresh.called
async def test_srp_entity(hass): """Test the SrpEntity.""" fake_coordinator = MagicMock(data=1.99999999999) srp_entity = SrpEntity(fake_coordinator) srp_entity.hass = hass assert srp_entity is not None assert srp_entity.name == f"{DEFAULT_NAME} {SENSOR_NAME}" assert srp_entity.unique_id == SENSOR_TYPE assert srp_entity.state is None assert srp_entity.unit_of_measurement == ENERGY_KILO_WATT_HOUR assert srp_entity.icon == ICON assert srp_entity.usage == "2.00" assert srp_entity.should_poll is False assert srp_entity.extra_state_attributes[ATTR_ATTRIBUTION] == ATTRIBUTION assert srp_entity.available is not None await srp_entity.async_added_to_hass() assert srp_entity.state is not None assert fake_coordinator.async_add_listener.called assert not fake_coordinator.async_add_listener.data.called
async def test_srp_entity_no_data(hass): """Test the SrpEntity.""" fake_coordinator = MagicMock(data=False) srp_entity = SrpEntity(fake_coordinator) assert srp_entity.device_state_attributes is None