Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def setUpClass(cls):
super(TestVehicleDisconnectE2E, cls).setUpClass()
access_object = cls.client.exchange_code(cls.code)
access_token = access_object['access_token']
vehicle_ids = smartcar.get_vehicle_ids(access_token)
cls.vehicle = smartcar.Vehicle(
vehicle_ids['vehicles'][0],
access_token)
def setUp(self):
self.access_token = 'access_token'
self.vehicle_id = 'vehicle_id'
self.vehicle = smartcar.Vehicle(self.vehicle_id, self.access_token)
self.auth = 'Bearer ' + self.access_token
cars of different makes with our application. We then render a list of these
vehicles.
"""
# ensure that there is an access token
if not 'access' in db:
return redirect('/')
if smartcar.expired(db['access']['expiration']): # there is a token, but check if it is expired
db['access'] = client.exchange_token(db['access']['refresh_token']) # use our refresh token to obtain a new access object
# get the access token from the access object. We pass this to all smartcar calls
access_token = db['access']['access_token']
vehicle_ids = client.get_vehicles(access_token)['vehicles'] # get list of vehicles this user has authorized
vehicles = []
for vehicle_id in vehicle_ids:
vehicles.append(smartcar.Vehicle(vehicle_id, access_token))
vehicles[1].set_unit('imperial')
data = [get_data(vehicle) for vehicle in vehicles]
# return "<pre>" + json.dumps(data, indent=2) + "</pre>"
return render_template('vehicles.html', vehicles=data)