コード例 #1
0
ファイル: test_CarManager.py プロジェクト: borko81/python_oop
    def test_carRefuelWithPositiveAndBiggerFromCapasity_ShouldReturn(self):
        make = "Test Car"
        model = 'Test model'
        fuel_consumption = 6
        fuel_capacity = 60

        params = [make, model, fuel_consumption, fuel_capacity]
        car = Car(*params)
        car.refuel(car.fuel_capacity * 2)

        self.assertEqual(car.fuel_capacity, car.fuel_amount)
コード例 #2
0
ファイル: test_CarManager.py プロジェクト: borko81/python_oop
    def test_driveWhenNotEnoughtFuelRaiseException(self):
        make = "Test Car"
        model = 'Test model'
        fuel_consumption = 6
        fuel_capacity = 60

        params = [make, model, fuel_consumption, fuel_capacity]
        car = Car(*params)
        with self.assertRaises(Exception) as x:
            car.drive(100)

        self.assertIsNotNone(x.exception)
コード例 #3
0
ファイル: test_CarManager.py プロジェクト: borko81/python_oop
    def test_carRefuelWithNegative_ShouldRaiseException(self):
        make = "Test Car"
        model = 'Test model'
        fuel_consumption = 6
        fuel_capacity = 60

        params = [make, model, fuel_consumption, fuel_capacity]
        car = Car(*params)
        with self.assertRaises(Exception) as x:
            car.refuel(-1)

        self.assertIsNotNone(x.exception)
コード例 #4
0
ファイル: test_CarManager.py プロジェクト: borko81/python_oop
    def test_catNegativeFuelAmmount_ShouldRaise(self):
        make = "Test Car"
        model = 'Test model'
        fuel_consumption = 6
        fuel_capacity = 60

        params = [make, model, fuel_consumption, fuel_capacity]
        car = Car(*params)
        with self.assertRaises(Exception) as x:
            car.fuel_amount = -1

        self.assertIsNotNone(x.exception)
コード例 #5
0
ファイル: test_CarManager.py プロジェクト: borko81/python_oop
    def test_carInitWithCorectValues(self):
        make = "Test make"
        model = 'Test model'
        fuel_consumption = 6
        fuel_capacity = 60

        car = Car(make, model, fuel_consumption, fuel_capacity)
        expected = [make, model, fuel_consumption, fuel_capacity, 0]
        actual = [
            car.make, car.model, car.fuel_consumption, car.fuel_capacity,
            car.fuel_amount
        ]

        self.assertListEqual(expected, actual)
コード例 #6
0
ファイル: test_CarManager.py プロジェクト: borko81/python_oop
    def test_driveWhithEnoughtFuelRaiseException(self):
        make = "Test Car"
        model = 'Test model'
        fuel_consumption = 6
        fuel_capacity = 60

        params = [make, model, fuel_consumption, fuel_capacity]
        car = Car(*params)
        car.refuel(car.fuel_capacity)
        distance = 100
        car.drive(distance)

        expected = car.fuel_capacity - car.fuel_consumption * distance / 100
        actual = car.fuel_amount

        self.assertEqual(expected, actual)
コード例 #7
0
ファイル: test_CarManager.py プロジェクト: borko81/python_oop
 def __get_exception_from_init(self, make, model, fuel_consumption,
                               fuel_capacity):
     with self.assertRaises(Exception) as ex:
         Car(make, model, fuel_consumption, fuel_capacity)
     return ex.exception