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())
def test_done_open_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()) task = Open(blind) self.assertTrue(task.done())
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())
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_done_pretilt_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()) prepare = PreTilt(blind) self.assertFalse(prepare.done())
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())
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_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())
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())
def test_tilt_calculation_close(self): mock = DeviceMock('👨🏫') blind = Blind('👨🎓', 10, 20, mock, [], []) blind.override_tilt_duration( 90) # Makes calculation for checks much more easy =) blind.close() self.assertEqual(State.CLOSED, mock.stats()) blind.tilt(0) self.assertEqual(90, mock.time) self.assertEqual('open', mock.direction)
def test_tilt_calculation_initial(self): mock = DeviceMock('👨🏫') blind = Blind('👨🎓', 10, 20, mock, [], []) blind.override_tilt_duration( 90) # Makes calculation for checks much more easy =) # starting from 90 blind.tilt(0) self.assertEqual(90, mock.time) self.assertEqual('open', mock.direction)
def blind(events: []) -> Blind: return Blind('test', 10, 20, DeviceMock('YOLO'), [], events)
def get_blind(name: str = 'Test') -> Blind: return Blind(name, 10, 20, DeviceMock(name), [], [])
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())
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())
def test_done_pretilt_moved_state(self): device = DeviceMock('TestDevice') blind = Blind('Test', 0, 0, device, [], []) device.move(50) prepare = PreTilt(blind) self.assertFalse(prepare.done())
def test_done_open_moved_state(self): device = DeviceMock('TestDevice') blind = Blind('Test', 0, 0, device, [], []) device.move(50) task = Open(blind) self.assertFalse(task.done())