Example #1
0
from customer import Customer
from car import SmallCar, MediumCar, LargeCar, PremiumCar
from car_rental_system import CarRentalSystem
from location import Location

# Populate the system
CRS = CarRentalSystem()

# Add customers
CRS.add_customer(Customer("Matt", 18, 1, "*****@*****.**"))
CRS.add_customer(Customer("Isaac", 31, 2, "*****@*****.**"))
CRS.add_customer(Customer("Taylor", 27, 3, "*****@*****.**"))

# Add cars
CRS.add_car(SmallCar("Mazda", "Falcon", 2019, 1))
CRS.add_car(MediumCar("Mazda", "Falcon", 2019, 2))
CRS.add_car(LargeCar("Mazda", "Falcon", 2019, 3))
CRS.add_car(SmallCar("Mazda", "Commodore", 2019, 4))
CRS.add_car(MediumCar("Mazda", "Commodore", 2019, 5))
CRS.add_car(LargeCar("Mazda", "Commodore", 2019, 6))
CRS.add_car(SmallCar("Holden", "Falcon", 2019, 7))
CRS.add_car(MediumCar("Holden", "Falcon", 2019, 8))
CRS.add_car(LargeCar("Holden", "Falcon", 2019, 9))
CRS.add_car(SmallCar("Holden", "Commodore", 2019, 10))
CRS.add_car(MediumCar("Holden", "Commodore", 2019, 11))
CRS.add_car(LargeCar("Holden", "Commodore", 2019, 12))
CRS.add_car(SmallCar("Ford", "Falcon", 2019, 13))
CRS.add_car(MediumCar("Ford", "Falcon", 2019, 14))
CRS.add_car(LargeCar("Ford", "Falcon", 2019, 15))
CRS.add_car(SmallCar("Ford", "Commodore", 2019, 16))
CRS.add_car(MediumCar("Ford", "Commodore", 2019, 17))
Example #2
0
def rental_fixture():

    rego_generator = IdGenerator()
    licence_generator = IdGenerator()

    system = CarRentalSystem()
    for name in ["Mazda", "Holden", "Ford"]:
        for model in ["Falcon", "Commodore"]:
            system.add_car(SmallCar(name, model, rego_generator.next()))
            system.add_car(MediumCar(name, model, rego_generator.next()))
            system.add_car(LargeCar(name, model, rego_generator.next()))

    for name in ["Tesla", "Audi"]:
        for model in ["model x", "A4", "S class"]:
            system.add_car(PremiumCar(name, model, rego_generator.next()))

    print(system.cars)
    for name in ["Matt", "Isaac", "Taylor"]:
        system.add_customer(Customer(name, licence_generator.next()))

    return system
from location import Location
from datetime import datetime
from errors import BookingError
from car import SmallCar, MediumCar, LargeCar, PremiumCar
from customer import Customer
from car_rental_system import CarRentalSystem

import pytest
system = CarRentalSystem()


class IdGenerator():
    def __init__(self):
        self._id = 0

    def next(self):
        self._id += 1
        return self._id


rego_generator = IdGenerator()
licence_generator = IdGenerator()


@pytest.fixture
def rental_fixture():
    rego_generator = IdGenerator()
    licence_generator = IdGenerator()
    for name in ["Mazda", "Holden", "Ford"]:
        for model in ["Falcon", "Commodore"]:
            system.add_car(SmallCar(name, model, rego_generator.next()))
Example #4
0
from car import SmallCar, MediumCar, LargeCar, PremiumCar
from car_rental_system import CarRentalSystem
from customer import Customer
from location import Location

system = CarRentalSystem()


class IdGenerator():
    def __init__(self):
        self._id = 0

    def next(self):
        self._id += 1
        return self._id


rego_generator = IdGenerator()
licence_generator = IdGenerator()

for name in ["Mazda", "Holden", "Ford"]:
    for model in ["Falcon", "Commodore"]:
        system.add_car(SmallCar(name, model, rego_generator.next()))
        system.add_car(MediumCar(name, model, rego_generator.next()))
        system.add_car(LargeCar(name, model, rego_generator.next()))

for name in ["Tesla", "Audi"]:
    for model in ["model x", "A4", "S class"]:
        system.add_car(PremiumCar(name, model, rego_generator.next()))

for name in ["Matt", "Isaac", "Taylor"]:
Example #5
0
def empty_fixture():
    system1 = CarRentalSystem()
    return system1
Example #6
0
import pytest

from customer import Customer
from car import SmallCar, MediumCar, LargeCar, PremiumCar
from car_rental_system import CarRentalSystem
from location import Location

# Populate the system
CRS = CarRentalSystem()


def test_add_customers():
    lookup = Customer("Matt", 18, 1, "*****@*****.**")
    CRS.add_customer(lookup)
    CRS.add_customer(Customer("Isaac", 31, 2, "*****@*****.**"))
    CRS.add_customer(Customer("Taylor", 27, 3, "*****@*****.**"))

    print("\n\n> Try to find customer with valid licence")
    lic = 1
    print(f"Looking for customer with licence {lic}")
    customer = CRS.get_customer(lic)
    print(f"Returned: {customer} (Expected: {None})")
    print(f"Test: {customer is None}")
    assert (customer is lookup)

    print("\n\n> Try to find non-existent customer with unknown licence")
    lic = 3333
    print(f"Looking for customer with licence {lic}")
    customer = CRS.get_customer(lic)
    print(f"Returned: {customer} (Expected: {None})")
    print(f"Test: {customer is None}")