class MotorcycleTestCase(unittest.TestCase):
    e = Motorcycle(maker='Ducati',
                   model='Monster',
                   year=2016,
                   base_price=18000,
                   miles=700)  #example object
    f = Motorcycle(maker='Ducati',
                   model='Monster',
                   year=2009,
                   base_price=9000,
                   miles=11400)  #example object

    def test_motorcycle_creation(self):
        self.assertEqual(MotorcycleTestCase.e.maker, 'Ducati')
        self.assertEqual(MotorcycleTestCase.e.model, 'Monster')
        self.assertEqual(MotorcycleTestCase.e.year, 2016)
        self.assertEqual(MotorcycleTestCase.e.base_price, 18000)
        self.assertEqual(MotorcycleTestCase.e.miles, 700)

    def test_motorcycle_sale_price(self):
        self.assertEqual(MotorcycleTestCase.e.sale_price(), 19800)
        self.assertEqual(MotorcycleTestCase.f.sale_price(), 9900)

    def test_motorcycle_purchase_price(self):
        self.assertEqual(MotorcycleTestCase.e.purchase_price(), 19793.7)
        self.assertEqual(MotorcycleTestCase.f.purchase_price(), 9797.4)
def test_motorcycle_creation():
    m = Motorcycle(maker='Ducati', model='Monster', year=2016,
                   base_price=18000, miles=700)

    assert m.maker == 'Ducati'
    assert m.model == 'Monster'
    assert m.year == 2016
    assert m.base_price == 18000
    assert m.miles == 700
    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_motorcycle_creation(self):
        m = Motorcycle(maker='Ducati',
                       model='Monster',
                       year=2016,
                       base_price=18000,
                       miles=700)

        self.assertEqual(m.maker, 'Ducati')
        self.assertEqual(m.model, 'Monster')
        self.assertEqual(m.year, 2016)
        self.assertEqual(m.base_price, 18000)
        self.assertEqual(m.miles, 700)
def test_motorcycle_purchase_price():
    v1 = Motorcycle(maker='Ducati', model='Monster', year=2016,
                    base_price=18000, miles=700)
    v2 = Motorcycle(maker='Ducati', model='Monster', year=2009,
                    base_price=9000, miles=11400)

    assert v1.purchase_price() == 19793.7
    assert v2.purchase_price() == 9797.4
def test_motorcycle_sale_price():
    v1 = Motorcycle(maker='Ducati', model='Monster', year=2016,
                    base_price=18000, miles=700)
    v2 = Motorcycle(maker='Ducati', model='Monster', year=2009,
                    base_price=9000, miles=11400)

    assert v1.sale_price() == 19800
    assert v2.sale_price() == 9900
    def test_motorcycle_purchase_price(self):
        v1 = Motorcycle(maker='Ducati',
                        model='Monster',
                        year=2016,
                        base_price=18000,
                        miles=700)
        v2 = Motorcycle(maker='Ducati',
                        model='Monster',
                        year=2009,
                        base_price=9000,
                        miles=11400)

        self.assertEqual(v1.purchase_price(), 19793.7)
        self.assertEqual(v2.purchase_price(), 9797.4)
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
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,
                               monthly_payments=6)

    assert car_contract.total_value() == approx(22986.72, rel=1e-5)
    assert car_contract.monthly_value() == approx(3831.12, rel=1e-5)