コード例 #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')
コード例 #2
0
 def test_leave_method_returns_correct(self):
     self.carpark.createParkingLots(2)
     car1 = Car("KA-01-HH-1234", "Red")
     car2 = Car("KA-01-HH-1235", "Gray")
     self.carpark.parkCar(car1)
     self.carpark.parkCar(car2)
     res = self.carpark.leave(2)
     self.assertEqual(True, res)
コード例 #3
0
 def test_parkCar_method_returns_negOne_carpark_full(self):
     self.carpark.createParkingLots(2)
     car1 = Car("KA-01-HH-1234", "Red")
     car2 = Car("KA-01-HH-1235", "Gray")
     car3 = Car("KA-01-HH-1236", "Blue")
     self.carpark.parkCar(car1)
     self.carpark.parkCar(car2)
     res = self.carpark.parkCar(car3)
     self.assertEqual(-1, res)
コード例 #4
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`'
        )
コード例 #5
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`'
        )
コード例 #6
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'
     )
コード例 #7
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'
     )
コード例 #8
0
ファイル: test_car.py プロジェクト: sagarladla/mini-projects
class TestCarMethods(unittest.TestCase):
    def setUp(self):
        self.car1 = Car("KA-01-HH-1234", "White")
        self.car2 = Car("KA-02-HH-1234", "Black")
        self.car3 = Car("KA-03-HH-1234", "black")

    def test_get_car_color_is_lowercase(self):
        self.assertEqual(self.car1.getColor(), "white")

    def test_get_car_color_compare_uppercase_and_lowercase(self):
        self.assertEqual(self.car2.getColor(), self.car2.getColor())

    def test_get_car_reg_no(self):
        self.assertEqual(self.car1.getRegNo(), "KA-01-HH-1234")
コード例 #9
0
ファイル: test_car.py プロジェクト: rhnvrm/mini-projects
class TestCarMethods(unittest.TestCase):

    def setUp(self):
        self.car1 = Car("KA-01-HH-1234", "White")
        self.car2 = Car("KA-02-HH-1234", "Black")
        self.car3 = Car("KA-03-HH-1234", "black")
    
    def test_get_car_color_is_lowercase(self):
        self.assertEqual(self.car1.getColor(), "white")

    def test_get_car_color_compare_uppercase_and_lowercase(self):
        self.assertEqual(self.car2.getColor(), self.car2.getColor())

    def test_get_car_reg_no(self):
        self.assertEqual(self.car1.getRegNo(), "KA-01-HH-1234")
コード例 #10
0
  def parse_action(self,inputs):
    if inputs[0] == "exit":
      return

    elif inputs[0] == "create_parking_lot":
      if self.validate_input(inputs,1):
        res = self.__interface.create_parking_lots(int(inputs[1]))
        if res > 0:
          return "Created a parking lot with " + str(res) + " slots"
        else:
          return "Parking lot already exists"

    elif inputs[0] == "park":
      if self.validate_input(inputs,2):
        car = Car(inputs[1],inputs[2])
        res = self.__interface.park_car(car)
        if res > 0:
          return "Allocated slot number: " + str(res)
        else:
          return "Sorry, parking lot is full"

    elif inputs[0] == "leave":
      if self.validate_input(inputs,1):
        res = self.__interface.leave_car(int(inputs[1]))
        if res:
          return "Slot number " + inputs[1] + " is free"
        else:
          return "No such slot number in parking lot"

    elif inputs[0] == "status":
      print("Slot No.".ljust(12) + "Registration No".ljust(19) + "Colour")
      res = self.__interface.print_status()
      for line in res:
        print(line)
      return

    elif inputs[0] == "registration_numbers_for_cars_with_colour":
      res = self.__interface.get_regNum_for_colour(inputs[1])
      if len(res) == 0:
        return "Not Found"

      printStr = (",").join(res)
      return printStr

    elif inputs[0] == "slot_numbers_for_cars_with_colour":
      res = self.__interface.get_slotNum_for_colour(inputs[1])
      if len(res) == 0:
        return "Not Found"

      printStr = (",").join(res)
      return printStr

    elif inputs[0] == "slot_number_for_registration_number":
      res = self.__interface.get_slotNum_for_regNum(inputs[1])
      if res > 0:
        return str(res)
      return "Not found"

    return "Invalid Input! Please check your input and try your command again."
