Ejemplo n.º 1
0
 def test_done_close_close_state(self):
     device = DeviceMock('TestDevice')
     blind = Blind('Test', 0, 0, device, [], [])
     Close(blind).do()
     self.assertEqual(1, device.close_counter)
     self.assertEqual(State.CLOSED, device.stats())
     close = Close(blind)
     self.assertTrue(close.done())
Ejemplo n.º 2
0
 def test_done_close_tilt_state(self):
     device = DeviceMock('TestDevice')
     blind = Blind('Test', 0, 0, device, [], [])
     Tilt(blind).do()
     self.assertEqual(1, device.tilt_counter)
     self.assertEqual(State.TILT, device.stats())
     close = Close(blind)
     self.assertFalse(close.done())
Ejemplo n.º 3
0
 def test_done_close_open_state(self):
     device = DeviceMock('TestDevice')
     blind = Blind('Test', 0, 0, device, [], [])
     Open(blind).do()
     self.assertEqual(1, device.open_counter)
     self.assertEqual(State.OPEN, device.stats())
     close = Close(blind)
     self.assertFalse(close.done())
Ejemplo n.º 4
0
 def test_done_tilt_close_state(self):
     device = DeviceMock('TestDevice')
     blind = Blind('Test', 0, 0, device, [], [])
     Close(blind).do()
     self.assertEqual(1, device.close_counter)
     self.assertEqual(State.CLOSED, device.stats())
     tilt = Tilt(blind)
     self.assertFalse(tilt.done())
Ejemplo n.º 5
0
 def test_extract_sunin(self):
     triggers = ['SUNIN', {'SUNIN': {'task': 'CLOSE'}}]
     result = trigger.extract_triggers(blind(triggers), sundata())
     self.assertEqual(2, len(result))
     self.assertEqual(Tilt.type(), result[0].task().type())
     self.assertEqual(Close.type(), result[1].task().type())
     for item in result:
         self.assertEqual(SunInTrigger.type(), item.type())
         self.assertEqual('2020-07-27T07:59:00+02:00', item.time().isoformat())
Ejemplo n.º 6
0
 def test_extract_sunset(self):
     triggers = ['SUNSET', {'SUNSET': {'task': 'TILT'}}]
     result = trigger.extract_triggers(blind(triggers), sundata())
     self.assertEqual(2, len(result))
     self.assertEqual(Close.type(), result[0].task().type())
     self.assertEqual(Tilt.type(), result[1].task().type())
     for item in result:
         self.assertEqual(SunsetTrigger.type(), item.type())
         self.assertEqual('2020-07-27T21:08:00+02:00', item.time().isoformat())
Ejemplo n.º 7
0
 def test_extract_time(self):
     dateutil.date.next()
     triggers = [{'TIME': {'task': 'CLOSE', 'time': '16:00:00'}}]
     result = trigger.extract_triggers(blind(triggers), sundata())
     self.assertEqual(1, len(result))
     self.assertEqual(Close.type(), result[0].task().type())
     for item in result:
         self.assertEqual(TimeTrigger.type(), item.type())
         now = datetime.now(dateutil.zone)
         self.assertEqual(now.date().isoformat() + 'T16:00:00+02:00', item.time().isoformat())
 def test_unblocking(self):
     # Setup
     e = CloudsEvent()
     b, trigger = self.__prepare([e], 804, percentage=100)
     # Test
     b.update(trigger)
     # Check
     self.assertEqual(1, b.device.open_counter)
     self.assertTrue(b.blocked)
     Close(b).do()
     Open(b).do()
     self.assertEqual(0, b.device.close_counter)
     self.assertEqual(1, b.device.open_counter)
     self.assertEqual(Open.type(), b._blocker.last.type())
     release = self.__create_trigger(803, percentage=93)
     b.update(release)
     self.assertFalse(b.blocked, 'Blocking should be released')
     self.assertEqual(1, b.device.close_counter,
                      'Last blocked Task should be applied')
     Close(b).do()
     self.assertEqual(2, b.device.close_counter,
                      'Further task shouldn\'t be blocked')
 def test_blocking(self):
     # Setup
     e = CloudsEvent()
     b, trigger = self.__prepare([e], 804, percentage=100)
     # Test
     b.update(trigger)
     # Check
     self.assertEqual(1, b.device.open_counter)
     self.assertTrue(b.blocked)
     Close(b).do()
     Open(b).do()
     self.assertEqual(0, b.device.close_counter)
     self.assertEqual(1, b.device.open_counter)
     self.assertEqual(Open.type(), b._blocker.last.type())
Ejemplo n.º 10
0
 def test_done_close_moved_state(self):
     device = DeviceMock('TestDevice')
     blind = Blind('Test', 0, 0, device, [], [])
     device.move(50)
     close = Close(blind)
     self.assertFalse(close.done())