Exemple #1
0
 def test_good_empty_filling(self):
     """
     Filling tank with nothing.
     """
     for car in self.ex1:
         c = Car(*car)
         self.assertEqual(c.fill_tank(liters=0), 0)
         c = Car(*car)
         self.assertEqual(c.fill_tank(limit=0.), 0)
Exemple #2
0
 def test_good_full_filling(self):
     """
     Checking filling the tank to maximum with all the methods.
     """
     for car, ans in zip(self.ex1, self.ex1_full):
         c = Car(*car)
         self.assertEqual(c.fill_tank(), ans)
         c = Car(*car)
         self.assertEqual(c.fill_tank(limit=1.), ans)
         c = Car(*car)
         self.assertEqual(c.fill_tank(liters=ans), ans)
Exemple #3
0
 def test_good_limit_filling(self):
     """
     Test filling with limit.
     """
     for limits, car in zip(self.ex1_prc, self.ex1):
         for (prc, ans) in limits:
             c = Car(*car)
             self.assertEqual(c.fill_tank(limit=prc), ans)
Exemple #4
0
 def test_bad_input_methods(self):
     for car in self.ex1:
         c = Car(*car)
         with self.assertRaises(TypeError):
             c.fill_tank(liters='sto')
         with self.assertRaises(TypeError):
             c.fill_tank(limit='sto')
         with self.assertRaises(TypeError):
             c.fill_tank(limit=1., liters=100)
         with self.assertRaises(ValueError):
             c.fill_tank(other=10)
Exemple #5
0
 def test_numers_liters(self):
     for car, (f, a) in zip(self.ex_numbers, self.ex_numbers_liters):
         c = Car(*car)
         self.assertEqual(c.fill_tank(liters=f), a)
Exemple #6
0
 def test_numbers_limit(self):
     for car, (f, a) in zip(self.ex_numbers, self.ex_numbers_limit):
         c = Car(*car)
         res = c.fill_tank(limit=f)
         self.assertEqual(res, a)
Exemple #7
0
 def test_bad_liters(self):
     for liters, car in zip(self.ex1_bad_liters, self.ex1):
         for e in liters:
             c = Car(*car)
             with self.assertRaises(ValueError):
                 c.fill_tank(liters=e)
Exemple #8
0
 def test_good_liters_filling(self):
     for liters, car in zip(self.ex1_liters, self.ex1):
         for ans in liters:
             c = Car(*car)
             self.assertEqual(c.fill_tank(liters=ans), ans)
Exemple #9
0
 def test_good_creating(self):
     for car in self.ex1:
         c = Car(*car)
         d = DieselCar(*car)
         self.assertEqual(str(c), info(c, car))
         self.assertEqual(str(d), info(d, car))
Exemple #10
0
import unittest

from zadanie2 import Car, get_carpool, DieselCar

test_car = Car('Test', 100, 70)
test_diesel_car = DieselCar('Test_diesel', 100, 10)
brand_car = [
    'Peugeot', 'Volvo', 'Skoda', 'Fiat', 'Ford', 'Doge', 'BMW', 'Toyota',
    'Mazda', 'Jaguar'
]


class TestZadanie2(unittest.TestCase):
    def test_fill_tank_over_limit(self):
        with self.assertRaises(Exception) as context:
            test_car.fill_tank(limit=1.1)
        self.assertTrue(
            'You can add limit only on range 0 to 1' in str(context.exception))

    def test_fill_tank_to_many_parameters(self):
        with self.assertRaises(Exception) as context:
            test_car.fill_tank(limit=0.5, liters=10)
        self.assertTrue(
            "You can add only one parameters they are mutually exclusive" in
            str(context.exception))

    def test_fill_tank_under_limit(self):
        with self.assertRaises(Exception) as context:
            limit = 0.5
            test_car.fill_tank(limit=limit)
        self.assertTrue(