コード例 #1
0
 def test_invalid_leave_slot(self):
     obj = ParkingLotService()
     obj.select_parking_lot(self.slot_id)
     obj.park("park KA-01-HH-1234", "White")
     try:
         obj.leave(str(2))
     except InvalidCommandException as e:
         print(e)
コード例 #2
0
 def test_slot_numbers_for_cars_with_colour(self):
     obj = ParkingLotService()
     obj.select_parking_lot(self.slot_id)
     for details in self.cars:
         registration_number, color = details
         obj.park(registration_number, color)
     self.assertListEqual([1, 2],
                          obj.slot_numbers_for_cars_with_colour("White"))
コード例 #3
0
 def test_invalid_leave_range(self):
     obj = ParkingLotService()
     obj.select_parking_lot(self.slot_id)
     try:
         obj.leave(str(12345))
     except InvalidCommandException as e:
         print(e)
コード例 #4
0
 def test_parking_lot_does_not_exists(self):
     obj = ParkingLotService()
     try:
         obj.select_parking_lot(12345)
         obj.parking_lot_exists()
     except ParkingLotNotExistsException as e:
         print(
             "This parking lot doesn't exist. Skip the raise exception from the service. {}"
             .format(e))
         pass
コード例 #5
0
 def test_status(self):
     obj = ParkingLotService()
     obj.select_parking_lot(self.slot_id)
     for details in self.cars:
         registration_number, color = details
         obj.park(registration_number, color)
     self.assertListEqual(
         [
             ["1", "KA-01-HH-1234", "White"],
             ["2", "KA-01-HH-9999", "White"],
             ["3", "KA-01-BB-0001", "Black"],
         ],
         obj.status(),
     )
コード例 #6
0
    def test_parking_lot(self):
        original_stdout = sys.stdout
        input_path = getcwd() + self.input_file
        output_path = getcwd() + self.output_file

        with open(output_path) as fp:
            output = fp.readlines()  # Output fixture

        with open(self.stdout_file, "w") as fp:
            sys.stdout = fp  # Change the standard output to the file
            parking_lot_service = ParkingLotService()
            process_file(parking_lot_service, input_path)
            sys.stdout = original_stdout  # Reset the standard output

        with open(self.stdout_file) as fp:
            std_out = fp.readlines()

        self.assertListEqual(std_out, output)
コード例 #7
0
 def test_slot_number_for_registration_number(self):
     obj = ParkingLotService()
     obj.select_parking_lot(self.slot_id)
     obj.park("park KA-01-HH-1234", "White")
     self.assertEqual(
         1, obj.slot_number_for_registration_number("park KA-01-HH-1234"))
コード例 #8
0
 def test_park_full(self):
     obj = ParkingLotService()
     slot_size = obj.select_parking_lot(self.slot_id)
     for i in range(slot_size):
         obj.park("park KA-01-HH" + str(i), "White")
     self.assertFalse(obj.park("park KA-01-HH-1234", "White"))
コード例 #9
0
 def test_park(self):
     obj = ParkingLotService()
     obj.select_parking_lot(self.slot_id)
     self.assertEqual(obj.park("park KA-01-HH-1234", "White"), 1)
コード例 #10
0
 def test_parking_lot_exists(self):
     obj = ParkingLotService()
     obj.select_parking_lot(self.slot_id)
     self.assertTrue(obj.parking_lot_exists())
コード例 #11
0
 def test_select_parking_lot(self):
     obj = ParkingLotService()
     self.assertEqual(obj.select_parking_lot(self.slot_id), 6)
コード例 #12
0
def parking_lot(input_file: str) -> None:
    parking_lot_service = ParkingLotService()
    if input_file:
        process_file(parking_lot_service, input_file)
    else:
        process_input(parking_lot_service)