def test_get_significant_states_include_exclude(opp_history): """Test if significant states when in/excluding domains and entities. We should only get back changes of the media_player.test2 entity. """ opp = opp_history zero, four, states = record_states(opp) 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"], }, }, }) check_significant_states(opp, zero, four, states, config)
def test_get_significant_states_exclude_include_entity(opp_history): """Test significant states when excluding domains and include entities. We should not get back every thermostat and media player test changes. """ opp = opp_history zero, four, states = record_states(opp) 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"] }, }, }) check_significant_states(opp, zero, four, states, config)
def test_get_significant_states_include_exclude_entity(opp_history): """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. """ opp = opp_history zero, four, states = record_states(opp) 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"] }, }, }) check_significant_states(opp, 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({ op.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_setup(self): """Test setup method of history.""" config = history.CONFIG_SCHEMA({ # op.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.opp, 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({ op.DOMAIN: {}, history.DOMAIN: { history.CONF_EXCLUDE: { history.CONF_ENTITIES: ["media_player.test"] } }, }) self.check_significant_states(zero, four, states, config)
def opp_history(opp_recorder): """Open Peer Power fixture with history.""" opp = opp_recorder() config = history.CONFIG_SCHEMA({ 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"], }, } }) assert setup_component(opp, history.DOMAIN, config) yield opp
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({ op.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({ op.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({ op.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_domain(opp_history): """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. """ opp = opp_history zero, four, states = record_states(opp) 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_EXCLUDE: { history.CONF_DOMAINS: ["media_player"] } }, }) check_significant_states(opp, zero, four, states, config)