2020-09-22 12:57:36 +02:00
|
|
|
#!/usr/bin/env python3
|
2020-09-25 01:06:21 +02:00
|
|
|
from starlette.routing import Route
|
|
|
|
from halfapi.lib.domain import VERBS, gen_router_routes
|
2020-09-22 12:57:36 +02:00
|
|
|
|
2020-09-25 01:06:21 +02:00
|
|
|
from halfapi.lib.routes import gen_starlette_routes
|
|
|
|
|
|
|
|
def test_gen_router_routes():
|
2020-09-22 12:57:36 +02:00
|
|
|
from .dummy_domain import routers
|
2020-10-04 17:26:36 +02:00
|
|
|
for path, d_route in gen_router_routes(routers):
|
|
|
|
assert isinstance(path, str)
|
|
|
|
for verb in VERBS:
|
|
|
|
if verb not in d_route.keys():
|
|
|
|
continue
|
|
|
|
route = d_route[verb]
|
|
|
|
print(f'[{verb}] {path} {route["fct"]}')
|
|
|
|
assert len(route['params']) > 0
|
|
|
|
assert hasattr(route['fct'], '__call__')
|
|
|
|
if hasattr('fqtn', route):
|
|
|
|
assert isinstance(route['fqtn'], str)
|
2020-09-22 12:57:36 +02:00
|
|
|
|
2020-09-25 01:06:21 +02:00
|
|
|
|
|
|
|
def test_gen_starlette_routes():
|
|
|
|
from . import dummy_domain
|
|
|
|
for route in gen_starlette_routes(dummy_domain):
|
|
|
|
assert isinstance(route, Route)
|
|
|
|
|