""" Grass development server. This server is intended for development only: it enables debugging tools, and use a different port (5000) so it can more easily interface with other applications. Launching the server is relatively easy:: $ pyvenv env $ source env/bin/activate; $ python dev.py """ from os import getenv from unittest import mock from application import app @mock.patch('analytics.context.get_current_user') @mock.patch('analytics.models.ows_account.get_vendor_id_by_subaccount_id') @mock.patch('owsrequest.flask_request.get_grass_headers') def run_dev_server( get_grass_headers, get_labelid_by_subaccountid, get_current_user): """Run developer server on localhost.""" labelid = getenv('LOCAL_USER') subaccountid = getenv('LOCAL_SUBACCOUNT') account_id = labelid if not subaccountid else subaccountid account_type = 'vendor' if not subaccountid else 'subaccount' get_current_user.return_value.user_id = account_id get_current_user.return_value.user_type = account_type get_grass_headers.return_value = [account_type, account_id] if subaccountid: get_labelid_by_subaccountid.return_value.message = labelid app.run(host='0.0.0.0', debug=True, port=5000) if __name__ == '__main__': run_dev_server()