feat: expose sanctions screening integration
This commit is contained in:
79
tests/test_sanctions_contract.py
Normal file
79
tests/test_sanctions_contract.py
Normal file
@@ -0,0 +1,79 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime, timezone
|
||||
import hashlib
|
||||
import unittest
|
||||
|
||||
from govoplan_core.core.sanctions import (
|
||||
CAPABILITY_CONNECTORS_SANCTIONS_SNAPSHOTS,
|
||||
SanctionsSnapshotPayload,
|
||||
SanctionsSnapshotProvider,
|
||||
SanctionsSnapshotReference,
|
||||
sanctions_snapshot_provider,
|
||||
)
|
||||
|
||||
|
||||
class _Provider:
|
||||
def list_snapshots(self, session, principal, *, limit=100):
|
||||
del session, principal, limit
|
||||
return ()
|
||||
|
||||
def get_snapshot(self, session, principal, *, snapshot_ref):
|
||||
del session, principal, snapshot_ref
|
||||
return None
|
||||
|
||||
def read_snapshot(self, session, principal, *, snapshot_ref):
|
||||
del session, principal, snapshot_ref
|
||||
raise LookupError
|
||||
|
||||
|
||||
class _Registry:
|
||||
def __init__(self, provider):
|
||||
self.provider = provider
|
||||
|
||||
def has_capability(self, name):
|
||||
return name == CAPABILITY_CONNECTORS_SANCTIONS_SNAPSHOTS
|
||||
|
||||
def capability(self, name):
|
||||
return self.provider if self.has_capability(name) else None
|
||||
|
||||
|
||||
class SanctionsContractTests(unittest.TestCase):
|
||||
def test_snapshot_evidence_is_versioned_and_bounded(self) -> None:
|
||||
content = b"<CONSOLIDATED_LIST/>"
|
||||
snapshot = SanctionsSnapshotReference(
|
||||
ref="sanctions-snapshot:snapshot-1",
|
||||
tenant_id="tenant-1",
|
||||
provider_id="un.security_council",
|
||||
publisher="United Nations Security Council",
|
||||
jurisdiction="UN",
|
||||
list_type="consolidated",
|
||||
source_id="unsc-consolidated",
|
||||
source_version="2026-07-22",
|
||||
publication_at=None,
|
||||
effective_at=None,
|
||||
acquired_at=datetime.now(timezone.utc),
|
||||
content_type="application/xml",
|
||||
byte_count=len(content),
|
||||
sha256=hashlib.sha256(content).hexdigest(),
|
||||
parser_version="unsc-xml-v1",
|
||||
raw_evidence_ref="connector-evidence:snapshot-1",
|
||||
connector_run_id="run-1",
|
||||
)
|
||||
|
||||
payload = SanctionsSnapshotPayload(
|
||||
snapshot=snapshot,
|
||||
content=content,
|
||||
)
|
||||
provider = _Provider()
|
||||
|
||||
self.assertEqual(content, payload.content)
|
||||
self.assertIsInstance(provider, SanctionsSnapshotProvider)
|
||||
self.assertIs(
|
||||
provider,
|
||||
sanctions_snapshot_provider(_Registry(provider)),
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user