Example #1
0
    def test_set_stove_mode_to_heating_with_no_lingering_shutdown_task(self, set_on_high_mock):
        config = self._new_config()
        ps = pellet_stove.PelletStove(config)
        run_async(self.eventloop, ps.set_stove_mode_to_heating())

        self.assertEqual('high', ps.stove_state)
        self.assertEqual('heating', ps.stove_automation_mode)
Example #2
0
    def test_run_scenario_2(self):
        config = self._new_config()
        ps = pellet_stove.PelletStove(config)
        ps._controller = Mock()
        ps._controller.get_thermostat_state.side_effect = [False, True, False, True]

        async def scenario_2():
            await ps.get_thermostat_state()

            self.assertFalse(ps.thermostat_state)
            self.assertEqual(ps.stove_state, 'off')
            self.assertEqual(ps.stove_automation_mode, 'off')

            await ps.get_thermostat_state()

            self.assertTrue(ps.thermostat_state)
            self.assertEqual(ps.stove_state, 'high')
            self.assertEqual(ps.stove_automation_mode, 'heating')
            ps._controller.set_on_high.called_once_with()

            await ps.get_thermostat_state()
            await ps.get_thermostat_state()

            self.assertTrue(ps.thermostat_state)
            self.assertTrue(ps.lingering_shutdown_task is None)
            self.assertEqual(ps.stove_state, 'high')
            self.assertEqual(ps.stove_automation_mode, 'heating')
            ps._controller.set_on_medium.called_once_with()
            ps._controller.set_on_low.called_once_with()
            ps._controller.set_off.called_once_with()

        run_async(self.eventloop, scenario_2())
Example #3
0
    def test_shutdown_with_no_lingering_shutdown_task(self):
        config = self._new_config()
        ps = pellet_stove.PelletStove(config)
        ps._controller = Mock()
        ps.shutdown()

        ps._controller.shutdown.assert_called_once_with()
Example #4
0
    def test_set_stove_mode_to_lingering(self):
        config = self._new_config()
        ps = pellet_stove.PelletStove(config)
        ps._controller = Mock()
        run_async(self.eventloop, ps.set_stove_mode_to_lingering())

        ps._controller.set_on_medium.assert_called_once_with()
        ps._controller.set_on_low.assert_called_once_with()
        ps._controller.set_off.assert_called_once_with()
Example #5
0
    def test_set_stove_mode_to_heating_with_lingering_shutdown_task(self):
        config = self._new_config()
        ps = pellet_stove.PelletStove(config)
        coro = AsyncMock()
        ps.lingering_shutdown_task = asyncio.ensure_future(coro())
        run_async(self.eventloop, ps.set_stove_mode_to_heating())

        self.assertEqual('high', ps.stove_state)
        self.assertEqual('heating', ps.stove_automation_mode)
        coro.m.assert_called_once_with()
        self.assertFalse(ps.lingering_shutdown_task)
Example #6
0
 def test_instantiation(self):
     config = self._new_config()
     ps = pellet_stove.PelletStove(config)
     self.assertFalse(ps.thermostat_state)
     self.assertEqual(ps.stove_state, "off")
     self.assertEqual(ps.stove_automation_mode, "off")