def create_app(): db = DB() flask = connexion.FlaskApp(__name__, specification_dir='../config/') flask.app.json_encoder = ExtendedJSONEncoder flask.app.config['MAX_CONTENT_LENGTH'] = config.get( 'uploads', 'max_upload_size') with open('/var/calendar/secrets/jwt_private.pem', 'rb') as fh: flask.app.config['JWT_PRIVATE_KEY'] = fh.read() with open('/var/calendar/secrets/jwt_public.pem', 'rb') as fh: flask.app.config['JWT_PUBLIC_KEY'] = fh.read() flask.add_api('openapi.yaml', resolver=RestyResolver('app')) @flask.app.teardown_appcontext def shutdown_session(exception=None): db.session.remove() return flask.app
import unittest from app import create_app from unittest.mock import patch from event_calendar.config import config from event_calendar.database import DB from event_calendar.testing.test_client import TestClient from werkzeug.exceptions import Forbidden from uuid import UUID, uuid4 as uuid db = DB() class TestApiGuards(unittest.TestCase): def setUp(self): config.set(['db', 'database'], 'test_guards') db.build_engine() db.create_db() app = create_app() app.test_client_class = TestClient self.client = app.test_client() def tearDown(self): db.destroy_db() def test_unauthenticated(self): res = self.client.post('/v1/events', json={ "org_id": uuid(), "info": [{
from event_calendar.database import DB DB().create_db()