예제 #1
0
    def test_reload_core_with_wrong_conf(self, mock_process, mock_error):
        """Test reload core conf service."""
        files = {config.YAML_CONFIG_FILE: yaml.dump(['invalid', 'config'])}
        with patch_yaml_files(files, True):
            comps.reload_core_config(self.hass)
            self.hass.block_till_done()

        assert mock_error.called
        assert mock_process.called is False
예제 #2
0
    def test_reload_core_with_wrong_conf(self, mock_process, mock_error):
        """Test reload core conf service."""
        files = {
            config.YAML_CONFIG_FILE: yaml.dump(['invalid', 'config'])
        }
        with patch_yaml_files(files, True):
            comps.reload_core_config(self.hass)
            self.hass.block_till_done()

        assert mock_error.called
        assert mock_process.called is False
예제 #3
0
    def test_reload_core_with_wrong_conf(self, mock_process, mock_error):
        """Test reload core conf service."""
        with TemporaryDirectory() as conf_dir:
            self.hass.config.config_dir = conf_dir
            conf_yaml = self.hass.config.path(config.YAML_CONFIG_FILE)

            with open(conf_yaml, 'a') as fp:
                fp.write(yaml.dump(['invalid', 'config']))

            comps.reload_core_config(self.hass)
            self.hass.block_till_done()

        assert mock_error.called
        assert mock_process.called is False
예제 #4
0
    def test_reload_core_with_wrong_conf(self, mock_process, mock_error):
        """Test reload core conf service."""
        with TemporaryDirectory() as conf_dir:
            self.hass.config.config_dir = conf_dir
            conf_yaml = self.hass.config.path(config.YAML_CONFIG_FILE)

            with open(conf_yaml, 'a') as fp:
                fp.write(yaml.dump(['invalid', 'config']))

            comps.reload_core_config(self.hass)
            self.hass.pool.block_till_done()

        assert mock_error.called
        assert mock_process.called is False
예제 #5
0
    def test_reload_core_conf(self):
        """Test reload core conf service."""
        ent = entity.Entity()
        ent.entity_id = 'test.entity'
        ent.hass = self.hass
        ent.update_ha_state()

        state = self.hass.states.get('test.entity')
        assert state is not None
        assert state.state == 'unknown'
        assert state.attributes == {}

        with TemporaryDirectory() as conf_dir:
            self.hass.config.config_dir = conf_dir
            conf_yaml = self.hass.config.path(config.YAML_CONFIG_FILE)

            with open(conf_yaml, 'a') as fp:
                fp.write(
                    yaml.dump({
                        ha.DOMAIN: {
                            'latitude': 10,
                            'longitude': 20,
                            'customize': {
                                'test.Entity': {
                                    'hello': 'world'
                                }
                            }
                        }
                    }))

            comps.reload_core_config(self.hass)
            self.hass.block_till_done()

        assert 10 == self.hass.config.latitude
        assert 20 == self.hass.config.longitude

        ent.update_ha_state()

        state = self.hass.states.get('test.entity')
        assert state is not None
        assert state.state == 'unknown'
        assert state.attributes.get('hello') == 'world'
예제 #6
0
    def test_reload_core_conf(self):
        """Test reload core conf service."""
        ent = entity.Entity()
        ent.entity_id = 'test.entity'
        ent.hass = self.hass
        ent.schedule_update_ha_state()
        self.hass.block_till_done()

        state = self.hass.states.get('test.entity')
        assert state is not None
        assert state.state == 'unknown'
        assert state.attributes == {}

        files = {
            config.YAML_CONFIG_FILE:
            yaml.dump({
                ha.DOMAIN: {
                    'latitude': 10,
                    'longitude': 20,
                    'customize': {
                        'test.Entity': {
                            'hello': 'world'
                        }
                    }
                }
            })
        }
        with patch_yaml_files(files, True):
            comps.reload_core_config(self.hass)
            self.hass.block_till_done()

        assert self.hass.config.latitude == 10
        assert self.hass.config.longitude == 20

        ent.schedule_update_ha_state()
        self.hass.block_till_done()

        state = self.hass.states.get('test.entity')
        assert state is not None
        assert state.state == 'unknown'
        assert state.attributes.get('hello') == 'world'
예제 #7
0
    def test_reload_core_conf(self):
        """Test reload core conf service."""
        ent = entity.Entity()
        ent.entity_id = 'test.entity'
        ent.hass = self.hass
        ent.update_ha_state()

        state = self.hass.states.get('test.entity')
        assert state is not None
        assert state.state == 'unknown'
        assert state.attributes == {}

        with TemporaryDirectory() as conf_dir:
            self.hass.config.config_dir = conf_dir
            conf_yaml = self.hass.config.path(config.YAML_CONFIG_FILE)

            with open(conf_yaml, 'a') as fp:
                fp.write(yaml.dump({
                    ha.DOMAIN: {
                        'latitude': 10,
                        'longitude': 20,
                        'customize': {
                            'test.Entity': {
                                'hello': 'world'
                            }
                        }
                    }
                }))

            comps.reload_core_config(self.hass)
            self.hass.pool.block_till_done()

        assert 10 == self.hass.config.latitude
        assert 20 == self.hass.config.longitude

        ent.update_ha_state()

        state = self.hass.states.get('test.entity')
        assert state is not None
        assert state.state == 'unknown'
        assert state.attributes.get('hello') == 'world'
예제 #8
0
    def test_reload_core_conf(self):
        """Test reload core conf service."""
        ent = entity.Entity()
        ent.entity_id = 'test.entity'
        ent.hass = self.hass
        ent.schedule_update_ha_state()
        self.hass.block_till_done()

        state = self.hass.states.get('test.entity')
        assert state is not None
        assert state.state == 'unknown'
        assert state.attributes == {}

        files = {
            config.YAML_CONFIG_FILE: yaml.dump({
                ha.DOMAIN: {
                    'latitude': 10,
                    'longitude': 20,
                    'customize': {
                        'test.Entity': {
                            'hello': 'world'
                        }
                    }
                }
            })
        }
        with patch_yaml_files(files, True):
            comps.reload_core_config(self.hass)
            self.hass.block_till_done()

        assert 10 == self.hass.config.latitude
        assert 20 == self.hass.config.longitude

        ent.schedule_update_ha_state()
        self.hass.block_till_done()

        state = self.hass.states.get('test.entity')
        assert state is not None
        assert state.state == 'unknown'
        assert state.attributes.get('hello') == 'world'