예제 #1
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())
예제 #2
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())
예제 #3
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())