Ejemplo n.º 1
0
    def test_select_option(self):
        """Test select_option methods."""
        self.assertTrue(
            setup_component(self.hass, DOMAIN, {DOMAIN: {
                'test_1': {
                    'options': [
                        'some option',
                        'another option',
                    ],
                },
            }}))
        entity_id = 'input_select.test_1'

        state = self.hass.states.get(entity_id)
        self.assertEqual('some option', state.state)

        select_option(self.hass, entity_id, 'another option')
        self.hass.block_till_done()

        state = self.hass.states.get(entity_id)
        self.assertEqual('another option', state.state)

        select_option(self.hass, entity_id, 'non existing option')
        self.hass.block_till_done()

        state = self.hass.states.get(entity_id)
        self.assertEqual('another option', state.state)
Ejemplo n.º 2
0
    def test_select_option(self):
        """Test select_option methods."""
        self.assertTrue(
            setup_component(
                self.hass, DOMAIN, {
                    DOMAIN: {
                        'test_1': {
                            'options': [
                                'some option',
                                'another option',
                            ],
                        },
                    }
                }))
        entity_id = 'input_select.test_1'

        state = self.hass.states.get(entity_id)
        self.assertEqual('some option', state.state)

        select_option(self.hass, entity_id, 'another option')
        self.hass.block_till_done()

        state = self.hass.states.get(entity_id)
        self.assertEqual('another option', state.state)

        select_option(self.hass, entity_id, 'non existing option')
        self.hass.block_till_done()

        state = self.hass.states.get(entity_id)
        self.assertEqual('another option', state.state)
Ejemplo n.º 3
0
    def test_set_options_service(self):
        """Test set_options service."""
        self.assertTrue(
            setup_component(self.hass, DOMAIN, {DOMAIN: {
                'test_1': {
                    'options': [
                        'first option',
                        'middle option',
                        'last option',
                    ],
                    'initial': 'middle option',
                },
            }}))
        entity_id = 'input_select.test_1'

        state = self.hass.states.get(entity_id)
        self.assertEqual('middle option', state.state)

        data = {ATTR_OPTIONS: ["test1", "test2"], "entity_id": entity_id}
        self.hass.services.call(DOMAIN, SERVICE_SET_OPTIONS, data)
        self.hass.block_till_done()

        state = self.hass.states.get(entity_id)
        self.assertEqual('test1', state.state)

        select_option(self.hass, entity_id, 'first option')
        self.hass.block_till_done()
        state = self.hass.states.get(entity_id)
        self.assertEqual('test1', state.state)

        select_option(self.hass, entity_id, 'test2')
        self.hass.block_till_done()
        state = self.hass.states.get(entity_id)
        self.assertEqual('test2', state.state)