Ejemplo n.º 1
0
 def test_move_elevator_with_two_items(self):
   start = SimulatorState(0)
   start.add_item_to_floor('HG', 2)
   start.add_item_to_floor('HM', 0)
   start.add_item_to_floor('NG', 2)
   start.add_item_to_floor('NM', 0)
   expected_floor_map = [
     {
       'generator': {
         'floor': 2,
         'name': 'HG'
       },
       'microchip': {
         'floor': 1,
         'name': 'HM'
       }
     },
     {
       'generator': {
         'floor': 2,
         'name': 'NG'
       },
       'microchip': {
         'floor': 1,
         'name': 'NM'
       }
     }
   ]
   rad_sim = RadiationContainmentSimulator(start)
   rad_sim.elevator_up(['NM', 'HM'])
   self.assert_simulator_state(rad_sim.get_simulator_state(), 1, expected_floor_map)
Ejemplo n.º 2
0
 def test_cannot_pickup_item_on_different_floor(self):
   with self.assertRaises(ElevatorPickupError):
     start = SimulatorState(0)
     start.add_item_to_floor('HG', 2)
     start.add_item_to_floor('HM', 1)
     rad_sim = RadiationContainmentSimulator(start)
     rad_sim.elevator_up(['HM'])
Ejemplo n.º 3
0
 def test_cannot_move_elevator_outside_building(self):
   with self.assertRaises(ElevatorMoveError):
     start = SimulatorState(3)
     start.add_item_to_floor('CoG', 0)
     start.add_item_to_floor('CoM', 0)
     rad_sim = RadiationContainmentSimulator(start)
     rad_sim.elevator_up(['CoM'])
Ejemplo n.º 4
0
 def test_check_fried_chips_after_all_cargo_moved():
   start = SimulatorState(2)
   start.add_item_to_floor('HG', 2)
   start.add_item_to_floor('HM', 2)
   start.add_item_to_floor('LiG', 2)
   start.add_item_to_floor('LiM', 3)
   rad_sim = RadiationContainmentSimulator(start)
   rad_sim.elevator_up(['HG', 'LiG'])
Ejemplo n.º 5
0
 def test_cannot_exceed_two_items_in_elevator(self):
   with self.assertRaises(ElevatorCapacityError):
     start = SimulatorState(0)
     start.add_item_to_floor('HG', 0)
     start.add_item_to_floor('HM', 0)
     start.add_item_to_floor('XeG', 0)
     start.add_item_to_floor('XeM', 0)
     rad_sim = RadiationContainmentSimulator(start)
     rad_sim.elevator_up(['HM', 'HG', 'XeM'])
Ejemplo n.º 6
0
 def test_chip_fried_when_exposed_to_other_generator(self):
   with self.assertRaises(FriedChipError):
     start = SimulatorState(0)
     start.add_item_to_floor('HG', 0)
     start.add_item_to_floor('HM', 0)
     start.add_item_to_floor('XeG', 1)
     start.add_item_to_floor('XeM', 0)
     rad_sim = RadiationContainmentSimulator(start)
     rad_sim.elevator_up(['HM'])
Ejemplo n.º 7
0
 def advance_simulator_up(state, cargo) -> SimulatorState:
     rad_sim = RadiationContainmentSimulator(state)
     rad_sim.elevator_up(cargo)
     return rad_sim.get_simulator_state()
Ejemplo n.º 8
0
 def test_cannot_move_item_that_does_not_exist(self):
   with self.assertRaises(RuntimeError):
     rad_sim = RadiationContainmentSimulator(SimulatorState(0))
     rad_sim.elevator_up(['CaM'])
Ejemplo n.º 9
0
 def test_cannot_move_empty_elevator(self):
   with self.assertRaises(ElevatorCapacityError):
     rad_sim = RadiationContainmentSimulator(SimulatorState(0))
     rad_sim.elevator_up([])