[tests] add dummy_domain as a testing dependency (because domains can't

be "not installed" in sys.path)
This commit is contained in:
Maxime Alves LIRMM 2020-10-07 15:51:24 +02:00
parent 1e1ff2fb69
commit 3959e6d614
6 changed files with 36 additions and 17 deletions

View File

@ -8,6 +8,7 @@ pytest = "*"
requests = "*"
pytest-asyncio = "*"
pylint = "*"
dummy-domain = {path = "./tests"}
[packages]
click = "*"

View File

@ -1,14 +1,15 @@
from starlette.responses import PlainTextResponse
from dummy_domain import acl
ROUTES={
'': {
'GET': [{'acl':None, 'in':None}]
'GET': [{'acl':acl.public}]
},
'{test:uuid}': {
'GET': [{'acl':None, 'in':None}],
'POST': [{'acl':None, 'in':None}],
'PATCH': [{'acl':None, 'in':None}],
'PUT': [{'acl':None, 'in':None}]
'GET': [{'acl':None}],
'POST': [{'acl':None}],
'PATCH': [{'acl':None}],
'PUT': [{'acl':None}]
}
}

25
tests/setup.py Normal file
View File

@ -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=[]
)

View File

@ -20,6 +20,7 @@ def test_gen_router_routes():
def test_gen_domain_routes():
from . import dummy_domain
for route in gen_domain_routes(
for path, route in gen_domain_routes(
'dummy_domain', dummy_domain):
assert isinstance(path, str)
assert isinstance(route, dict)

View File

@ -3,8 +3,7 @@ from halfapi.lib.routes import gen_starlette_routes
def test_gen_starlette_routes():
from . import dummy_domain
for path, route in gen_starlette_routes({
for route in gen_starlette_routes({
'dummy_domain': dummy_domain }):
assert isinstance(path, str)
assert isinstance(route, Route)

View File

@ -19,12 +19,4 @@ def test_get_api_routes(project_runner):
c = TestClient(application)
r = c.get('/')
d_r = r.json()
try:
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