From a31634122601eb9e602f03eea91b8594abb7bccb Mon Sep 17 00:00:00 2001 From: Albrecht Degering Date: Wed, 22 Jul 2026 03:21:10 +0200 Subject: [PATCH] refactor(scheduling): consume core participation contract --- src/govoplan_scheduling/backend/manifest.py | 6 ++-- src/govoplan_scheduling/backend/service.py | 24 +++++++------- tests/test_module_boundary.py | 35 +++++++++++++++++++++ 3 files changed, 50 insertions(+), 15 deletions(-) create mode 100644 tests/test_module_boundary.py diff --git a/src/govoplan_scheduling/backend/manifest.py b/src/govoplan_scheduling/backend/manifest.py index 92e1de6..e0bcaa0 100644 --- a/src/govoplan_scheduling/backend/manifest.py +++ b/src/govoplan_scheduling/backend/manifest.py @@ -18,14 +18,14 @@ from govoplan_core.core.modules import ( PublicFrontendRoute, RoleTemplate, ) -from govoplan_core.db.base import Base -from govoplan_core.core.poll import CAPABILITY_POLL_SCHEDULING from govoplan_core.core.people import ( CAPABILITY_ACCESS_PEOPLE_SEARCH, CAPABILITY_ADDRESSES_PEOPLE_SEARCH, ) +from govoplan_core.core.poll import CAPABILITY_POLL_SCHEDULING +from govoplan_core.core.poll_participation import CAPABILITY_POLL_PARTICIPATION_GATEWAY from govoplan_core.core.policy import CAPABILITY_POLICY_SCHEDULING_PARTICIPANT_PRIVACY -from govoplan_poll.backend.participation import CAPABILITY_POLL_PARTICIPATION_GATEWAY +from govoplan_core.db.base import Base from govoplan_scheduling.backend.db import models as scheduling_models # noqa: F401 - populate Scheduling ORM metadata MODULE_ID = "scheduling" diff --git a/src/govoplan_scheduling/backend/service.py b/src/govoplan_scheduling/backend/service.py index 06a38d5..a6873ac 100644 --- a/src/govoplan_scheduling/backend/service.py +++ b/src/govoplan_scheduling/backend/service.py @@ -27,6 +27,18 @@ from govoplan_core.core.poll import ( PollUpdateCommand, poll_scheduling_provider, ) +from govoplan_core.core.poll_participation import ( + ANONYMOUS_PASSWORD_REQUIREMENT, + PollGovernedInvitationCommand, + PollGovernedResponseCommand, + PollGovernedResponseRef, + PollParticipationContextRef, + PollParticipationGatewayProvider, + PollParticipationPolicy, + PollResponseGatewayRef, + participation_token_fingerprint, + poll_participation_gateway_provider, +) from govoplan_core.core.policy import ( SchedulingParticipantPrivacyDecision, SchedulingParticipantPrivacyRequest, @@ -55,18 +67,6 @@ from govoplan_scheduling.backend.security import ( hash_participant_password, verify_participant_password, ) -from govoplan_poll.backend.participation import ( - ANONYMOUS_PASSWORD_REQUIREMENT, - PollGovernedInvitationCommand, - PollGovernedResponseCommand, - PollGovernedResponseRef, - PollParticipationContextRef, - PollParticipationGatewayProvider, - PollParticipationPolicy, - PollResponseGatewayRef, - participation_token_fingerprint, - poll_participation_gateway_provider, -) class SchedulingError(ValueError): diff --git a/tests/test_module_boundary.py b/tests/test_module_boundary.py new file mode 100644 index 0000000..464bfba --- /dev/null +++ b/tests/test_module_boundary.py @@ -0,0 +1,35 @@ +from __future__ import annotations + +import ast +import pathlib +import unittest + + +ROOT = pathlib.Path(__file__).resolve().parents[1] + + +class SchedulingModuleBoundaryTests(unittest.TestCase): + def test_runtime_source_does_not_import_poll_implementation_internals(self) -> None: + offenders: list[str] = [] + source_root = ROOT / "src" / "govoplan_scheduling" + for path in source_root.rglob("*.py"): + tree = ast.parse(path.read_text(encoding="utf-8")) + imported_modules = [ + node.module + for node in ast.walk(tree) + if isinstance(node, ast.ImportFrom) and node.module is not None + ] + imported_modules.extend( + alias.name + for node in ast.walk(tree) + if isinstance(node, ast.Import) + for alias in node.names + ) + if any(module.startswith("govoplan_poll") for module in imported_modules): + offenders.append(str(path.relative_to(ROOT))) + + self.assertEqual([], offenders) + + +if __name__ == "__main__": + unittest.main()