class CarTestCase(unittest.TestCase):
    a = Car(maker='Ford',
            model='Mustang',
            year=2005,
            base_price=18000,
            miles=31000)  #example object
    b = Car(maker='Ford',
            model='Mustang',
            year=2014,
            base_price=31000,
            miles=11000)  #example object

    def is_it_maker_equal_to_FORD(self):
        self.assertEquals(CarTestCase.a.maker, 'Ford')

    def test_car_creation(self):
        self.assertEqual(CarTestCase.a.maker, 'Ford')
        self.assertEqual(CarTestCase.a.model, 'Mustang')
        self.assertEqual(CarTestCase.a.year, 2005)
        self.assertEqual(CarTestCase.a.base_price, 18000)
        self.assertEqual(CarTestCase.a.miles, 31000)

    def test_cars_sale_price(self):
        self.assertEqual(CarTestCase.a.sale_price(), 21600)
        self.assertEqual(CarTestCase.b.sale_price(), 37200)

    def test_cars_purchase_price(self):

        self.assertEqual(CarTestCase.a.purchase_price(), 21476)
        self.assertEqual(CarTestCase.b.purchase_price(), 37156)
def test_car_creation():
    c = Car(maker='Ford', model='Mustang', year=2005,
            base_price=18000, miles=31000)

    assert c.maker == 'Ford'
    assert c.model == 'Mustang'
    assert c.year == 2005
    assert c.base_price == 18000
    assert c.miles == 31000
    def setUp(self):
        self.car = Car(maker='Ford', model='Mustang', year=2005,
                       base_price=18000, miles=31000)

        self.truck = Truck(maker='Chevrolet', model='Silverado', year=2014,
                           base_price=29000, miles=3000)

        self.bike = Motorcycle(maker='Ducati', model='Monster',
                               year=2016, base_price=18000, miles=700)

        self.customer = Customer('John', 'Doe', '*****@*****.**')
        self.employee = Employee('Jane', 'Doe', '*****@*****.**')
    def test_car_creation(self):
        c = Car(maker='Ford',
                model='Mustang',
                year=2005,
                base_price=18000,
                miles=31000)

        self.assertEqual(c.maker, 'Ford')
        self.assertEqual(c.model, 'Mustang')
        self.assertEqual(c.year, 2005)
        self.assertEqual(c.base_price, 18000)
        self.assertEqual(c.miles, 31000)
def test_cars_purchase_price():
    v1 = Car(maker='Ford', model='Mustang', year=2005,
             base_price=18000, miles=31000)
    v2 = Car(maker='Ford', model='Mustang', year=2014,
             base_price=31000, miles=11000)

    assert v1.purchase_price() == 21476
    assert v2.purchase_price() == 37156
def test_cars_sale_price():
    v1 = Car(maker='Ford', model='Mustang', year=2005,
             base_price=18000, miles=31000)
    v2 = Car(maker='Ford', model='Mustang', year=2014,
             base_price=31000, miles=11000)

    assert v1.sale_price() == 21600
    assert v2.sale_price() == 37200
    def test_cars_purchase_price(self):
        v1 = Car(maker='Ford',
                 model='Mustang',
                 year=2005,
                 base_price=18000,
                 miles=31000)
        v2 = Car(maker='Ford',
                 model='Mustang',
                 year=2014,
                 base_price=31000,
                 miles=11000)

        self.assertEqual(v1.purchase_price(), 21476)
        self.assertEqual(v2.purchase_price(), 37156)
def fixtures():
    fix = Namespace()

    fix.car = Car(maker='Ford',
                  model='Mustang',
                  year=2005,
                  base_price=18000,
                  miles=31000)
    fix.truck = Truck(maker='Chevrolet',
                      model='Silverado',
                      year=2014,
                      base_price=29000,
                      miles=3000)
    fix.bike = Motorcycle(maker='Ducati',
                          model='Monster',
                          year=2016,
                          base_price=18000,
                          miles=700)

    fix.customer = Customer('John', 'Doe', '*****@*****.**')
    fix.employee = Employee('Jane', 'Doe', '*****@*****.**')
    return fix
Exemple #9
0
from pytest import approx

from dealership.contracts import BuyContract, LeaseContract
from dealership.customers import Customer, Employee
from dealership.vehicles import Car, Truck, Motorcycle

car = Car(maker='Ford',
          model='Mustang',
          year=2005,
          base_price=18000,
          miles=31000)

truck = Truck(maker='Chevrolet',
              model='Silverado',
              year=2014,
              base_price=29000,
              miles=3000)

bike = Motorcycle(maker='Ducati',
                  model='Monster',
                  year=2016,
                  base_price=18000,
                  miles=700)

customer = Customer('John', 'Doe', '*****@*****.**')
employee = Employee('Jane', 'Doe', '*****@*****.**')


def test_buy_contract_total_value_with_customer():
    car_contract = BuyContract(vehicle=car,
                               customer=customer,