Exemple #1
0
def test_1():

    user_name = "Matt"
    password = "******"
    system.new_customer(Customer(user_name, password, 1531))
    user = system.validate_login(user_name, password)
    assert user != None

    car_name = "Tesla"
    car_model = "model x"
    rego = 0
    system.add_car(PremiumCar(car_name, car_model, str(rego)))
    car = system.get_car(str(rego))
    assert car.get_name() == car_name
    assert car.get_model() == car_model

    location = Location("Sydney", "Mel")
    assert location

    date_format = "%Y-%m-%d"
    start_time = datetime.strptime("2018-11-11", date_format)
    end_time = datetime.strptime("2018-12-12", date_format)

    diff = end_time - start_time

    booking = system.make_booking(current_user, diff, car, location)
    assert booking._period == diff
    assert booking._car == car
    assert booking.location == location
    assert car.get_bookings()[0]
    assert system._bookings[0]
Exemple #2
0
def test_3():
    with pytest.raises(Exception) as err:
        user_name = "Taylor"
        password = "******"
        system.new_customer(Customer(user_name, password, 1531))
        user = system.validate_login(user_name, password)
        assert user != None

        car_name = "Tesla"
        car_model = "model x"
        rego = 0
        system.add_car(PremiumCar(car_name, car_model, str(rego)))
        car = system.get_car(str(rego))
        assert car.get_name() == car_name
        assert car.get_model() == car_model

        location = Location("Sydney", "Mel")
        assert location

        date_format = "%Y-%m-%d"
        start_time = datetime.strptime("", date_format)
        end_time = datetime.strptime("2018-11-10", date_format)

        diff = end_time - start_time

        booking = system.make_booking(current_user, diff, car, location)
        assert err.errors['start_date'] == 'The date is not valid'
Exemple #3
0
def test_2():
    user_name = "Issav"
    password = "******"
    system.new_customer(Customer(user_name, password, 1531))
    user = system.validate_login(user_name, password)
    assert user != None

    car_name = "Tesla"
    car_model = "model x"
    rego = 0
    system.add_car(PremiumCar(car_name, car_model, str(rego)))
    car = system.get_car(str(rego))
    assert car.get_name() == car_name
    assert car.get_model() == car_model

    location = Location("Sydney", "Mel")
    assert location

    date_format = "%Y-%m-%d"
    start_time = datetime.strptime("2018-11-11", date_format)
    end_time = datetime.strptime("2018-11-10", date_format)

    diff = end_time - start_time

    booking = system.make_booking(current_user, diff, car, location)
    system = CarRentalSystem()
Exemple #4
0
def generate_car_list(car_names, car_models):
    car_list = []
    car_id = 0
    for car_name in car_names:
        for car_model in car_models:
            car_list.append(SmallCar(car_name, car_model, car_id))
            car_id += 1
            car_list.append(MediumCar(car_name, car_model, car_id))
            car_id += 1
            car_list.append(LargeCar(car_name, car_model, car_id))
            car_id += 1
            car_list.append(PremiumCar(car_name, car_model, car_id))
    return car_list
def bootstrap_system():
    system = CarRentalSystem()

    rego = 0
    for name in ["Mazda", "Holden", "Ford"]:
        for model in ["Falcon", "Commodore", "Buggy"]:
            system.add_car(SmallCar(name, model, str(rego)))
            rego += 1
            system.add_car(MediumCar(name, model, str(rego)))
            rego += 1
            system.add_car(LargeCar(name, model, str(rego)))
            rego += 1

    for name in ["Tesla", "Audi", "Mercedes"]:
        for model in ["model x", "A4", "S class"]:
            system.add_car(PremiumCar(name, model, str(rego)))
            rego += 1

    for name in ["Matt", "Isaav", "Taylor"]:
        system.new_customer(Customer(name, 'pass', 1531))

    return system