Exemplo n.º 1
0
    def test_reloading_groups(self):
        """Test reloading the group config."""
        assert setup_component(
            self.hass,
            "group",
            {
                "group": {
                    "second_group": {
                        "entities": "light.Bowl",
                        "icon": "mdi:work",
                        "view": True,
                    },
                    "test_group": "hello.world,sensor.happy",
                    "empty_group": {
                        "name": "Empty Group",
                        "entities": None
                    },
                }
            },
        )

        group.Group.create_group(self.hass,
                                 "all tests", ["test.one", "test.two"],
                                 user_defined=False)

        assert sorted(self.hass.states.entity_ids()) == [
            "group.all_tests",
            "group.empty_group",
            "group.second_group",
            "group.test_group",
        ]
        assert self.hass.bus.listeners["state_changed"] == 3

        with patch(
                "homeassistant.config.load_yaml_config_file",
                return_value={
                    "group": {
                        "hello": {
                            "entities": "light.Bowl",
                            "icon": "mdi:work",
                            "view": True,
                        }
                    }
                },
        ):
            with patch("homeassistant.config.find_config_file",
                       return_value=""):
                common.reload(self.hass)
                self.hass.block_till_done()

        assert sorted(self.hass.states.entity_ids()) == [
            "group.all_tests",
            "group.hello",
        ]
        assert self.hass.bus.listeners["state_changed"] == 2
Exemplo n.º 2
0
    def test_reloading_groups(self):
        """Test reloading the group config."""
        assert setup_component(
            self.hass, 'group', {
                'group': {
                    'second_group': {
                        'entities': 'light.Bowl',
                        'icon': 'mdi:work',
                        'view': True,
                    },
                    'test_group': 'hello.world,sensor.happy',
                    'empty_group': {
                        'name': 'Empty Group',
                        'entities': None
                    },
                }
            })

        group.Group.create_group(self.hass,
                                 'all tests', ['test.one', 'test.two'],
                                 user_defined=False)

        assert sorted(self.hass.states.entity_ids()) == \
            ['group.all_tests', 'group.empty_group', 'group.second_group',
             'group.test_group']
        assert self.hass.bus.listeners['state_changed'] == 3

        with patch('homeassistant.config.load_yaml_config_file',
                   return_value={
                       'group': {
                           'hello': {
                               'entities': 'light.Bowl',
                               'icon': 'mdi:work',
                               'view': True,
                           }
                       }
                   }):
            with patch('homeassistant.config.find_config_file',
                       return_value=''):
                common.reload(self.hass)
                self.hass.block_till_done()

        assert sorted(self.hass.states.entity_ids()) == \
            ['group.all_tests', 'group.hello']
        assert self.hass.bus.listeners['state_changed'] == 2
Exemplo n.º 3
0
    def test_reloading_groups(self):
        """Test reloading the group config."""
        assert setup_component(self.hass, 'group', {'group': {
            'second_group': {
                'entities': 'light.Bowl',
                'icon': 'mdi:work',
                'view': True,
            },
            'test_group': 'hello.world,sensor.happy',
            'empty_group': {'name': 'Empty Group', 'entities': None},
        }})

        group.Group.create_group(
            self.hass, 'all tests',
            ['test.one', 'test.two'],
            user_defined=False)

        assert sorted(self.hass.states.entity_ids()) == \
            ['group.all_tests', 'group.empty_group', 'group.second_group',
             'group.test_group']
        assert self.hass.bus.listeners['state_changed'] == 3

        with patch('homeassistant.config.load_yaml_config_file', return_value={
            'group': {
                'hello': {
                    'entities': 'light.Bowl',
                    'icon': 'mdi:work',
                    'view': True,
                }}}):
            with patch('homeassistant.config.find_config_file',
                       return_value=''):
                common.reload(self.hass)
                self.hass.block_till_done()

        assert sorted(self.hass.states.entity_ids()) == \
            ['group.all_tests', 'group.hello']
        assert self.hass.bus.listeners['state_changed'] == 2