コード例 #11
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'
     )
コード例 #12
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"
     )
コード例 #13
0
ファイル: parking.py プロジェクト: sagarladla/mini-projects
 def newCar(self, reg_no, color):
     car = Car(reg_no, color)
     try:
         slot = self.lot.index(None)
         self.lot[slot] = car
         return slot + 1
     except ValueError:
         return -1
コード例 #14
0
 def test_car_getDescription_method_returns_correct_result(self):
     c = Car("Ford Mustang", "red", "GT350")
     print(c.getDescription(), "Ford MustangGT350 in red color")
     print(c.getName(), "Ford Mustang")
コード例 #15
0
ファイル: test_car.py プロジェクト: zh-lim/ParkingLot
 def test_carCreation_correct_regno(self):
     car = Car("KA-01-HH-9980", "Black")
     res = car.getRegNo()
     self.assertEquals("KA-01-HH-9980", res)
コード例 #16
0
ファイル: test_car.py プロジェクト: zh-lim/ParkingLot
 def test_carCreation_correct_colour(self):
     car = Car("KA-01-HH-9980", "Black")
     res = car.getColour()
     self.assertEquals("Black", res)
コード例 #17
0
ファイル: camera.py プロジェクト: jmllubes/raspberry-pi-car
from flask import Flask, jsonify, Response
from flask_cors import cross_origin
from app.camera import Camera
from app.car import Car

app = Flask(__name__)
car = Car()
car.start()


@app.route("/health", methods=["GET"])
def health():
    return jsonify({"status": "OK"})


@cross_origin()
@app.route('/')
def video_feed():
    camera = Camera()
    return Response(camera.stream(),
                    mimetype='multipart/x-mixed-replace; boundary=frame')


if __name__ == "__main__":
    app.run(host='0.0.0.0', port=8081, debug=True)

print("Camera is down now")
コード例 #18
0
 def test_parkCar_method_returns_negOne_carpark_not_created(self):
     car3 = Car("KA-01-HH-1236", "Blue")
     res = self.carpark.parkCar(car3)
     self.assertEqual(-1, res)
コード例 #19
0
 def test_parkCar_method_returns_correct(self):
     self.carpark.createParkingLots(2)
     car = Car("KA-01-HH-9988", "Blue")
     res = self.carpark.parkCar(car)
     self.assertEqual(1, res)
コード例 #20
0
 def test_object_type(self):
     honda = Car('Honda')
     self.assertTrue((type(honda) is Car),
                     msg='The object should be a type of `Car`')
コード例 #21
0
ファイル: test_car.py プロジェクト: sagarladla/mini-projects
 def setUp(self):
     self.car1 = Car("KA-01-HH-1234", "White")
     self.car2 = Car("KA-02-HH-1234", "Black")
     self.car3 = Car("KA-03-HH-1234", "black")
コード例 #22
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')
コード例 #23
0
 def test_car_instance(self):
     honda = Car('Honda')
     self.assertIsInstance(
         honda,
         Car,
         msg='The object should be an instance of the `Car` class')
コード例 #24
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')
コード例 #25
0
ファイル: test_car.py プロジェクト: sagarladla/mini-projects
 def test_new_car(self):
     car = Car("KA-01-HH-1234", "White")
     reg_no = car.reg_no
     self.assertEqual("KA-01-HH-1234", reg_no)
     color = car.color
     self.assertEqual("White", color)
コード例 #26
0
ファイル: test_car.py プロジェクト: rhnvrm/mini-projects
 def setUp(self):
     self.car1 = Car("KA-01-HH-1234", "White")
     self.car2 = Car("KA-02-HH-1234", "Black")
     self.car3 = Car("KA-03-HH-1234", "black")