async def get_application(self): app = get_application() app[SETTINGS] = TestSettings app[NON_WORKING_DAYS] = {self.MIN_DATE, self.MAX_DATE, *self.WEEKENDS} app[ALLOWED_DATE_MIN] = min(app[NON_WORKING_DAYS]) app[ALLOWED_DATE_MAX] = max(app[NON_WORKING_DAYS]) return app
def app() -> Generator[FastAPI, Any, None]: """ Create a fresh database on each test case. """ Base.metadata.create_all(engine) # Create the tables. _app = get_application() yield _app Base.metadata.drop_all(engine)
def setUp(self): #clears existing data from google.appengine.ext import db from google.appengine.ext import testbed from google.appengine.api import apiproxy_stub_map # First, create an instance of the Testbed class. self.testbed = testbed.Testbed() # Then activate the testbed, which prepares the service stubs for use. self.testbed.activate() # Next, declare which service stubs you want to use. self.testbed.init_datastore_v3_stub() self.testbed.init_taskqueue_stub(root_path = www_root) self.testbed.init_memcache_stub() self.app = RestifyMiddleware(get_application(), Member, 'member') self.app = TestApp(self.app, extra_environ = dict(HTTP_HOST='localhost:8080'))
def setUp(self): #clears existing data from google.appengine.ext import db from google.appengine.ext import testbed from google.appengine.api import apiproxy_stub_map # First, create an instance of the Testbed class. self.testbed = testbed.Testbed() # Then activate the testbed, which prepares the service stubs for use. self.testbed.activate() # Next, declare which service stubs you want to use. self.testbed.init_datastore_v3_stub() self.testbed.init_taskqueue_stub(root_path=www_root) self.testbed.init_memcache_stub() self.app = RestifyMiddleware(get_application(), Member, 'member') self.app = TestApp(self.app, extra_environ=dict(HTTP_HOST='localhost:8080'))
from aiohttp import web import main if __name__ == '__main__': app = main.get_application() web.run_app(app)
def get_app(self, loop): app = main.get_application(loop) return app
def app() -> FastAPI: from main import get_application the_app = get_application() return the_app
def client(loop, aiohttp_client): app = loop.run_until_complete(get_application()) return loop.run_until_complete(aiohttp_client(app))
from fastapi.testclient import TestClient from main import get_application api = get_application() test_client = TestClient(api) def test_status_route_root(): response = test_client.get("/status") assert response.status_code == 200