Squashed commit of the following: commitac935db6d6
Author: Maxime Alves LIRMM@home <maxime.alves@lirmm.fr> Date: Thu Jun 17 18:52:49 2021 +0200 [tests] remove dummy-domain from dependencies commit4d50363c9b
Author: Maxime Alves LIRMM@home <maxime.alves@lirmm.fr> Date: Thu Jun 17 18:52:18 2021 +0200 [tests] update tests for 0.5.3 commit6181592692
Author: Maxime Alves LIRMM@home <maxime.alves@lirmm.fr> Date: Thu Jun 17 18:17:51 2021 +0200 [lib.*] Refactor libs commited7485a8a1
Author: Maxime Alves LIRMM@home <maxime.alves@lirmm.fr> Date: Thu Jun 17 18:15:10 2021 +0200 [app] Use HalfAPI class to be able to use custom configuration à commitfa1ca6bf9d
Author: Maxime Alves LIRMM <maxime.alves@lirmm.fr> Date: Wed Jun 16 15:34:25 2021 +0200 [wip] tests dummy_domain commit86e8dd3465
Author: Maxime Alves LIRMM <maxime.alves@lirmm.fr> Date: Tue Jun 15 18:12:13 2021 +0200 [0.5.3] ajout de la config actuelle dans les arguments des routes commitaa7ec62c7a
Author: Maxime Alves LIRMM <maxime.alves@lirmm.fr> Date: Tue Jun 15 11:16:23 2021 +0200 [lib.jwtMw] verify signature even if halfapi is in DEBUG mode commite208728d7e
Author: Maxime Alves LIRMM <maxime.alves@lirmm.fr> Date: Tue Jun 15 10:49:46 2021 +0200 [lib.acl] args_check doesn't check required/optional arguments if "args" is not specified in request, if the target function is not async commitaa4c309778
Author: Maxime Alves LIRMM <maxime.alves@lirmm.fr> Date: Tue Jun 15 09:45:37 2021 +0200 [lib.domain] SUBROUTER can be a path parameter if including ":" commit138420461d
Author: Maxime Alves LIRMM@home <maxime.alves@lirmm.fr> Date: Tue Jun 15 07:24:32 2021 +0200 [gitignore] *.swp commit0c1e2849ba
Author: Maxime Alves LIRMM@home <maxime.alves@lirmm.fr> Date: Tue Jun 15 07:24:14 2021 +0200 [tests] test get route with dummy projects commit7227e2d7f1
Author: Maxime Alves LIRMM@home <maxime.alves@lirmm.fr> Date: Mon Jun 14 17:18:47 2021 +0200 [lib.domain] handle modules without ROUTES attribute commit78c75cd60e
Author: Maxime Alves LIRMM@home <maxime.alves@lirmm.fr> Date: Mon Jun 14 16:34:58 2021 +0200 [tests] add dummy_project_router tests for path-based routers (without ROUTES variable)
37 lines
989 B
Python
37 lines
989 B
Python
#!/usr/bin/env python3
|
|
import importlib
|
|
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
|
|
for path, verb, fct, params in gen_router_routes(routers, ['dummy_domain']):
|
|
assert isinstance(path, str)
|
|
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)
|
|
|