Esempio n. 1
0
 def test_done_tilt_different_tilt_state(self):
     device = DeviceMock('TestDevice')
     blind = Blind('Test', 0, 0, device, [], [])
     Tilt(blind, 45).do()
     self.assertEqual(1, device.tilt_counter)
     self.assertEqual(State.TILT, device.stats())
     tilt = Tilt(blind)
     self.assertFalse(tilt.done())
Esempio n. 2
0
 def test_done_tilt_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())
     tilt = Tilt(blind)
     self.assertFalse(tilt.done())
Esempio n. 3
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())
 def test_wind(self):
     events = [
         'WIND', {
             'WIND': {
                 'task': 'TILT',
                 'speed': 100,
                 'direction': {
                     'from': 100,
                     'to': 200
                 }
             }
         }
     ]
     b = blind(events)
     event.apply_weather_events(b)
     result = b.events
     self.assertEqual(2, len(result))
     for e in result:
         self.assertEqual('WIND', e.type())
     self.assertEqual(120.0, result[0].speed)
     self.assertEqual(100, result[1].speed)
     self.assertIsNone(result[0].direction[0])
     self.assertIsNone(result[0].direction[1])
     self.assertEqual((100, 200), result[1].direction)
     self.assertEqual(Tilt.type(), result[1]._task.type())
Esempio n. 5
0
 def test_done_pretilt_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())
     prepare = PreTilt(blind)
     self.assertTrue(prepare.done())
Esempio n. 6
0
 def test_done_open_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())
     task = Open(blind)
     self.assertFalse(task.done())
Esempio n. 7
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())
 def test_extract_sunout(self):
     triggers = ['SUNOUT', {'SUNOUT': {'task': 'TILT'}}]
     result = trigger.extract_triggers(blind(triggers), sundata())
     self.assertEqual(2, len(result))
     self.assertEqual(Open.type(), result[0].task().type())
     self.assertEqual(Tilt.type(), result[1].task().type())
     for item in result:
         self.assertEqual(SunOutTrigger.type(), item.type())
         self.assertEqual('2020-07-27T07:59:00+02:00', item.time().isoformat())
 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())
 def test_clear(self):
     events = ['CLEAR', {'CLEAR': {'task': 'TILT'}}]
     b = blind(events)
     event.apply_weather_events(b)
     result = b.events
     self.assertEqual(2, len(result))
     for e in result:
         self.assertEqual(WeatherConditionEnum.CLEAR, e._main)
         self.assertEqual('CLEAR', e.type())
     self.assertEqual(Tilt.type(), result[1]._task.type())
 def test_rain(self):
     events = ['RAIN', {'RAIN': {'task': 'TILT', 'intensity': ['HEAVY']}}]
     b = blind(events)
     event.apply_weather_events(b)
     result = b.events
     self.assertEqual(2, len(result))
     for e in result:
         self.assertEqual(WeatherConditionEnum.RAIN, e._main)
         self.assertEqual('RAIN', e.type())
     self.assertEqual(1, len(result[1]._sub))
     self.assertEqual(WeatherSubConditionEnum.HEAVY, result[1]._sub[0])
     self.assertEqual(Tilt.type(), result[1]._task.type())
 def test_snow(self):
     events = ['SNOW', {'SNOW': {'task': 'TILT', 'intensity': ['SLEET']}}]
     b = blind(events)
     event.apply_weather_events(b)
     result = b.events
     self.assertEqual(2, len(result))
     for e in result:
         self.assertEqual(WeatherConditionEnum.SNOW, e._main)
         self.assertEqual('SNOW', e.type())
     self.assertEqual(1, len(result[1]._sub))
     self.assertEqual(WeatherSubConditionEnum.SLEET, result[1]._sub[0])
     self.assertEqual(Tilt.type(), result[1]._task.type())
 def test_clouds(self):
     events = ['CLOUDY', {'CLOUDY': {'task': 'TILT', 'coverage': 93}}]
     b = blind(events)
     event.apply_weather_events(b)
     result = b.events
     self.assertEqual(2, len(result))
     self.assertEqual(Open.type(), result[0]._task.type())
     self.assertEqual(Tilt.type(), result[1]._task.type())
     item = result[0]
     self.assertEqual(CloudsEvent.type(), item.type())
     self.assertEqual(WeatherConditionEnum.CLOUDS, item._main)
     self.assertEqual(0, len(item._sub))
     self.assertEqual(100, item.percentage)
     item = result[1]
     self.assertEqual(CloudsEvent.type(), item.type())
     self.assertEqual(WeatherConditionEnum.CLOUDS, item._main)
     self.assertEqual(0, len(item._sub))
     self.assertEqual(93, item.percentage)
 def test_drizzle(self):
     events = [
         'DRIZZLE', {
             'DRIZZLE': {
                 'task': 'TILT',
                 'intensity': ['SHOWER']
             }
         }
     ]
     b = blind(events)
     event.apply_weather_events(b)
     result = b.events
     self.assertEqual(2, len(result))
     for e in result:
         self.assertEqual(WeatherConditionEnum.DRIZZLE, e._main)
         self.assertEqual('DRIZZLE', e.type())
     self.assertEqual(1, len(result[1]._sub))
     self.assertEqual(WeatherSubConditionEnum.SHOWER, result[1]._sub[0])
     self.assertEqual(Tilt.type(), result[1]._task.type())
 def test_special_weather(self):
     events = [
         'SPECIAL', {
             'SPECIAL': {
                 'task': 'TILT',
                 'events': ['TORNADO']
             }
         }
     ]
     b = blind(events)
     event.apply_weather_events(b)
     result = b.events
     self.assertEqual(2, len(result))
     for e in result:
         self.assertEqual(WeatherConditionEnum.ATMOSPHERE, e._main)
         self.assertEqual('SPECIAL', e.type())
     self.assertEqual(1, len(result[1]._sub))
     self.assertEqual(WeatherSubConditionEnum.TORNADO, result[1]._sub[0])
     self.assertEqual(Tilt.type(), result[1]._task.type())
Esempio n. 16
0
 def test_done_tilt_moved_state(self):
     device = DeviceMock('TestDevice')
     blind = Blind('Test', 0, 0, device, [], [])
     device.move(50)
     tilt = Tilt(blind)
     self.assertFalse(tilt.done())