def test_vehicles_are_rejected_when_capacity_is_exceeded(): parking_level_1 = ParkingLevel(spaces=[ParkingSpace(), ParkingSpace()]) parking_level_2 = ParkingLevel(spaces=[ParkingSpace()]) garage = Garage(levels=[parking_level_1, parking_level_2]) vehicle_1 = Vehicle() vehicle_2 = Vehicle() vehicle_3 = Vehicle() vehicle_4 = Vehicle() vehicle_5 = Vehicle() vehicle_6 = Vehicle() vehicle_7 = Vehicle() expected_rejected_vehicles: List[Vehicle] = [ vehicle_4, vehicle_5, vehicle_6, vehicle_7, ] actual_rejected_vehicles = garage.add_vehicles([ vehicle_1, vehicle_2, vehicle_3, vehicle_4, vehicle_5, vehicle_6, vehicle_7 ]) TestHelpers.assert_expected_vehicles_are_rejected( actual=actual_rejected_vehicles, expected=expected_rejected_vehicles)
def test_vehicle_is_added_to_parking_space(): parking_space = ParkingSpace() parking_level = ParkingLevel(spaces=[parking_space]) vehicle = Vehicle() garage = Garage(levels=[parking_level]) garage.add_vehicles(vehicles=[vehicle]) assert (parking_space.vehicle is vehicle), "Parking space does not contain the expected vehicle."
def test_vehicles_without_premium_permits_are_rejected_from_premium_parking_spaces( ): parking_space_a = ParkingSpace(required_permit=Permit.PREMIUM) parking_space_b = ParkingSpace(required_permit=Permit.PREMIUM) parking_space_c = ParkingSpace(required_permit=Permit.PREMIUM) parking_space_d = ParkingSpace(required_permit=Permit.PREMIUM) parking_space_e = ParkingSpace(required_permit=Permit.PREMIUM) parking_space_f = ParkingSpace(required_permit=Permit.PREMIUM) parking_level_1 = ParkingLevel(spaces=[parking_space_a, parking_space_b]) parking_level_2 = ParkingLevel(spaces=[parking_space_c, parking_space_d]) parking_level_3 = ParkingLevel(spaces=[parking_space_e, parking_space_f]) garage = Garage(levels=[parking_level_1, parking_level_2, parking_level_3]) vehicle_1 = Vehicle(permit=Permit.PREMIUM) vehicle_2 = Vehicle(permit=Permit.NONE) vehicle_3 = Vehicle(permit=Permit.NONE) vehicle_4 = Vehicle(permit=Permit.PREMIUM) vehicle_5 = Vehicle(permit=Permit.DISABILITY) vehicle_6 = Vehicle(permit=Permit.NONE) expected_rejected_vehicles: List[Vehicle] = [ vehicle_2, vehicle_3, vehicle_5, vehicle_6, ] actual_rejected_vehicles = garage.add_vehicles( [vehicle_1, vehicle_2, vehicle_3, vehicle_4, vehicle_5, vehicle_6]) TestHelpers.assert_expected_vehicles_are_rejected( actual=actual_rejected_vehicles, expected=expected_rejected_vehicles)
def test_compact_vehicles_are_first_prioritized_into_compact_parking_space(): parking_level_1 = ParkingLevel( spaces=[ParkingSpace(compact=True), ParkingSpace(compact=False)]) parking_level_2 = ParkingLevel( spaces=[ParkingSpace(compact=False), ParkingSpace(compact=True)]) parking_level_3 = ParkingLevel( spaces=[ParkingSpace(compact=False), ParkingSpace(compact=False)]) garage = Garage(levels=[parking_level_1, parking_level_2, parking_level_3]) vehicle_1 = Vehicle(vehicle_type=VehicleType.Car) vehicle_2 = Vehicle(vehicle_type=VehicleType.Compact) vehicle_3 = Vehicle(vehicle_type=VehicleType.Compact) vehicle_4 = Vehicle(vehicle_type=VehicleType.Truck) vehicle_5 = Vehicle(vehicle_type=VehicleType.Compact) vehicle_6 = Vehicle(vehicle_type=VehicleType.Car) expected_vehicles_on_level_1: List[Vehicle] = [vehicle_2, vehicle_1] expected_vehicles_on_level_2: List[Vehicle] = [vehicle_4, vehicle_3] expected_vehicles_on_level_3: List[Vehicle] = [vehicle_5, vehicle_6] garage.add_vehicles( [vehicle_1, vehicle_2, vehicle_3, vehicle_4, vehicle_5, vehicle_6]) TestHelpers.assert_expected_parking_placement( levels=garage.levels, expected_levels=[ expected_vehicles_on_level_1, expected_vehicles_on_level_2, expected_vehicles_on_level_3, ], )
def test_trucks_are_rejected_from_compact_parking_space(): parking_level_1 = ParkingLevel( spaces=[ParkingSpace(compact=True), ParkingSpace(compact=True)]) parking_level_2 = ParkingLevel( spaces=[ParkingSpace(compact=True), ParkingSpace(compact=True)]) parking_level_3 = ParkingLevel( spaces=[ParkingSpace(compact=True), ParkingSpace(compact=True)]) garage = Garage(levels=[parking_level_1, parking_level_2, parking_level_3]) vehicle_1 = Vehicle(vehicle_type=VehicleType.Compact) vehicle_2 = Vehicle(vehicle_type=VehicleType.Truck) vehicle_3 = Vehicle(vehicle_type=VehicleType.Truck) vehicle_4 = Vehicle(vehicle_type=VehicleType.Truck) vehicle_5 = Vehicle(vehicle_type=VehicleType.Compact) vehicle_6 = Vehicle(vehicle_type=VehicleType.Truck) expected_rejected_vehicles: List[Vehicle] = [ vehicle_2, vehicle_3, vehicle_4, vehicle_6, ] actual_rejected_vehicles = garage.add_vehicles( [vehicle_1, vehicle_2, vehicle_3, vehicle_4, vehicle_5, vehicle_6]) TestHelpers.assert_expected_vehicles_are_rejected( actual=actual_rejected_vehicles, expected=expected_rejected_vehicles)
def test_standard_cars_are_rejected_from_compact_parking_space(): parking_space_a = ParkingSpace(compact=True) parking_space_b = ParkingSpace(compact=True) parking_space_c = ParkingSpace(compact=True) parking_space_d = ParkingSpace(compact=True) parking_space_e = ParkingSpace(compact=True) parking_space_f = ParkingSpace(compact=True) parking_level_1 = ParkingLevel(spaces=[parking_space_a, parking_space_b]) parking_level_2 = ParkingLevel(spaces=[parking_space_c, parking_space_d]) parking_level_3 = ParkingLevel(spaces=[parking_space_e, parking_space_f]) garage = Garage(levels=[parking_level_1, parking_level_2, parking_level_3]) vehicle_1 = Vehicle(vehicle_type=VehicleType.Compact) vehicle_2 = Vehicle(vehicle_type=VehicleType.Car) vehicle_3 = Vehicle(vehicle_type=VehicleType.Car) vehicle_4 = Vehicle(vehicle_type=VehicleType.Compact) vehicle_5 = Vehicle(vehicle_type=VehicleType.Car) vehicle_6 = Vehicle(vehicle_type=VehicleType.Car) expected_vehicles_rejected: List[Vehicle] = [ vehicle_2, vehicle_3, vehicle_5, vehicle_6, ] actual_vehicles_rejected = garage.add_vehicles( [vehicle_1, vehicle_2, vehicle_3, vehicle_4, vehicle_5, vehicle_6] ) TestHelpers.assert_expected_vehicles_are_rejected( actual=actual_vehicles_rejected, expected=expected_vehicles_rejected )
def test_compact_vehicles_with_dual_premium_disability_permits_take_the_same_priority_as_non_compact_vehicles(): parking_space_a = ParkingSpace(required_permit=Permit.DISABILITY) parking_space_b = ParkingSpace(required_permit=Permit.PREMIUM) parking_space_c = ParkingSpace(required_permit=Permit.PREMIUM) parking_space_d = ParkingSpace(required_permit=Permit.DISABILITY) parking_space_e = ParkingSpace(required_permit=Permit.PREMIUM) parking_space_f = ParkingSpace(required_permit=Permit.PREMIUM) parking_level_1 = ParkingLevel(spaces=[parking_space_a, parking_space_b]) parking_level_2 = ParkingLevel(spaces=[parking_space_c, parking_space_d]) parking_level_3 = ParkingLevel(spaces=[parking_space_e, parking_space_f]) garage = Garage(levels=[parking_level_1, parking_level_2, parking_level_3]) vehicle_1 = Vehicle(vehicle_type=VehicleType.Compact, permit=Permit.PREMIUM) vehicle_2 = Vehicle( vehicle_type=VehicleType.Truck, permit=Permit.DISABILITY | Permit.PREMIUM ) vehicle_3 = Vehicle( vehicle_type=VehicleType.Compact, permit=Permit.DISABILITY | Permit.PREMIUM ) vehicle_4 = Vehicle(vehicle_type=VehicleType.Compact, permit=Permit.PREMIUM) vehicle_5 = Vehicle( vehicle_type=VehicleType.Truck, permit=Permit.DISABILITY | Permit.PREMIUM ) vehicle_6 = Vehicle( vehicle_type=VehicleType.Compact, permit=Permit.DISABILITY | Permit.PREMIUM ) expected_vehicles_on_level_1: List[Vehicle] = [vehicle_2, vehicle_5] expected_vehicles_on_level_2: List[Vehicle] = [vehicle_6, vehicle_3] expected_vehicles_on_level_3: List[Vehicle] = [vehicle_1, vehicle_4] garage.add_vehicles( [vehicle_1, vehicle_2, vehicle_3, vehicle_4, vehicle_5, vehicle_6] ) TestHelpers.assert_expected_vehicles_on_levels( levels=garage.levels, expected_vehicles=[ expected_vehicles_on_level_1, expected_vehicles_on_level_2, expected_vehicles_on_level_3, ], )
def test_compact_vehicles_with_premium_permits_are_first_prioritized_into_premium_parking_spaces( ): parking_space_a = ParkingSpace(required_permit=Permit.PREMIUM) parking_space_b = ParkingSpace(compact=True) parking_space_c = ParkingSpace(compact=True) parking_space_d = ParkingSpace(required_permit=Permit.PREMIUM) parking_space_e = ParkingSpace(required_permit=Permit.PREMIUM) parking_space_f = ParkingSpace(compact=True) parking_level_1 = ParkingLevel(spaces=[parking_space_a, parking_space_b]) parking_level_2 = ParkingLevel(spaces=[parking_space_c, parking_space_d]) parking_level_3 = ParkingLevel(spaces=[parking_space_e, parking_space_f]) garage = Garage(levels=[parking_level_1, parking_level_2, parking_level_3]) vehicle_1 = Vehicle() vehicle_2 = Vehicle(vehicle_type=VehicleType.Compact, permit=Permit.PREMIUM) vehicle_3 = Vehicle(vehicle_type=VehicleType.Compact, permit=Permit.PREMIUM) vehicle_4 = Vehicle() vehicle_5 = Vehicle() vehicle_6 = Vehicle(vehicle_type=VehicleType.Compact, permit=Permit.PREMIUM) vehicle_7 = Vehicle(vehicle_type=VehicleType.Compact, permit=Permit.PREMIUM) expected_vehicles_on_level_1: List[Vehicle] = [vehicle_2, vehicle_7] expected_vehicles_on_level_2: List[Vehicle] = [None, vehicle_3] expected_vehicles_on_level_3: List[Vehicle] = [vehicle_6, None] garage.add_vehicles([ vehicle_1, vehicle_2, vehicle_3, vehicle_4, vehicle_5, vehicle_6, vehicle_7 ]) TestHelpers.assert_expected_parking_placement( levels=garage.levels, expected_levels=[ expected_vehicles_on_level_1, expected_vehicles_on_level_2, expected_vehicles_on_level_3, ], )
def test_compact_vehicles_with_disability_permits_do_not_take_priority_over_non_permitted_spaces( ): parking_space_a = ParkingSpace(required_permit=Permit.DISABILITY) parking_space_b = ParkingSpace(compact=True) parking_space_c = ParkingSpace(compact=True) parking_space_d = ParkingSpace(required_permit=Permit.DISABILITY) parking_space_e = ParkingSpace(required_permit=Permit.DISABILITY) parking_space_f = ParkingSpace(compact=True) parking_level_1 = ParkingLevel(spaces=[parking_space_a, parking_space_b]) parking_level_2 = ParkingLevel(spaces=[parking_space_c, parking_space_d]) parking_level_3 = ParkingLevel(spaces=[parking_space_e, parking_space_f]) garage = Garage(levels=[parking_level_1, parking_level_2, parking_level_3]) vehicle_1 = Vehicle() vehicle_2 = Vehicle(vehicle_type=VehicleType.Compact, permit=Permit.DISABILITY) vehicle_3 = Vehicle(vehicle_type=VehicleType.Compact, permit=Permit.DISABILITY) vehicle_4 = Vehicle(vehicle_type=VehicleType.Compact) vehicle_5 = Vehicle(vehicle_type=VehicleType.Compact) vehicle_6 = Vehicle(vehicle_type=VehicleType.Compact, permit=Permit.DISABILITY) vehicle_7 = Vehicle(vehicle_type=VehicleType.Compact, permit=Permit.DISABILITY) expected_vehicles_on_level_1: List[Vehicle] = [vehicle_2, vehicle_4] expected_vehicles_on_level_2: List[Vehicle] = [vehicle_5, vehicle_3] expected_vehicles_on_level_3: List[Vehicle] = [vehicle_6, vehicle_7] garage.add_vehicles([ vehicle_1, vehicle_2, vehicle_3, vehicle_4, vehicle_5, vehicle_6, vehicle_7 ]) TestHelpers.assert_expected_parking_placement( levels=garage.levels, expected_levels=[ expected_vehicles_on_level_1, expected_vehicles_on_level_2, expected_vehicles_on_level_3, ], )
def test_vehicles_with_premium_permits_take_priority_over_non_permitted_spaces( ): parking_space_a = ParkingSpace(required_permit=Permit.PREMIUM) parking_space_b = ParkingSpace() parking_space_c = ParkingSpace() parking_space_d = ParkingSpace(required_permit=Permit.PREMIUM) parking_space_e = ParkingSpace() parking_space_f = ParkingSpace() parking_level_1 = ParkingLevel(spaces=[parking_space_a, parking_space_b]) parking_level_2 = ParkingLevel(spaces=[parking_space_c, parking_space_d]) parking_level_3 = ParkingLevel(spaces=[parking_space_e, parking_space_f]) garage = Garage(levels=[parking_level_1, parking_level_2, parking_level_3]) vehicle_1 = Vehicle() vehicle_2 = Vehicle(permit=Permit.PREMIUM) vehicle_3 = Vehicle(permit=Permit.PREMIUM) vehicle_4 = Vehicle() vehicle_5 = Vehicle(permit=Permit.PREMIUM) vehicle_6 = Vehicle(permit=Permit.PREMIUM) vehicle_7 = Vehicle(permit=Permit.PREMIUM) expected_vehicles_on_level_1: List[Vehicle] = [vehicle_2, vehicle_5] expected_vehicles_on_level_2: List[Vehicle] = [vehicle_6, vehicle_3] expected_vehicles_on_level_3: List[Vehicle] = [vehicle_7, vehicle_1] garage.add_vehicles([ vehicle_1, vehicle_2, vehicle_3, vehicle_4, vehicle_5, vehicle_6, vehicle_7 ]) TestHelpers.assert_expected_parking_placement( levels=garage.levels, expected_levels=[ expected_vehicles_on_level_1, expected_vehicles_on_level_2, expected_vehicles_on_level_3, ], )
def test_vehicles_are_added_to_single_level_garage_until_capacity_is_reached(): parking_level_1 = ParkingLevel(spaces=[ ParkingSpace(), ParkingSpace(), ParkingSpace(), ParkingSpace(), ParkingSpace(), ParkingSpace(), ]) garage = Garage(levels=[parking_level_1]) vehicle_1 = Vehicle() vehicle_2 = Vehicle() vehicle_3 = Vehicle() vehicle_4 = Vehicle() vehicle_5 = Vehicle() vehicle_6 = Vehicle() vehicle_7 = Vehicle() expected_vehicles_on_level_1: List[Vehicle] = [ vehicle_1, vehicle_2, vehicle_3, vehicle_4, vehicle_5, vehicle_6, ] garage.add_vehicles([ vehicle_1, vehicle_2, vehicle_3, vehicle_4, vehicle_5, vehicle_6, vehicle_7 ]) TestHelpers.assert_expected_parking_placement( levels=garage.levels, expected_levels=[ expected_vehicles_on_level_1, ], )
def test_vehicles_with_premium_permits_are_added_to_premium_parking_spaces(): parking_space_a = ParkingSpace(required_permit=Permit.PREMIUM) parking_space_b = ParkingSpace() parking_space_c = ParkingSpace(required_permit=Permit.PREMIUM) parking_space_d = ParkingSpace(required_permit=Permit.PREMIUM) parking_space_e = ParkingSpace() parking_space_f = ParkingSpace(required_permit=Permit.PREMIUM) parking_level_1 = ParkingLevel(spaces=[parking_space_a, parking_space_b]) parking_level_2 = ParkingLevel(spaces=[parking_space_c, parking_space_d]) parking_level_3 = ParkingLevel(spaces=[parking_space_e, parking_space_f]) garage = Garage(levels=[parking_level_1, parking_level_2, parking_level_3]) vehicle_1 = Vehicle() vehicle_2 = Vehicle(permit=Permit.DISABILITY | Permit.PREMIUM) vehicle_3 = Vehicle(permit=Permit.PREMIUM) vehicle_4 = Vehicle() vehicle_5 = Vehicle() vehicle_6 = Vehicle(permit=Permit.PREMIUM) expected_vehicles_on_level_1: List[Vehicle] = [vehicle_2, vehicle_1] expected_vehicles_on_level_2: List[Vehicle] = [vehicle_3, vehicle_6] expected_vehicles_on_level_3: List[Vehicle] = [vehicle_4, None] garage.add_vehicles( [vehicle_1, vehicle_2, vehicle_3, vehicle_4, vehicle_5, vehicle_6] ) TestHelpers.assert_expected_vehicles_on_levels( levels=garage.levels, expected_vehicles=[ expected_vehicles_on_level_1, expected_vehicles_on_level_2, expected_vehicles_on_level_3, ], )
def test_new_parking_spaces_are_empty(): parking_space = ParkingSpace() assert parking_space.vehicle is None, "Default parking space is not empty."
def test_new_parking_spaces_do_not_require_permits(): parking_space = ParkingSpace() assert (parking_space.required_permit is Permit.NONE), "Default parking space requires a permit."
def test_new_parking_spaces_are_not_compact(): parking_space = ParkingSpace() assert not parking_space.compact, "Default parking space is compact."