Beispiel #1
0
    def test_turn_on(self):
        """ Test turn_on"""
        turn_on_calls = mock_service(self.hass, remote.DOMAIN, SERVICE_TURN_ON)

        remote.turn_on(self.hass, entity_id='entity_id_val')

        self.hass.block_till_done()

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

        self.assertEqual(remote.DOMAIN, call.domain)
Beispiel #2
0
    def test_services(self):
        """Test the provided services."""

        # Test turn_on
        turn_on_calls = mock_service(
            self.hass, remote.DOMAIN, SERVICE_TURN_ON)

        remote.turn_on(
            self.hass,
            entity_id='entity_id_val')

        self.hass.block_till_done()

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

        self.assertEqual(remote.DOMAIN, call.domain)

        # Test turn_off
        turn_off_calls = mock_service(
            self.hass, remote.DOMAIN, SERVICE_TURN_OFF)

        remote.turn_off(
            self.hass, entity_id='entity_id_val')

        self.hass.block_till_done()

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

        self.assertEqual(remote.DOMAIN, call.domain)
        self.assertEqual(SERVICE_TURN_OFF, call.service)
        self.assertEqual('entity_id_val', call.data[ATTR_ENTITY_ID])

        # Test send_command
        send_command_calls = mock_service(
            self.hass, remote.DOMAIN, SERVICE_SEND_COMMAND)

        remote.send_command(
            self.hass, entity_id='entity_id_val',
            device='test_device', command='test_command')

        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 #3
0
    def test_services(self):
        """Test the provided services."""
        # Test turn_on
        turn_on_calls = mock_service(
            self.hass, remote.DOMAIN, SERVICE_TURN_ON)

        remote.turn_on(
            self.hass,
            entity_id='entity_id_val')

        self.hass.block_till_done()

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

        self.assertEqual(remote.DOMAIN, call.domain)

        # Test turn_off
        turn_off_calls = mock_service(
            self.hass, remote.DOMAIN, SERVICE_TURN_OFF)

        remote.turn_off(
            self.hass, entity_id='entity_id_val')

        self.hass.block_till_done()

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

        self.assertEqual(remote.DOMAIN, call.domain)
        self.assertEqual(SERVICE_TURN_OFF, call.service)
        self.assertEqual('entity_id_val', call.data[ATTR_ENTITY_ID])

        # Test send_command
        send_command_calls = mock_service(
            self.hass, remote.DOMAIN, SERVICE_SEND_COMMAND)

        remote.send_command(
            self.hass, entity_id='entity_id_val',
            device='test_device', command='test_command')

        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_turn_on(self):
        """ Test turn_on"""
        turn_on_calls = mock_service(
            self.hass, remote.DOMAIN, SERVICE_TURN_ON)

        remote.turn_on(
            self.hass,
            entity_id='entity_id_val')

        self.hass.block_till_done()

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

        self.assertEqual(remote.DOMAIN, call.domain)
    def test_methods(self):
        """Test if services call the entity methods as expected."""
        remote.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)

        remote.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)

        remote.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)

        remote.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'})
Beispiel #6
0
    def test_methods(self):
        """Test if services call the entity methods as expected."""
        remote.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)

        remote.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)

        remote.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)

        remote.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'})