Example #1
0
 def test_if_applicable_hook_off(self):
     """Test test_if_applicable method with hook set to 'off'."""
     xknx = XKNX(loop=self.loop)
     action = ActionBase(xknx, counter=2, hook="off")
     self.assertTrue(action.test_if_applicable(BinarySensorState.OFF, 2))
     self.assertFalse(action.test_if_applicable(BinarySensorState.OFF, 3))
     self.assertFalse(action.test_if_applicable(BinarySensorState.ON, 2))
Example #2
0
 def test_execute_base_action(self):
     """Test if execute method of BaseAction shows correct info message."""
     xknx = XKNX(loop=self.loop)
     action = ActionBase(xknx)
     with patch('logging.Logger.info') as mock_info:
         self.loop.run_until_complete(asyncio.Task(action.execute()))
         mock_info.assert_called_with('Execute not implemented for %s', 'ActionBase')
Example #3
0
 def test_if_applicable_hook_on(self):
     """Test test_if_applicable method with hook set to 'on'."""
     xknx = XKNX(loop=self.loop)
     action = ActionBase(xknx, counter=2, hook="on")
     self.assertTrue(action.test_if_applicable(True, 2))
     self.assertFalse(action.test_if_applicable(True, 3))
     self.assertFalse(action.test_if_applicable(False, 2))
Example #4
0
 def test_execute_base_action(self):
     """Test if execute method of BaseAction shows correct info message."""
     xknx = XKNX(loop=self.loop)
     action = ActionBase(xknx)
     with patch("logging.Logger.info") as mock_info:
         self.loop.run_until_complete(action.execute())
         mock_info.assert_called_with("Execute not implemented for %s", "ActionBase")
Example #5
0
 def test_no_counter(self):
     """Test counter method with no counter set."""
     xknx = XKNX(loop=self.loop)
     action = ActionBase(xknx, counter=None)
     self.assertTrue(action.test_counter(None))
     self.assertTrue(action.test_counter(1))
     self.assertTrue(action.test_counter(2))
     self.assertTrue(action.test_counter(3))
Example #6
0
 def test_no_counter(self):
     """Test counter method with no counter set."""
     xknx = XKNX(loop=self.loop)
     action = ActionBase(xknx, counter=None)
     self.assertTrue(action.test_counter(None))
     self.assertTrue(action.test_counter(1))
     self.assertTrue(action.test_counter(2))
     self.assertTrue(action.test_counter(3))
Example #7
0
 def test_counter(self):
     """Test counter method."""
     xknx = XKNX(loop=self.loop)
     action = ActionBase(xknx, counter=2)
     self.assertTrue(action.test_counter(None))
     self.assertFalse(action.test_counter(1))
     self.assertTrue(action.test_counter(2))
     self.assertFalse(action.test_counter(3))
Example #8
0
 def test_if_applicable_hook_off(self):
     """Test test_if_applicable method with hook set to 'off'."""
     xknx = XKNX(loop=self.loop)
     action = ActionBase(xknx, counter=2, hook="off")
     self.assertTrue(action.test_if_applicable(
         BinarySensorState.OFF, 2))
     self.assertFalse(action.test_if_applicable(
         BinarySensorState.OFF, 3))
     self.assertFalse(action.test_if_applicable(
         BinarySensorState.ON, 2))
Example #9
0
 def test_action_base(self):
     """Test string representation of action base."""
     xknx = XKNX(loop=self.loop)
     action_base = ActionBase(
         xknx,
         hook='off',
         counter='2')
     self.assertEqual(
         str(action_base),
         '<ActionBase hook="off" counter="2"/>')
Example #10
0
 def test_counter(self):
     """Test counter method."""
     xknx = XKNX(loop=self.loop)
     action = ActionBase(xknx, counter=2)
     self.assertTrue(action.test_counter(None))
     self.assertFalse(action.test_counter(1))
     self.assertTrue(action.test_counter(2))
     self.assertFalse(action.test_counter(3))