def app(mocker): mocker.patch.object(sentry, 'client', None) mocker.patch.object(settings, 'SENTRY_DSN', 'gevent+http://foo:[email protected]/1') app = create_app() app.config['PROPAGATE_EXCEPTIONS'] = False @app.route('/api/internal_server_error') def internal_server_error(): raise Exception('meow') @app.route('/api/busy') def busy(): gevent.sleep(1) return 'busy' @app.route('/api/busy_with_login') @login_required def busy_with_login(): gevent.sleep(1) return 'busy' @app.route('/api/busy_with_bad_request') def busy_with_bad_request(): gevent.sleep(1) abort(400, 'bad request') return app
def app(mocker): mocker.patch.object(sentry, 'client', None) mocker.patch.object(settings, 'SENTRY_DSN', 'gevent+http://foo:[email protected]/1') app = create_app() app.config['PROPAGATE_EXCEPTIONS'] = False @app.route('/api/internal_server_error') def internal_server_error(): raise Exception('meow') @app.route('/api/bad_method', methods=['POST']) def bad_method(): abort(400, 'woo') @app.route('/api/fine') def fine(): return 'fine' @app.route('/api/need_login') @login_required def need_login(): return 'fine' return app
def app(): app = create_app() app.config['PROPAGATE_EXCEPTIONS'] = False @app.route('/api/minimal-mode') def minimal_mode(): return unicode(g.auth.is_minimal_mode) return app
def app(): app = create_app() app.config['PROPAGATE_EXCEPTIONS'] = False @app.route('/api/minimal-mode') def minimal_mode(): return unicode(g.auth.is_minimal_mode) @app.route('/api/mysql') def mysql_error(): raise SQLAlchemyError() @app.route('/api/redis') def redis_error(): raise RedisError() return app
def app(): app = create_app() @app.route('/whoami') def whoami(): if not g.auth: return '', 401 return api_response(data=dict(username=g.auth.username, is_application=g.auth.is_application, is_admin=g.auth.is_admin)) @app.route('/incompatible') @minimal_mode_incompatible def incompatible(): return '' return app
def app(): app = create_app() app.config['PROPAGATE_EXCEPTIONS'] = False @app.route('/api/this_is_bad') def this_is_bad(): raise Exception('meow') @app.route('/api/this_is_okay') def this_is_okay(): return api_response() @app.route('/api/this_is_sad') def this_is_sad(): return 'sad', 400 @app.route('/api/post_list', methods=['POST']) def post_list(): return api_response() return app
def app(): app = create_app() app.config['PROPAGATE_EXCEPTIONS'] = False @app.route('/api/test_etag') @with_etag def test_etag(): return api_response(data={ '233': request.args.get('value', '666'), }) @app.route('/api/test_cache_control') @with_cache_control def test_cache_control(): return api_response() @app.route('/api/test_email') def test_email(): deliver_email_safe(EmailTemplate.DEBUG, '*****@*****.**', {'foo': 't'}) return api_response() return app
def gen(): """Generates snapshot with updated template.""" # We can not use pytest fixtures without pytest as launcher. # Is there a better way? settings.ADMIN_HOME_URL = 'http://example.com' settings.ADMIN_SIGNUP_URL = 'http://example.com/ewf' settings.ADMIN_RESET_PASSWORD_URL = \ 'http://example.com/password-reset/{username}/{token}' settings.ADMIN_INFRA_CONFIG_URL = \ 'http://example.com/application/{application_name}/config?' \ 'infra_type={infra_type}&infra_name={infra_name}' app = create_app() print('-' * 70) print('Generating snapshots ...') print('-' * 70) indices = [] for id_, template, arguments in SNAPSHOT_ARGUMENTS: filename, _, _ = template.value with app.app_context(): result = render_email_template(template, **arguments) with get_snapshot(filename, id_).open('w') as snapshot: snapshot.write(result.encode('utf-8')) print('%s %r\n%s\n---' % (template.name, arguments, snapshot.name)) relpath = DOCUMENT_DIR.bestrelpath(get_snapshot(filename, id_)) indices.append((id_, template.value, relpath)) print('Generating documents ...') with app.app_context(): result = render_template('docs-assets-index.rst', indices=indices) with DOCUMENT_DIR.join('index.rst').open('w') as index: index.write('.. DO NOT EDIT (auto generated)\n\n') index.write(result.encode('utf-8')) print('-' * 70) print(SNAPSHOT_ANNOUNCE) print('-' * 70)
def app(mocker): return create_app()