Ejemplo n.º 1
0
 def test_car_wheels(self):
     man = Car('MAN', 'Truck', 'trailer')
     koenigsegg = Car('Koenigsegg', 'Agera R')
     self.assertEqual(
         [8, 4], [man.num_of_wheels, koenigsegg.num_of_wheels],
         msg=
         'The car shoud have four (4) wheels except its a type of trailer')
Ejemplo n.º 2
0
 def test_drive_car(self):
     man = Car('MAN', 'Truck', 'trailer')
     moving_man = man.drive(7)
     moving_man_instance = isinstance(moving_man, Car)
     moving_man_type = type(moving_man) is Car
     self.assertListEqual([True, True, man.speed],
                          [moving_man_instance, moving_man_type, moving_man.speed],
                          msg='The car drive function should return the instance of the Car class')
Ejemplo n.º 3
0
    def test_car_speed2(self):
        man = Car('Mercedes', 'SLR500')
        parked_speed = man.speed
        moving_speed = man.drive(3).speed

        self.assertListEqual([parked_speed, moving_speed],
                             [0, 1000],
                             msg='The Mercedes should have speed 0 km/h until you put `the pedal to the metal`')
Ejemplo n.º 4
0
    def test_car_speed(self):
        man = Car('MAN', 'Truck', 'trailer')
        parked_speed = man.speed
        moving_speed = man.drive(7).speed

        self.assertListEqual([parked_speed, moving_speed],
                             [0, 77],
                             msg='The Trailer should have speed 0 km/h until you put `the pedal to the metal`')
Ejemplo n.º 5
0
 def test_car_doors(self):
     opel = Car('Opel', 'Omega 3')
     porshe = Car('Porshe', '911 Turbo')
     self.assertListEqual([opel.num_of_doors,
                          porshe.num_of_doors,
                          Car('Koenigsegg', 'Agera R').num_of_doors],
                          [4, 2, 2],
                          msg='The car shoud have four (4) doors except its a Porshe or Koenigsegg')
 def test_drive_car(self):
     man = Car('MAN', 'Truck', 'trailer')
     moving_man = man.drive(7)
     moving_man_instance = isinstance(moving_man, Car)
     moving_man_type = type(moving_man) is Car
     self.assertListEqual([True, True, man.speed],
                          [moving_man_instance, moving_man_type, moving_man.speed],
                          msg='The car drive function should return the instance of the Car class')
    def test_car_speed2(self):
        man = Car('Mercedes', 'SLR500')
        parked_speed = man.speed
        moving_speed = man.drive(3).speed

        self.assertListEqual([parked_speed, moving_speed],
                             [0, 1000],
                             msg='The Mercedes should have speed 0 km/h until you put `the pedal to the metal`')
    def test_car_speed(self):
        man = Car('MAN', 'Truck', 'trailer')
        parked_speed = man.speed
        moving_speed = man.drive(7).speed

        self.assertListEqual([parked_speed, moving_speed],
                             [0, 77],
                             msg='The Trailer should have speed 0 km/h until you put `the pedal to the metal`')
Ejemplo n.º 9
0
 def test_default_car_model(self):
     gm = Car()
     self.assertEqual(
         'GM',
         gm.model,
         msg=
         "The car's model should be called `GM` if no model was passed as an argument"
     )
Ejemplo n.º 10
0
 def test_default_car_name(self):
     gm = Car()
     self.assertEqual(
         'General',
         gm.name,
         msg=
         'The car should be called `General` if no name was passed as an argument'
     )
Ejemplo n.º 11
0
 def test_car_instance(self):
     honda = Car('Honda')
     self.assertIsInstance(honda, Car, msg='The object should be an instance of the `Car` class')
Ejemplo n.º 12
0
 def test_car_type(self):
     koenigsegg = Car('Koenigsegg', 'Agera R')
     self.assertTrue(koenigsegg.is_saloon(),
                     msg='The car type should be saloon if it is not a trailer')
Ejemplo n.º 13
0
 def test_car_properties(self):
     toyota = Car('Toyota', 'Corolla')
     self.assertListEqual(['Toyota', 'Corolla'],
                          [toyota.name, toyota.model],
                          msg='The car name and model should be a property of the car')
Ejemplo n.º 14
0
 def test_object_type(self):
     honda = Car('Honda')
     self.assertTrue((type(honda) is Car), msg='The object should be a type of `Car`')
Ejemplo n.º 15
0
def main():
    audi = Car() 
    
    audi.startEngine()
    
    if audi.isRun():
        while audi.isRun():
            if audi.get_gear() == 0:
                print("Jedziemy? wbij bieg 1")
                b = input()
                if int(b) == 1:
                    audi.set_gear(int(b))
                else:
                    print("Od kiedy ruszmy z ", b)
                    audi.stopEngine()
            else:
                audi.carCockpit()
                time.sleep(1)
                if audi.get_gear() == 1:
                    audi.accelerator(4, 30, 5000)
                if audi.get_gear() == 2:
                    audi.accelerator(4, 60, 5000)
                if audi.get_gear() == 3:
                    audi.accelerator(4, 90, 5000)
                if audi.get_gear() == 4:
                    audi.accelerator(4, 120, 5000)
                    if audi.get_engine_speed() >= 9000:
                        audi.stopEngine(2)
 def test_car_type(self):
     koenigsegg = Car('Koenigsegg', 'Agera R')
     self.assertTrue(koenigsegg.is_saloon(),
                     msg='The car type should be saloon if it is not a trailer')