def setUp(self): self.ECS = ElevatorControlSystem(floors=20, elevator_count=5) ## giving initial state to all elevators self.ECS.update(0, 4, 10) self.ECS.update(1, 3, 0) self.ECS.update(2, 8, 4) self.ECS.update(3, 6, 2) self.ECS.update(4, 7, 10)
def test_to_be_assigned_feature(self): ecs = ElevatorControlSystem(floors=20, elevator_count=1) ecs.update(0, 3, 0) ecs.pickup(2, 1, 10) for i in range(3): self.assertEqual(len(ecs.toBeAssigned), 1) ecs.step() # when the elevator gets done with the request # the queue should get empty self.assertEqual(len(ecs.toBeAssigned), 0) # and its goal should change accordingly self.assertEqual(ecs.elevators[0].goal, 2) # after two moves, the goal should correct change to 10 ecs.step() ecs.step() self.assertEqual(ecs.elevators[0].goal, 10)