Exemplo n.º 1
0
 def move(self, pos: int) -> bool:
     self.move_counter = self.move_counter + 1
     if pos < self.position:
         self.blindstate = BlindState(pos, Direction.CLOSE)
     else:
         self.blindstate = BlindState(pos, Direction.OPEN)
     self.position = pos
     return True
Exemplo n.º 2
0
 def tilt(self, direction: str, time: float) -> bool:
     self.time = time
     self.direction = direction
     self.tilt_counter = self.tilt_counter + 1
     self.position = 2
     self.blindstate = BlindState(self.position,
                                  Direction.from_name(direction))
     return True
Exemplo n.º 3
0
 def open(self) -> bool:
     self.open_counter = self.open_counter + 1
     self.position = 100
     self.blindstate = BlindState(self.position, Direction.OPEN)
     return True
 def test_closed_state(self):
     state = BlindState(0, Direction.CLOSE)
     self.assertEqual(State.CLOSED, state.state())
Exemplo n.º 5
0
 def close(self) -> bool:
     self.close_counter = self.close_counter + 1
     self.position = 0
     self.blindstate = BlindState(self.position, Direction.CLOSE)
     return True
 def test_tilt_open_str(self):
     state = BlindState(4, Direction.OPEN.value)
     self.assertEqual(State.TILT, state.state())
 def test_json(self):
     json = get_json()
     state = BlindState(json.get('current_pos'), json.get('last_direction'))
     self.assertEqual(State.CLOSED, state.state())
 def test_tilt_close_str(self):
     state = BlindState(1, Direction.CLOSE.value)
     self.assertEqual(State.TILT, state.state())
 def test_moved_zero_open_State(self):
     state = BlindState(0, Direction.OPEN)
     self.assertEqual(State.MOVED, state.state())
 def test_moved_min_close_state(self):
     state = BlindState(5, Direction.CLOSE)
     self.assertEqual(State.MOVED, state.state())
 def test_moved_min_open_state(self):
     state = BlindState(5, Direction.OPEN)
     self.assertEqual(State.MOVED, state.state())
 def test_open_min_state(self):
     state = BlindState(96, Direction.OPEN)
     self.assertEqual(State.OPEN, state.state())