feat: add status and payment capability contracts
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
from datetime import UTC, datetime
|
||||
import unittest
|
||||
|
||||
from govoplan_core.core.application_status import (
|
||||
CAPABILITY_APPLICATION_STATUS_PROJECTION,
|
||||
application_status_projection_provider,
|
||||
)
|
||||
|
||||
|
||||
class _Provider:
|
||||
def tenant_id_for_tracking_id(self, session, *, tracking_id):
|
||||
return "tenant-1"
|
||||
|
||||
def public_access_challenge(self, session, *, tracking_id):
|
||||
return {"tracking_id": tracking_id, "mode": "permanent_link"}
|
||||
|
||||
def get_authenticated_projection(
|
||||
self, session, principal, *, tracking_id, observed_at
|
||||
):
|
||||
return {"tracking_id": tracking_id, "status": "submitted"}
|
||||
|
||||
def get_public_projection(self, session, *, tracking_id, token, observed_at):
|
||||
return {"tracking_id": tracking_id, "status": "submitted"}
|
||||
|
||||
def request_email_link(self, session, *, tracking_id, email, requested_at):
|
||||
return True
|
||||
|
||||
|
||||
class _Registry:
|
||||
def __init__(self, provider):
|
||||
self.provider = provider
|
||||
|
||||
def has_capability(self, name):
|
||||
return name == CAPABILITY_APPLICATION_STATUS_PROJECTION
|
||||
|
||||
def capability(self, name):
|
||||
return self.provider
|
||||
|
||||
|
||||
class ApplicationStatusContractTests(unittest.TestCase):
|
||||
def test_resolves_only_structurally_complete_provider(self):
|
||||
provider = _Provider()
|
||||
resolved = application_status_projection_provider(_Registry(provider))
|
||||
|
||||
self.assertIs(provider, resolved)
|
||||
self.assertEqual(
|
||||
"tenant-1",
|
||||
resolved.tenant_id_for_tracking_id(None, tracking_id="tracking-1"),
|
||||
)
|
||||
self.assertTrue(
|
||||
resolved.request_email_link(
|
||||
None,
|
||||
tracking_id="tracking-1",
|
||||
email="resident@example.test",
|
||||
requested_at=datetime(2026, 8, 19, tzinfo=UTC),
|
||||
)
|
||||
)
|
||||
|
||||
def test_rejects_incomplete_provider(self):
|
||||
self.assertIsNone(application_status_projection_provider(_Registry(object())))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user