2020-10-07 09:52:23 +02:00
|
|
|
from starlette.routing import Route
|
2021-11-30 18:31:40 +01:00
|
|
|
from halfapi.lib.routes import gen_starlette_routes, gen_router_routes
|
2020-10-07 09:52:23 +02:00
|
|
|
|
|
|
|
def test_gen_starlette_routes():
|
2021-05-28 22:30:48 +02:00
|
|
|
from .dummy_domain import routers
|
2020-10-07 15:51:24 +02:00
|
|
|
for route in gen_starlette_routes({
|
2021-05-28 22:30:48 +02:00
|
|
|
'dummy_domain': routers }):
|
2020-10-07 09:52:23 +02:00
|
|
|
|
|
|
|
assert isinstance(route, Route)
|
2021-11-29 05:43:51 +01:00
|
|
|
|
2021-11-30 18:31:40 +01:00
|
|
|
import pytest
|
|
|
|
|
|
|
|
@pytest.mark.skip
|
2021-11-29 05:43:51 +01:00
|
|
|
def test_api_routes():
|
|
|
|
from . import dummy_domain
|
|
|
|
d_res, d_acls = api_routes(dummy_domain)
|
|
|
|
assert isinstance(d_res, dict)
|
|
|
|
assert isinstance(d_acls, dict)
|
|
|
|
|
|
|
|
yielded = False
|
|
|
|
|
|
|
|
for path, verb, m_router, fct, params in gen_router_routes(dummy_domain, []):
|
|
|
|
if not yielded:
|
|
|
|
yielded = True
|
|
|
|
|
|
|
|
assert path in d_res
|
|
|
|
assert verb in d_res[path]
|
|
|
|
assert 'docs' in d_res[path][verb]
|
|
|
|
assert 'acls' in d_res[path][verb]
|
|
|
|
assert isinstance(d_res[path][verb]['docs'], dict)
|
|
|
|
assert isinstance(d_res[path][verb]['acls'], list)
|
|
|
|
assert len(d_res[path][verb]['acls']) == len(params)
|
|
|
|
|
|
|
|
assert yielded is True
|