import importlib.metadata import importlib.resources import tornado.template import tornado_openapi3.testing import yaml import tutor.server template_path = importlib.resources.path("tutor", "templates") template_loader = tornado.template.Loader(template_path) openapi_spec_dict = yaml.safe_load( template_loader.load("openapi.yaml").generate( version=importlib.metadata.version("tutor") ) ) openapi_spec = None class ServerTestCase(tornado_openapi3.testing.AsyncOpenAPITestCase): @property def spec_dict(self): global openapi_spec_dict return openapi_spec_dict def get_app(self): return tutor.server.Application() class DocumentationTestCase(ServerTestCase): def test_api_root(self): self.fetch("/api/") def test_openapi_yaml(self): self.fetch("/api/openapi.yaml")