From ec26438340c8d3aa757a80beb82bd06e13724167 Mon Sep 17 00:00:00 2001 From: Maxime Alves LIRMM Date: Tue, 30 Nov 2021 14:40:07 +0100 Subject: [PATCH] [schemas] supression des fonctions api_routes --- halfapi/halfapi.py | 4 +-- halfapi/lib/schemas.py | 62 -------------------------------------- tests/test_debug_routes.py | 2 +- tests/test_lib_schemas.py | 2 +- 4 files changed, 4 insertions(+), 66 deletions(-) diff --git a/halfapi/halfapi.py b/halfapi/halfapi.py index 8f5ec0d..a0cdee4 100644 --- a/halfapi/halfapi.py +++ b/halfapi/halfapi.py @@ -40,7 +40,7 @@ from halfapi.lib.responses import (ORJSONResponse, UnauthorizedResponse, ServiceUnavailableResponse) from halfapi.lib.routes import gen_domain_routes, gen_schema_routes, JSONRoute -from halfapi.lib.schemas import get_api_routes, get_api_domain_routes, schema_json, get_acls +from halfapi.lib.schemas import schema_json, get_acls from halfapi.logging import logger, config_logging from halfapi import __version__ @@ -81,7 +81,7 @@ class HalfAPI: DOMAINS[domain] = importlib.import_module(f'{domain}.{router}') if DOMAINS: - self.api_routes = get_api_routes(DOMAINS) + self.api_routes = {} routes = [ Route('/', JSONRoute(self.api_routes)) ] diff --git a/halfapi/lib/schemas.py b/halfapi/lib/schemas.py index a3df7ed..6481776 100644 --- a/halfapi/lib/schemas.py +++ b/halfapi/lib/schemas.py @@ -1,7 +1,6 @@ """ Schemas module Functions : - - get_api_routes - schema_json - schema_dict_dom - get_acls @@ -27,67 +26,6 @@ SCHEMAS = SchemaGenerator( {"openapi": "3.0.0", "info": {"title": "HalfAPI", "version": __version__}} ) -def get_api_routes(domains: Dict[str, ModuleType]) -> Dict: - """ - description: Returns the current API routes dictionary - as a JSON object - example: { - "dummy_domain": { - "abc/alphabet": { - "GET": { - "docs": "", - "acls": [ - { - "acl": "public" - } - ] - } - }, - "abc/alphabet/{test:uuid}": { - "GET": [ - { - "acl": "public" - } - ], - "POST": [ - { - "acl": "public" - } - ], - "PATCH": [ - { - "acl": "public" - } - ], - "PUT": [ - { - "acl": "public" - } - ] - } - } - } - """ - return { - domain: api_routes(m_domain)[0] - for domain, m_domain in domains.items() - } - - -def get_api_domain_routes(m_domain: ModuleType) -> Coroutine: - routes, _ = api_routes(m_domain) - - async def wrapped(request, *args, **kwargs): - """ - description: Returns the current API routes dictionary for a specific - domain as a JSON object - """ - return ORJSONResponse(routes) - - return wrapped - - - async def schema_json(request, *args, **kwargs): """ description: Returns the current API routes description (OpenAPI v3) diff --git a/tests/test_debug_routes.py b/tests/test_debug_routes.py index 4f17594..47cc4df 100644 --- a/tests/test_debug_routes.py +++ b/tests/test_debug_routes.py @@ -25,7 +25,7 @@ def test_error(application_debug): r = c.get('/halfapi/error/500') assert r.status_code == 500 -@pytest.skip +@pytest.mark.skip def test_exception(application_debug): c = TestClient(application_debug) try: diff --git a/tests/test_lib_schemas.py b/tests/test_lib_schemas.py index a6b59e6..a0e32f0 100644 --- a/tests/test_lib_schemas.py +++ b/tests/test_lib_schemas.py @@ -16,7 +16,7 @@ def test_schemas_dict_dom(): 'dummy_domain':routers}) assert isinstance(schema, dict) -def test_get_api_routes(project_runner, application_debug): +def test_get_api_schema(project_runner, application_debug): c = TestClient(application_debug) r = c.get('/') assert isinstance(c, TestClient)