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'])
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)
def test_cannot_move_elevator_into_basement(self): with self.assertRaises(ElevatorMoveError): start = SimulatorState(0) start.add_item_to_floor('CaG', 0) start.add_item_to_floor('CaM', 0) rad_sim = RadiationContainmentSimulator(start) rad_sim.elevator_down(['CaM'])
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'])
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'])
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'])
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'])
def advance_simulator_down(state, cargo) -> SimulatorState: rad_sim = RadiationContainmentSimulator(state) rad_sim.elevator_down(cargo) return rad_sim.get_simulator_state()
def calculate_cargos(state: SimulatorState) -> list[list[str]]: current_rad_sim = RadiationContainmentSimulator(state) available_items = current_rad_sim.current_floor_items() return CargoCalculator.calculate_cargo_combinations(available_items)
def test_cannot_move_item_that_does_not_exist(self): with self.assertRaises(RuntimeError): rad_sim = RadiationContainmentSimulator(SimulatorState(0)) rad_sim.elevator_up(['CaM'])
def test_cannot_move_empty_elevator(self): with self.assertRaises(ElevatorCapacityError): rad_sim = RadiationContainmentSimulator(SimulatorState(0)) rad_sim.elevator_up([])