Initialize GovOPlaN REST connector
This commit is contained in:
41
tests/test_rest_module_contract.py
Normal file
41
tests/test_rest_module_contract.py
Normal file
@@ -0,0 +1,41 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import unittest
|
||||
|
||||
from govoplan_core.core.modules import ModuleContext
|
||||
|
||||
from govoplan_rest.backend.contracts import RestFunctionDescriptor
|
||||
from govoplan_rest.backend.manifest import get_manifest
|
||||
|
||||
|
||||
class RestModuleContractTests(unittest.TestCase):
|
||||
def test_manifest_declares_rest_module(self) -> None:
|
||||
manifest = get_manifest()
|
||||
|
||||
self.assertEqual("rest", manifest.id)
|
||||
self.assertTrue(manifest.route_factory)
|
||||
self.assertEqual(("auth.principalResolver", "auth.permissionEvaluator"), manifest.required_capabilities)
|
||||
|
||||
def test_route_factory_exports_status_router(self) -> None:
|
||||
manifest = get_manifest()
|
||||
|
||||
router = manifest.route_factory(ModuleContext(registry=object(), settings=object()))
|
||||
|
||||
self.assertEqual("/rest", router.prefix)
|
||||
self.assertEqual(1, len(router.routes))
|
||||
|
||||
def test_function_descriptor_is_stable(self) -> None:
|
||||
descriptor = RestFunctionDescriptor(
|
||||
id="demo.ping",
|
||||
module_id="demo",
|
||||
name="Ping",
|
||||
summary="Demo function",
|
||||
)
|
||||
|
||||
self.assertEqual("POST", descriptor.method)
|
||||
self.assertEqual("authenticated", descriptor.visibility)
|
||||
self.assertEqual((), descriptor.required_scopes)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user