[pipfile] remove dependency to python3.8, TODO find a way to specify python>=3.8

This commit is contained in:
Maxime Alves LIRMM@home 2021-12-01 12:02:21 +01:00
parent 15794327f9
commit a98aa27485
4 changed files with 19 additions and 25 deletions

View File

@ -21,8 +21,5 @@ pyyaml = ">=5.3.1,<6"
timing-asgi = ">=0.2.1,<1" timing-asgi = ">=0.2.1,<1"
schema = ">=0.7.4,<1" schema = ">=0.7.4,<1"
[requires]
python_version = "3.8"
[scripts] [scripts]
halfapi = "python -m halfapi" halfapi = "python -m halfapi"

View File

@ -35,6 +35,13 @@ from halfapi.lib.jwt_middleware import (
JWTUser, JWTAuthenticationBackend, JWTUser, JWTAuthenticationBackend,
JWTWebSocketAuthenticationBackend) JWTWebSocketAuthenticationBackend)
@pytest.fixture
def dummy_domain():
yield {
'name': 'dummy_domain',
'router': 'dummy_domain.routers'
}
@pytest.fixture @pytest.fixture
def token_builder(): def token_builder():
yield jwt.encode({ yield jwt.encode({
@ -290,31 +297,24 @@ def application_debug(routers):
'secret':'turlututu', 'secret':'turlututu',
'production':False, 'production':False,
'domain': { 'domain': {
'name': 'dummy_domain', 'name': 'test_domain',
'router': 'routers' 'router': 'test_domain.routers'
}, },
'config':{ 'config':{
'domain_config': {'dummy_domain': {'test': True}} 'domain_config': {'test_domain': {'test': True}}
} }
}) })
assert isinstance(halfAPI, HalfAPI) assert isinstance(halfAPI, HalfAPI)
return halfAPI.application yield halfAPI.application
def test_application_debug(application_debug):
assert application_debug is not None
@pytest.fixture @pytest.fixture
def application_domain(routers): def application_domain(dummy_domain):
return HalfAPI({ return HalfAPI({
'secret':'turlututu', 'secret':'turlututu',
'production':True, 'production':True,
'domain': { 'domain': dummy_domain,
'name': 'dummy_domain',
'router': 'routers'
},
'config':{ 'config':{
'domain_config': {'dummy_domain': {'test': True}} 'domain_config': {'dummy_domain': {'test': True}}
} }

View File

@ -5,12 +5,9 @@ from halfapi.halfapi import HalfAPI
from halfapi.lib.domain import NoDomainsException 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: with patch('starlette.applications.Starlette') as mock:
mock.return_value = MagicMock() mock.return_value = MagicMock()
halfapi = HalfAPI({ halfapi = HalfAPI({
'domain': { 'domain': dummy_domain
'name': 'dummy_domain',
'router': 'routers'
}
}) })

View File

@ -10,14 +10,14 @@ from starlette.testclient import TestClient
from halfapi.lib.domain import gen_router_routes 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) c = TestClient(application_domain)
r = c.get('/config') r = c.get('/config')
assert r.status_code == 200 assert r.status_code == 200
pprint(r.json()) pprint(r.json())
assert 'test' in 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) c = TestClient(application_domain)
path = verb = params = None path = verb = params = None
dummy_domain_routes = [ dummy_domain_routes = [
@ -73,7 +73,7 @@ def test_get_route(dummy_project, application_domain, routers):
assert r.status_code == 200 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) c = TestClient(application_domain)
from uuid import uuid4 from uuid import uuid4
arg = str(uuid4()) arg = str(uuid4())
@ -81,7 +81,7 @@ def test_delete_route(dummy_project, application_domain, routers):
assert r.status_code == 200 assert r.status_code == 200
assert isinstance(r.json(), str) 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) c = TestClient(application_domain)
path = '/arguments' path = '/arguments'