[lib.domain] gen_router_routes yields router module also
This commit is contained in:
parent
908eab5fdc
commit
049860fce5
@ -194,6 +194,7 @@ def gen_router_routes(m_router: ModuleType, path: List[str]) -> \
|
|||||||
continue
|
continue
|
||||||
yield ('/'.join(filter(lambda x: len(x) > 0, path)),
|
yield ('/'.join(filter(lambda x: len(x) > 0, path)),
|
||||||
verb,
|
verb,
|
||||||
|
m_router,
|
||||||
*gen_routes(m_router, verb, path, params[verb])
|
*gen_routes(m_router, verb, path, params[verb])
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ def gen_domain_routes(m_domain: ModuleType):
|
|||||||
Returns:
|
Returns:
|
||||||
Generator(Route)
|
Generator(Route)
|
||||||
"""
|
"""
|
||||||
for path, verb, fct, params in gen_router_routes(m_domain, []):
|
for path, verb, m_router, fct, params in gen_router_routes(m_domain, []):
|
||||||
yield (
|
yield (
|
||||||
Route(f'/{path}',
|
Route(f'/{path}',
|
||||||
route_acl_decorator(
|
route_acl_decorator(
|
||||||
@ -176,7 +176,7 @@ def api_routes(m_dom: ModuleType) -> Tuple[Dict, Dict]:
|
|||||||
return l_params
|
return l_params
|
||||||
|
|
||||||
d_res = {}
|
d_res = {}
|
||||||
for path, verb, _, params in gen_router_routes(m_dom, []):
|
for path, verb, _, _, params in gen_router_routes(m_dom, []):
|
||||||
if path not in d_res:
|
if path not in d_res:
|
||||||
d_res[path] = {}
|
d_res[path] = {}
|
||||||
d_res[path][verb] = str_acl(params)
|
d_res[path][verb] = str_acl(params)
|
||||||
|
@ -17,7 +17,7 @@ def test_get_config_route(dummy_project, application_domain, routers):
|
|||||||
def test_get_route(dummy_project, application_domain, routers):
|
def test_get_route(dummy_project, application_domain, routers):
|
||||||
c = TestClient(application_domain)
|
c = TestClient(application_domain)
|
||||||
path = verb = params = None
|
path = verb = params = None
|
||||||
for path, verb, _, params in gen_router_routes(routers, []):
|
for path, verb, _, _, params in gen_router_routes(routers, []):
|
||||||
if len(params):
|
if len(params):
|
||||||
route_path = '/dummy_domain/{}'.format(path)
|
route_path = '/dummy_domain/{}'.format(path)
|
||||||
try:
|
try:
|
||||||
|
@ -7,11 +7,13 @@ from types import FunctionType
|
|||||||
|
|
||||||
def test_gen_router_routes():
|
def test_gen_router_routes():
|
||||||
from .dummy_domain import routers
|
from .dummy_domain import routers
|
||||||
for path, verb, fct, params in gen_router_routes(routers, ['dummy_domain']):
|
for path, verb, m_router, fct, params in gen_router_routes(routers, ['dummy_domain']):
|
||||||
assert isinstance(path, str)
|
assert isinstance(path, str)
|
||||||
assert verb in VERBS
|
assert verb in VERBS
|
||||||
assert len(params) > 0
|
assert len(params) > 0
|
||||||
assert hasattr(fct, '__call__')
|
assert hasattr(fct, '__call__')
|
||||||
|
assert len(m_router.__file__) > 0
|
||||||
|
|
||||||
|
|
||||||
def test_gen_routes():
|
def test_gen_routes():
|
||||||
from .dummy_domain.routers.abc.alphabet import TEST_uuid
|
from .dummy_domain.routers.abc.alphabet import TEST_uuid
|
||||||
|
Loading…
Reference in New Issue
Block a user