def request_uber(): """Make sandbox Uber ride request""" search = Search.query.order_by(Search.date.desc()).first() search.uber_request = True db.session.commit() credentials2 = import_oauth2_credentials() oauth2credential = OAuth2Credential( client_id=credentials2.get('client_id'), access_token=sesh.get('access_token'), expires_in_seconds=credentials2.get('expires_in_seconds'), scopes=credentials2.get('scopes'), grant_type=credentials2.get('grant_type'), redirect_url=credentials2.get('redirect_url'), client_secret=credentials2.get('client_secret'), refresh_token=credentials2.get('refresh_token'), ) uber_session = Session(oauth2credential=oauth2credential) uber_client = UberRidesClient(uber_session, sandbox_mode=True) # receive data from Ajax call start_lat = request.form.get('start_lat') start_lng = request.form.get('start_lng') end_lat = request.form.get('end_lat') end_lng = request.form.get('end_lng') response = uber_client.get_products(37.3688301, -122.0363495) products = response.json.get('products') product_id = products[0].get('product_id') # make sandbox calls ride_request = uber_client.request_ride(product_id=product_id, start_latitude=37.3688301, start_longitude=-122.0363495, end_latitude=37.8003415, end_longitude=-122.4331332) ride_details = ride_request.json ride_id = ride_details.get('request_id') get_ride = uber_client.update_sandbox_ride(ride_id, 'accepted') send_uber_text(); return jsonify(ride_details)
def test_send_uber_text(self): """Test SMS with invalid phone number""" self.assertEqual(send_uber_text('+1234567890'), "Error")
def test_send_uber_text(self): """Test SMS with uber ride information""" self.assertEqual(send_uber_text('+1203983811'), "success")