def test_get_significant_states_include_exclude(self): """Test if significant states when in/excluding domains and entities. We should only get back changes of the media_player.test2 entity. """ zero, four, states = self.record_states() del states["media_player.test"] del states["thermostat.test"] del states["thermostat.test2"] del states["script.can_cancel_this_one"] config = history.CONFIG_SCHEMA({ ha.DOMAIN: {}, history.DOMAIN: { history.CONF_INCLUDE: { history.CONF_DOMAINS: ["media_player"], history.CONF_ENTITIES: ["thermostat.test"], }, history.CONF_EXCLUDE: { history.CONF_DOMAINS: ["thermostat"], history.CONF_ENTITIES: ["media_player.test"], }, }, }) self.check_significant_states(zero, four, states, config)
def test_get_significant_states_include_exclude_domain(self): """Test if significant states when excluding and including domains. We should not get back any changes since we include only the media_player domain but also exclude it. """ zero, four, states = self.record_states() del states['media_player.test'] del states['media_player.test2'] del states['thermostat.test'] del states['thermostat.test2'] del states['script.can_cancel_this_one'] config = history.CONFIG_SCHEMA({ ha.DOMAIN: {}, history.DOMAIN: { history.CONF_INCLUDE: { history.CONF_DOMAINS: ['media_player'] }, history.CONF_EXCLUDE: { history.CONF_DOMAINS: ['media_player'] } } }) self.check_significant_states(zero, four, states, config)
def test_get_significant_states_include_exclude_entity(self): """Test if significant states when excluding and including domains. We should not get back any changes since we include only media_player.test but also exclude it. """ zero, four, states = self.record_states() del states["media_player.test"] del states["media_player.test2"] del states["media_player.test3"] del states["thermostat.test"] del states["thermostat.test2"] del states["script.can_cancel_this_one"] config = history.CONFIG_SCHEMA({ ha.DOMAIN: {}, history.DOMAIN: { history.CONF_INCLUDE: { history.CONF_ENTITIES: ["media_player.test"] }, history.CONF_EXCLUDE: { history.CONF_ENTITIES: ["media_player.test"] }, }, }) self.check_significant_states(zero, four, states, config)
def test_get_significant_states_include_exclude_domain(hass_history): """Test if significant states when excluding and including domains. We should not get back any changes since we include only the media_player domain but also exclude it. """ hass = hass_history zero, four, states = record_states(hass) del states["media_player.test"] del states["media_player.test2"] del states["media_player.test3"] del states["thermostat.test"] del states["thermostat.test2"] del states["script.can_cancel_this_one"] config = history.CONFIG_SCHEMA({ ha.DOMAIN: {}, history.DOMAIN: { history.CONF_INCLUDE: { history.CONF_DOMAINS: ["media_player"] }, history.CONF_EXCLUDE: { history.CONF_DOMAINS: ["media_player"] }, }, }) check_significant_states(hass, zero, four, states, config)
def test_get_significant_states_exclude_include_entity(self): """Test significant states when excluding domains and include entities. We should not get back every thermostat and media player test changes. """ zero, four, states = self.record_states() del states["media_player.test2"] del states["media_player.test3"] del states["thermostat.test"] del states["thermostat.test2"] del states["script.can_cancel_this_one"] config = history.CONFIG_SCHEMA({ ha.DOMAIN: {}, history.DOMAIN: { history.CONF_INCLUDE: { history.CONF_ENTITIES: ["media_player.test", "thermostat.test"] }, history.CONF_EXCLUDE: { history.CONF_DOMAINS: ["thermostat"] }, }, }) self.check_significant_states(zero, four, states, config)
def test_setup(self): """Test setup method of history.""" mock_http_component(self.hass) config = history.CONFIG_SCHEMA({ ha.DOMAIN: {}, history.DOMAIN: {history.CONF_INCLUDE: { history.CONF_DOMAINS: ['media_player'], history.CONF_ENTITIES: ['thermostat.test']}, history.CONF_EXCLUDE: { history.CONF_DOMAINS: ['thermostat'], history.CONF_ENTITIES: ['media_player.test']}}}) self.assertTrue(setup_component(self.hass, history.DOMAIN, config))
def test_setup(self): """Test setup method of history.""" config = history.CONFIG_SCHEMA({ # ha.DOMAIN: {}, history.DOMAIN: { history.CONF_INCLUDE: { history.CONF_DOMAINS: ['media_player'], history.CONF_ENTITIES: ['thermostat.test']}, history.CONF_EXCLUDE: { history.CONF_DOMAINS: ['thermostat'], history.CONF_ENTITIES: ['media_player.test']}}}) self.init_recorder() assert setup_component(self.hass, history.DOMAIN, config)
def test_get_significant_states_exclude_entity(self): """Test if significant states are returned when excluding entities. We should get back every thermostat and script changes, but no media player changes. """ zero, four, states = self.record_states() del states['media_player.test'] config = history.CONFIG_SCHEMA({ ha.DOMAIN: {}, history.DOMAIN: {history.CONF_EXCLUDE: { history.CONF_ENTITIES: ['media_player.test', ]}}}) self.check_significant_states(zero, four, states, config)
def test_get_significant_states_include_domain(self): """Test if significant states are returned when including domains. We should get back every thermostat and script changes, but no media player changes. """ zero, four, states = self.record_states() del states['media_player.test'] del states['media_player.test2'] config = history.CONFIG_SCHEMA({ ha.DOMAIN: {}, history.DOMAIN: {history.CONF_INCLUDE: { history.CONF_DOMAINS: ['thermostat', 'script']}}}) self.check_significant_states(zero, four, states, config)
def test_get_significant_states_include(self): """Test significant states when including domains and entities. We should only get back changes of the media_player.test entity and the thermostat domain. """ zero, four, states = self.record_states() del states['media_player.test2'] del states['script.can_cancel_this_one'] config = history.CONFIG_SCHEMA({ ha.DOMAIN: {}, history.DOMAIN: {history.CONF_INCLUDE: { history.CONF_DOMAINS: ['thermostat'], history.CONF_ENTITIES: ['media_player.test']}}}) self.check_significant_states(zero, four, states, config)
def test_get_significant_states_exclude(self): """Test significant states when excluding entities and domains. We should not get back every thermostat and media player test changes. """ zero, four, states = self.record_states() del states['media_player.test'] del states['thermostat.test'] del states['thermostat.test2'] config = history.CONFIG_SCHEMA({ ha.DOMAIN: {}, history.DOMAIN: {history.CONF_EXCLUDE: { history.CONF_DOMAINS: ['thermostat', ], history.CONF_ENTITIES: ['media_player.test', ]}}}) self.check_significant_states(zero, four, states, config)
def test_get_significant_states_exclude_entity(hass_history): """Test if significant states are returned when excluding entities. We should get back every thermostat and script changes, but no media player changes. """ hass = hass_history zero, four, states = record_states(hass) del states["media_player.test"] config = history.CONFIG_SCHEMA({ ha.DOMAIN: {}, history.DOMAIN: { history.CONF_EXCLUDE: { history.CONF_ENTITIES: ["media_player.test"] } }, }) check_significant_states(hass, zero, four, states, config)
def test_get_significant_states_exclude_domain(self): """Test if significant states are returned when excluding domains. We should get back every thermostat change that includes an attribute change, but no media player changes. """ zero, four, states = self.record_states() del states["media_player.test"] del states["media_player.test2"] config = history.CONFIG_SCHEMA( { ha.DOMAIN: {}, history.DOMAIN: { history.CONF_EXCLUDE: {history.CONF_DOMAINS: ["media_player"]} }, } ) self.check_significant_states(zero, four, states, config)
def hass_history(hass_recorder): """Home Assistant fixture with history.""" hass = hass_recorder() config = history.CONFIG_SCHEMA({ history.DOMAIN: { CONF_INCLUDE: { CONF_DOMAINS: ["media_player"], CONF_ENTITIES: ["thermostat.test"], }, CONF_EXCLUDE: { CONF_DOMAINS: ["thermostat"], CONF_ENTITIES: ["media_player.test"], }, } }) assert setup_component(hass, history.DOMAIN, config) yield hass
def test_get_significant_states_include_domain(hass_history): """Test if significant states are returned when including domains. We should get back every thermostat and script changes, but no media player changes. """ hass = hass_history zero, four, states = record_states(hass) del states["media_player.test"] del states["media_player.test2"] del states["media_player.test3"] config = history.CONFIG_SCHEMA({ ha.DOMAIN: {}, history.DOMAIN: { history.CONF_INCLUDE: { history.CONF_DOMAINS: ["thermostat", "script"] } }, }) check_significant_states(hass, zero, four, states, config)
def test_get_significant_states_exclude(hass_history): """Test significant states when excluding entities and domains. We should not get back every thermostat and media player test changes. """ hass = hass_history zero, four, states = record_states(hass) del states["media_player.test"] del states["thermostat.test"] del states["thermostat.test2"] config = history.CONFIG_SCHEMA({ ha.DOMAIN: {}, history.DOMAIN: { history.CONF_EXCLUDE: { history.CONF_DOMAINS: ["thermostat"], history.CONF_ENTITIES: ["media_player.test"], } }, }) check_significant_states(hass, zero, four, states, config)
def test_get_significant_states_include(hass_history): """Test significant states when including domains and entities. We should only get back changes of the media_player.test entity and the thermostat domain. """ hass = hass_history zero, four, states = record_states(hass) del states["media_player.test2"] del states["media_player.test3"] del states["script.can_cancel_this_one"] config = history.CONFIG_SCHEMA({ ha.DOMAIN: {}, history.DOMAIN: { history.CONF_INCLUDE: { history.CONF_DOMAINS: ["thermostat"], history.CONF_ENTITIES: ["media_player.test"], } }, }) check_significant_states(hass, zero, four, states, config)