halfapi/tests/test_lib_domain.py

37 lines
989 B
Python
Raw Permalink Normal View History

#!/usr/bin/env python3
import importlib
2021-06-17 18:52:18 +02:00
from halfapi.lib.domain import VERBS, gen_routes, gen_router_routes, MissingAclError
from types import FunctionType
def test_gen_router_routes():
from .dummy_domain import routers
2021-06-17 18:52:18 +02:00
for path, verb, fct, params in gen_router_routes(routers, ['dummy_domain']):
assert isinstance(path, str)
2021-06-17 18:52:18 +02:00
assert verb in VERBS
assert len(params) > 0
assert hasattr(fct, '__call__')
def test_gen_routes():
from .dummy_domain.routers.abc.alphabet import TEST_uuid
try:
gen_routes(
TEST_uuid,
'get',
['abc', 'alphabet', 'TEST_uuid', ''],
[])
except MissingAclError:
assert True
fct, params = gen_routes(
TEST_uuid,
'get',
['abc', 'alphabet', 'TEST_uuid', ''],
TEST_uuid.ACLS['GET'])
assert isinstance(fct, FunctionType)
assert isinstance(params, list)
assert len(TEST_uuid.ACLS['GET']) == len(params)