def test_methods(self):
        """Test if services call the entity methods as expected."""
        common.turn_on(self.hass, entity_id=ENTITY_ID)
        self.hass.block_till_done()
        state = self.hass.states.get(ENTITY_ID)
        assert state.state == STATE_ON

        common.turn_off(self.hass, entity_id=ENTITY_ID)
        self.hass.block_till_done()
        state = self.hass.states.get(ENTITY_ID)
        assert state.state == STATE_OFF

        common.turn_on(self.hass, entity_id=ENTITY_ID)
        self.hass.block_till_done()
        state = self.hass.states.get(ENTITY_ID)
        assert state.state == STATE_ON

        common.send_command(self.hass, 'test', entity_id=ENTITY_ID)
        self.hass.block_till_done()
        state = self.hass.states.get(ENTITY_ID)
        assert state.attributes == {
            'friendly_name': 'Remote One',
            'last_command_sent': 'test',
            'supported_features': 0
        }
    def test_methods(self):
        """Test if services call the entity methods as expected."""
        common.turn_on(self.opp, entity_id=ENTITY_ID)
        self.opp.block_till_done()
        state = self.opp.states.get(ENTITY_ID)
        assert state.state == STATE_ON

        common.turn_off(self.opp, entity_id=ENTITY_ID)
        self.opp.block_till_done()
        state = self.opp.states.get(ENTITY_ID)
        assert state.state == STATE_OFF

        common.turn_on(self.opp, entity_id=ENTITY_ID)
        self.opp.block_till_done()
        state = self.opp.states.get(ENTITY_ID)
        assert state.state == STATE_ON

        common.send_command(self.opp, "test", entity_id=ENTITY_ID)
        self.opp.block_till_done()
        state = self.opp.states.get(ENTITY_ID)
        assert state.attributes == {
            "friendly_name": "Remote One",
            "last_command_sent": "test",
            "supported_features": 0,
        }
Beispiel #3
0
    def test_send_command(self):
        """Test send_command."""
        send_command_calls = mock_service(
            self.hass, remote.DOMAIN, SERVICE_SEND_COMMAND)

        common.send_command(
            self.hass, entity_id='entity_id_val',
            device='test_device', command=['test_command'],
            num_repeats='4', delay_secs='0.6')

        self.hass.block_till_done()

        self.assertEqual(1, len(send_command_calls))
        call = send_command_calls[-1]

        self.assertEqual(remote.DOMAIN, call.domain)
        self.assertEqual(SERVICE_SEND_COMMAND, call.service)
        self.assertEqual('entity_id_val', call.data[ATTR_ENTITY_ID])
Beispiel #4
0
    def test_send_command(self):
        """Test send_command."""
        send_command_calls = mock_service(
            self.hass, remote.DOMAIN, SERVICE_SEND_COMMAND)

        common.send_command(
            self.hass, entity_id='entity_id_val',
            device='test_device', command=['test_command'],
            num_repeats='4', delay_secs='0.6')

        self.hass.block_till_done()

        assert 1 == len(send_command_calls)
        call = send_command_calls[-1]

        assert remote.DOMAIN == call.domain
        assert SERVICE_SEND_COMMAND == call.service
        assert 'entity_id_val' == call.data[ATTR_ENTITY_ID]
Beispiel #5
0
    def test_send_command(self):
        """Test send_command."""
        send_command_calls = mock_service(self.hass, remote.DOMAIN,
                                          SERVICE_SEND_COMMAND)

        common.send_command(self.hass,
                            entity_id='entity_id_val',
                            device='test_device',
                            command=['test_command'],
                            num_repeats='4',
                            delay_secs='0.6')

        self.hass.block_till_done()

        self.assertEqual(1, len(send_command_calls))
        call = send_command_calls[-1]

        self.assertEqual(remote.DOMAIN, call.domain)
        self.assertEqual(SERVICE_SEND_COMMAND, call.service)
        self.assertEqual('entity_id_val', call.data[ATTR_ENTITY_ID])
    def test_send_command(self):
        """Test send_command."""
        send_command_calls = mock_service(self.hass, remote.DOMAIN,
                                          SERVICE_SEND_COMMAND)

        common.send_command(
            self.hass,
            entity_id="entity_id_val",
            device="test_device",
            command=["test_command"],
            num_repeats="4",
            delay_secs="0.6",
        )

        self.hass.block_till_done()

        assert len(send_command_calls) == 1
        call = send_command_calls[-1]

        assert call.domain == remote.DOMAIN
        assert call.service == SERVICE_SEND_COMMAND
        assert call.data[ATTR_ENTITY_ID] == "entity_id_val"
    def test_methods(self):
        """Test if services call the entity methods as expected."""
        common.turn_on(self.hass, entity_id=ENTITY_ID)
        self.hass.block_till_done()
        state = self.hass.states.get(ENTITY_ID)
        assert state.state == STATE_ON

        common.turn_off(self.hass, entity_id=ENTITY_ID)
        self.hass.block_till_done()
        state = self.hass.states.get(ENTITY_ID)
        assert state.state == STATE_OFF

        common.turn_on(self.hass, entity_id=ENTITY_ID)
        self.hass.block_till_done()
        state = self.hass.states.get(ENTITY_ID)
        assert state.state == STATE_ON

        common.send_command(self.hass, 'test', entity_id=ENTITY_ID)
        self.hass.block_till_done()
        state = self.hass.states.get(ENTITY_ID)
        assert state.attributes == \
            {'friendly_name': 'Remote One', 'last_command_sent': 'test'}
Beispiel #8
0
    def test_methods(self):
        """Test if services call the entity methods as expected."""
        common.turn_on(self.hass, entity_id=ENTITY_ID)
        self.hass.block_till_done()
        state = self.hass.states.get(ENTITY_ID)
        self.assertEqual(state.state, STATE_ON)

        common.turn_off(self.hass, entity_id=ENTITY_ID)
        self.hass.block_till_done()
        state = self.hass.states.get(ENTITY_ID)
        self.assertEqual(state.state, STATE_OFF)

        common.turn_on(self.hass, entity_id=ENTITY_ID)
        self.hass.block_till_done()
        state = self.hass.states.get(ENTITY_ID)
        self.assertEqual(state.state, STATE_ON)

        common.send_command(self.hass, 'test', entity_id=ENTITY_ID)
        self.hass.block_till_done()
        state = self.hass.states.get(ENTITY_ID)
        self.assertEqual(state.attributes, {
            'friendly_name': 'Remote One',
            'last_command_sent': 'test'
        })