Example #1
0
 def test_fuel_battery(self):
     for id in ids:
         response1 = sc.get_fuel(id)
         response2 = sc.get_battery(id)
         self.assertNotEqual(response1,
                             'Status code other than 200 received!')
         self.assertNotEqual(response2,
                             'Status code other than 200 received!')
Example #2
0
 def test_engine(self):
     for id in ids:
         content_type = 'application/json'
         actions = ['START', 'STOP']
         for action in actions:
             response = sc.get_engine(id, content_type, action)
             self.assertNotEqual(response,
                                 'Status code other than 200 received!')
Example #3
0
 def get(self, request, id):
     info = sc.get_battery(id)
     if info == 'Status code other than 200 received!':
         response = Response()
         response.status_code = 404
         return response
     battery = Battery()
     battery.percent = info['percent']
     serializer = BatterySerializer(battery)
     return Response(serializer.data)
Example #4
0
 def get(self, request, id):
     info = sc.get_fuel(id)
     if info == 'Status code other than 200 received!':
         response = Response()
         response.status_code = 404
         return response
     fuel = Fuel()
     fuel.percent = info['percent']
     serializer = FuelSerializer(fuel)
     return Response(serializer.data)
Example #5
0
 def post(self, request, id):
     content_type = request.content_type
     action = request.data['action']
     info = sc.get_engine(id, content_type, action)
     if info == 'Status code other than 200 received!':
         response = Response()
         response.status_code = 404
         return response
     engine = Engine()
     engine.status = info['status']
     serializer = EngineSerializer(engine)
     return Response(serializer.data)
Example #6
0
 def get(self, request, id):
     info = sc.get_vehicle_info(id)
     if info == 'Status code other than 200 received!':
         response = Response()
         response.status_code = 404
         return response
     vehicle = Vehicle()
     vehicle.color = info['color']
     vehicle.doorCount = info['doorCount']
     vehicle.vin = info['vin']
     vehicle.driveTrain = info['driveTrain']
     serializer = VehicleSerializer(vehicle)
     return Response(serializer.data)
Example #7
0
 def get(self, request, id):
     info = sc.get_security(id)
     if info == 'Status code other than 200 received!':
         response = Response()
         response.status_code = 404
         return response
     security_list = []
     for element in info:
         security = Security()
         security.location = element['location']
         security.locked = element['locked']
         security_list.append(security)
     serializer = SecuritySerializer(security_list, many=True)
     return Response(serializer.data)
Example #8
0
 def test_vehicle_info(self):
     for id in ids:
         response = sc.get_vehicle_info(id)
         self.assertNotEqual(response,
                             'Status code other than 200 received!')
         if id == 1234:
             self.assertEquals(response['vin'], '123123412412')
             self.assertEquals(response['color'], 'Metallic Silver')
             self.assertEquals(response['doorCount'], 4)
             self.assertEquals(response['driveTrain'], 'v8')
         elif id == 1235:
             self.assertEquals(response['vin'], '1235AZ91XP')
             self.assertEquals(response['color'], 'Forest Green')
             self.assertEquals(response['doorCount'], 2)
             self.assertEquals(response['driveTrain'], 'electric')
Example #9
0
 def test_security(self):
     for id in ids:
         response = sc.get_security(id)
         self.assertNotEqual(response,
                             'Status code other than 200 received!')
Example #10
0
 def test_non_working_id(self):
     response = sc.get_vehicle_info(1236)
     self.assertEquals(response, 'Status code other than 200 received!')