Beispiel #1
0
    def test_resume_program_service(self, mocked_thermostat):
        """Test resume program service."""
        mocked_thermostat.return_value = self.thermostat
        thermostat = mocked_thermostat(self.api, "12345", "F")
        thermostat.resume_program = Mock()
        thermostat.schedule_update_ha_state = Mock()
        thermostat.entity_id = "climate.master_bathroom"

        self.hass.data[nuheat.NUHEAT_DOMAIN] = (self.api, ["12345"])
        nuheat.setup_platform(self.hass, {}, Mock(), {})

        # Explicit entity
        self.hass.services.call(nuheat.DOMAIN, nuheat.SERVICE_RESUME_PROGRAM,
                                {"entity_id": "climate.master_bathroom"}, True)

        thermostat.resume_program.assert_called_with()
        thermostat.schedule_update_ha_state.assert_called_with(True)

        thermostat.resume_program.reset_mock()
        thermostat.schedule_update_ha_state.reset_mock()

        # All entities
        self.hass.services.call(nuheat.DOMAIN, nuheat.SERVICE_RESUME_PROGRAM,
                                {}, True)

        thermostat.resume_program.assert_called_with()
        thermostat.schedule_update_ha_state.assert_called_with(True)
    def test_resume_program_service(self, mocked_thermostat):
        """Test resume program service."""
        mocked_thermostat.return_value = self.thermostat
        thermostat = mocked_thermostat(self.api, "12345", "F")
        thermostat.resume_program = Mock()
        thermostat.schedule_update_ha_state = Mock()
        thermostat.entity_id = "climate.master_bathroom"

        self.hass.data[nuheat.NUHEAT_DOMAIN] = (self.api, ["12345"])
        nuheat.setup_platform(self.hass, {}, Mock(), {})

        # Explicit entity
        self.hass.services.call(nuheat.DOMAIN, nuheat.SERVICE_RESUME_PROGRAM,
                                {"entity_id": "climate.master_bathroom"}, True)

        thermostat.resume_program.assert_called_with()
        thermostat.schedule_update_ha_state.assert_called_with(True)

        thermostat.resume_program.reset_mock()
        thermostat.schedule_update_ha_state.reset_mock()

        # All entities
        self.hass.services.call(
            nuheat.DOMAIN, nuheat.SERVICE_RESUME_PROGRAM, {}, True)

        thermostat.resume_program.assert_called_with()
        thermostat.schedule_update_ha_state.assert_called_with(True)
Beispiel #3
0
    def test_setup_platform(self, mocked_thermostat):
        """Test setup_platform."""
        mocked_thermostat.return_value = self.thermostat
        thermostat = mocked_thermostat(self.api, "12345", "F")
        thermostats = [thermostat]

        self.hass.data[nuheat.NUHEAT_DOMAIN] = (self.api, ["12345"])

        config = {}
        add_entities = Mock()
        discovery_info = {}

        nuheat.setup_platform(self.hass, config, add_entities, discovery_info)
        add_entities.assert_called_once_with(thermostats, True)
    def test_setup_platform(self, mocked_thermostat):
        """Test setup_platform."""
        mocked_thermostat.return_value = self.thermostat
        thermostat = mocked_thermostat(self.api, "12345", "F")
        thermostats = [thermostat]

        self.hass.data[nuheat.NUHEAT_DOMAIN] = (self.api, ["12345"])

        config = {}
        add_devices = Mock()
        discovery_info = {}

        nuheat.setup_platform(self.hass, config, add_devices, discovery_info)
        add_devices.assert_called_once_with(thermostats, True)