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-09-25 01:06:21 +02:00
|
|
|
for route in gen_router_routes(routers):
|
2020-09-22 12:57:36 +02:00
|
|
|
print(f'[{route["verb"]}] {route["path"]} {route["fct"]}')
|
|
|
|
assert route['verb'] in VERBS
|
|
|
|
assert isinstance(route['path'], str)
|
|
|
|
assert len(route['params']) > 0
|
|
|
|
assert hasattr(route['fct'], '__call__')
|
|
|
|
|
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)
|
|
|
|
|