[tests] add dummy_domain as a testing dependency (because domains can't
be "not installed" in sys.path)
This commit is contained in:
parent
1e1ff2fb69
commit
3959e6d614
1
Pipfile
1
Pipfile
|
@ -8,6 +8,7 @@ pytest = "*"
|
||||||
requests = "*"
|
requests = "*"
|
||||||
pytest-asyncio = "*"
|
pytest-asyncio = "*"
|
||||||
pylint = "*"
|
pylint = "*"
|
||||||
|
dummy-domain = {path = "./tests"}
|
||||||
|
|
||||||
[packages]
|
[packages]
|
||||||
click = "*"
|
click = "*"
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
from starlette.responses import PlainTextResponse
|
from starlette.responses import PlainTextResponse
|
||||||
|
from dummy_domain import acl
|
||||||
|
|
||||||
ROUTES={
|
ROUTES={
|
||||||
'': {
|
'': {
|
||||||
'GET': [{'acl':None, 'in':None}]
|
'GET': [{'acl':acl.public}]
|
||||||
},
|
},
|
||||||
'{test:uuid}': {
|
'{test:uuid}': {
|
||||||
'GET': [{'acl':None, 'in':None}],
|
'GET': [{'acl':None}],
|
||||||
'POST': [{'acl':None, 'in':None}],
|
'POST': [{'acl':None}],
|
||||||
'PATCH': [{'acl':None, 'in':None}],
|
'PATCH': [{'acl':None}],
|
||||||
'PUT': [{'acl':None, 'in':None}]
|
'PUT': [{'acl':None}]
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import os
|
||||||
|
|
||||||
|
def get_packages(package):
|
||||||
|
"""
|
||||||
|
Return root package and all sub-packages.
|
||||||
|
"""
|
||||||
|
return [
|
||||||
|
dirpath
|
||||||
|
for dirpath, dirnames, filenames in os.walk(package)
|
||||||
|
if os.path.exists(os.path.join(dirpath, "__init__.py"))
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
from setuptools import setup, find_packages
|
||||||
|
module_name="dummy_domain"
|
||||||
|
setup(
|
||||||
|
name=module_name,
|
||||||
|
version='0',
|
||||||
|
url="https://gite.lirmm.fr/malves/halfapi",
|
||||||
|
packages=get_packages(module_name),
|
||||||
|
python_requires=">=3.7",
|
||||||
|
install_requires=[]
|
||||||
|
)
|
|
@ -20,6 +20,7 @@ def test_gen_router_routes():
|
||||||
|
|
||||||
def test_gen_domain_routes():
|
def test_gen_domain_routes():
|
||||||
from . import dummy_domain
|
from . import dummy_domain
|
||||||
for route in gen_domain_routes(
|
for path, route in gen_domain_routes(
|
||||||
'dummy_domain', dummy_domain):
|
'dummy_domain', dummy_domain):
|
||||||
|
assert isinstance(path, str)
|
||||||
assert isinstance(route, dict)
|
assert isinstance(route, dict)
|
||||||
|
|
|
@ -3,8 +3,7 @@ from halfapi.lib.routes import gen_starlette_routes
|
||||||
|
|
||||||
def test_gen_starlette_routes():
|
def test_gen_starlette_routes():
|
||||||
from . import dummy_domain
|
from . import dummy_domain
|
||||||
for path, route in gen_starlette_routes({
|
for route in gen_starlette_routes({
|
||||||
'dummy_domain': dummy_domain }):
|
'dummy_domain': dummy_domain }):
|
||||||
|
|
||||||
assert isinstance(path, str)
|
|
||||||
assert isinstance(route, Route)
|
assert isinstance(route, Route)
|
||||||
|
|
|
@ -19,12 +19,4 @@ def test_get_api_routes(project_runner):
|
||||||
c = TestClient(application)
|
c = TestClient(application)
|
||||||
r = c.get('/')
|
r = c.get('/')
|
||||||
d_r = r.json()
|
d_r = r.json()
|
||||||
try:
|
assert isinstance(d_r, dict)
|
||||||
assert isinstance(d_r, dict)
|
|
||||||
assert 'paths' in d_r
|
|
||||||
assert '/' in d_r['paths']
|
|
||||||
assert '/dummy_domain/abc/alphabet' in d_r['paths']
|
|
||||||
except AssertionError as exc:
|
|
||||||
pprint(d_r)
|
|
||||||
raise exc
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue