Exemplo n.º 1
0
 def test_negative_load(self):
     """should raise error for negative load"""
     self.assertRaises(vehicle.OutOfRangeError,
                       vehicle.truck.get_actual_load,
                       vehicle.truck('test', 10, 10, 10, 5, -1))
     self.assertRaises(vehicle.OutOfRangeError,
                       vehicle.truck.get_rated_load,
                       vehicle.truck('test', 1, 10, 0, -1, 0))
Exemplo n.º 2
0
 def test_unloading(self):
     for unload_amount, known_result in self.knownUnloadingValues:
         testTruck = vehicle.truck("testTruck", self.horsepower,
                                   self.max_speed, self.speed,
                                   self.rated_load, self.actual_load)
         testTruck.unloading(unload_amount)
         final_load = testTruck.actual_load
         self.assertEqual(final_load, known_result)
Exemplo n.º 3
0
 def test_loading(self):
     for additional_load, known_result in self.knownLoadingValues:
         testTruck = vehicle.truck("testTruck", self.horsepower,
                                   self.max_speed, self.speed,
                                   self.rated_load, self.actual_load)
         print(
             "Test truck currently has %dkg of load and its max load is %dkg"
             % (testTruck.actual_load, testTruck.rated_load))
         testTruck.loading(additional_load)
         final_load = testTruck.actual_load
         self.assertEqual(final_load, known_result)
Exemplo n.º 4
0
            num = car.actual_passenger - car.rated_passenger_capacity
            car.get_off(num)

            if num == 1:
                print(str(num) + " people gets off the " + name + ".")
            else:
                print(str(num) + " people get off the " + name + ".")

        while not car.is_full_speed():
            car.speed_up()
        print(name + " increases its speed to full speed.")

        speed = car.get_speed()
        passenger = car.get_actual_passenger()
        print(name + " travels at a speed of " + str(speed) + " km/h with " +
              str(passenger) + " people.")
        print()


if __name__ == '__main__':

    truck1 = vehicle.truck("truck1", 15, 120, 90, 50, 100)
    truck2 = vehicle.truck("truck2", 20, 100, 120, 80, 80)
    trucks = [truck1, truck2]

    car1 = vehicle.car("car1", 30, 120, 150, 15, 12)
    car2 = vehicle.car("car2", 40, 180, 100, 5, 6)
    cars = [car1, car2]

    traffic(trucks, cars)
Exemplo n.º 5
0
 def test_over_unload(self):
     testTruck = vehicle.truck("testTruck", 1, 90, 0, 100, 50)
     print(
         "Unloading should raise error if unloading more than actual load (not possible)"
     )
     self.assertRaises(vehicle.OutOfRangeError, testTruck.unloading, 60)