From a98aa2748507a544c680fd1fbd350b2a20f6d384 Mon Sep 17 00:00:00 2001 From: "Maxime Alves LIRMM@home" Date: Wed, 1 Dec 2021 12:02:21 +0100 Subject: [PATCH] [pipfile] remove dependency to python3.8, TODO find a way to specify python>=3.8 --- Pipfile | 3 --- tests/conftest.py | 26 +++++++++++++------------- tests/test_app.py | 7 ++----- tests/test_dummy_project_router.py | 8 ++++---- 4 files changed, 19 insertions(+), 25 deletions(-) diff --git a/Pipfile b/Pipfile index e5f2cdb..6e71b15 100644 --- a/Pipfile +++ b/Pipfile @@ -21,8 +21,5 @@ pyyaml = ">=5.3.1,<6" timing-asgi = ">=0.2.1,<1" schema = ">=0.7.4,<1" -[requires] -python_version = "3.8" - [scripts] halfapi = "python -m halfapi" diff --git a/tests/conftest.py b/tests/conftest.py index a791d70..4d517b0 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -35,6 +35,13 @@ from halfapi.lib.jwt_middleware import ( JWTUser, JWTAuthenticationBackend, JWTWebSocketAuthenticationBackend) +@pytest.fixture +def dummy_domain(): + yield { + 'name': 'dummy_domain', + 'router': 'dummy_domain.routers' + } + @pytest.fixture def token_builder(): yield jwt.encode({ @@ -290,31 +297,24 @@ def application_debug(routers): 'secret':'turlututu', 'production':False, 'domain': { - 'name': 'dummy_domain', - 'router': 'routers' + 'name': 'test_domain', + 'router': 'test_domain.routers' }, 'config':{ - 'domain_config': {'dummy_domain': {'test': True}} + 'domain_config': {'test_domain': {'test': True}} } }) assert isinstance(halfAPI, HalfAPI) - return halfAPI.application - -def test_application_debug(application_debug): - assert application_debug is not None - + yield halfAPI.application @pytest.fixture -def application_domain(routers): +def application_domain(dummy_domain): return HalfAPI({ 'secret':'turlututu', 'production':True, - 'domain': { - 'name': 'dummy_domain', - 'router': 'routers' - }, + 'domain': dummy_domain, 'config':{ 'domain_config': {'dummy_domain': {'test': True}} } diff --git a/tests/test_app.py b/tests/test_app.py index ab9630f..d2eabeb 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -5,12 +5,9 @@ from halfapi.halfapi import HalfAPI from halfapi.lib.domain import NoDomainsException -def test_halfapi_dummy_domain(): +def test_halfapi_dummy_domain(dummy_domain): with patch('starlette.applications.Starlette') as mock: mock.return_value = MagicMock() halfapi = HalfAPI({ - 'domain': { - 'name': 'dummy_domain', - 'router': 'routers' - } + 'domain': dummy_domain }) diff --git a/tests/test_dummy_project_router.py b/tests/test_dummy_project_router.py index ffd90c6..8b06268 100644 --- a/tests/test_dummy_project_router.py +++ b/tests/test_dummy_project_router.py @@ -10,14 +10,14 @@ from starlette.testclient import TestClient from halfapi.lib.domain import gen_router_routes -def test_get_config_route(dummy_project, application_domain, routers): +def test_get_config_route(dummy_project, application_domain): c = TestClient(application_domain) r = c.get('/config') assert r.status_code == 200 pprint(r.json()) assert 'test' in r.json() -def test_get_route(dummy_project, application_domain, routers): +def test_get_route(dummy_project, application_domain): c = TestClient(application_domain) path = verb = params = None dummy_domain_routes = [ @@ -73,7 +73,7 @@ def test_get_route(dummy_project, application_domain, routers): assert r.status_code == 200 -def test_delete_route(dummy_project, application_domain, routers): +def test_delete_route(dummy_project, application_domain): c = TestClient(application_domain) from uuid import uuid4 arg = str(uuid4()) @@ -81,7 +81,7 @@ def test_delete_route(dummy_project, application_domain, routers): assert r.status_code == 200 assert isinstance(r.json(), str) -def test_arguments_route(dummy_project, application_domain, routers): +def test_arguments_route(dummy_project, application_domain): c = TestClient(application_domain) path = '/arguments'