added
This commit is contained in:
1 parent
57f4e2c561
commit
902d332eec
14 files changed
+213
-22
No files matched your search
+1
-1
@@ -1,3 +1,3 @@
|
||||
# Tests
|
||||
|
||||
Run `python -B -m unittest discover -s tests -v`. Tests cover complete-week boundaries, rejected incomplete evidence, provenance, idempotent finalization, standard catalog compatibility, metadata alignment and unchanged checkpoint behavior. Synthetic fixtures do not constitute weekly research.
|
||||
Run `python -B -m unittest discover -s tests -v`. Tests cover complete-week boundaries, rejected incomplete evidence, provenance, idempotent finalization, standard catalog compatibility, metadata alignment and unchanged checkpoint behavior. Gmail regressions cover merged public discovery provenance, missing/truncated/unchecked scans, checked-empty success, partial artifacts on access failure and unchanged checkpoint behavior. Historical pre-activation evidence stays valid. Synthetic fixtures do not constitute weekly research.
|
||||
@@ -84,6 +84,108 @@ class WorkflowTests(unittest.TestCase):
|
||||
with self.assertRaises(ValueError):
|
||||
w.validate_run(root, root / "evidence/run.json")
|
||||
|
||||
# Gmail contract tests use synthetic aggregate counts and public evidence only.
|
||||
class GmailCoverageTests(unittest.TestCase):
|
||||
fixture = WorkflowTests.fixture
|
||||
|
||||
def gmail_fixture(self, root, status="complete"):
|
||||
e = self.fixture(root)
|
||||
config = w.read(root / "config/research.json")
|
||||
config["gmail_candidate_source"] = {"enabled_from_run_date": "2026-10-19"}
|
||||
w.atomic_json(root / "config/research.json", config)
|
||||
e["coverage"]["gmail_brandemails"] = status
|
||||
e["gmail_collection"] = {"status": status, "pages_read": 2, "messages_enumerated": 3,
|
||||
"messages_screened": 3, "enumeration_complete": True, "screening_complete": True, "limitations": []}
|
||||
return e
|
||||
|
||||
def test_complete_gmail_and_merged_public_evidence(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
root = Path(tmp)
|
||||
e = self.gmail_fixture(root)
|
||||
e["sources"][0]["discovery_methods"].append("gmail")
|
||||
w.atomic_json(root / "evidence/run.json", e)
|
||||
w.finalize(root, "evidence/run.json")
|
||||
|
||||
def test_gmail_cannot_claim_complete_when_truncated_or_missing(self):
|
||||
for mutation in ("missing", "truncated", "screening", "unavailable", "unchecked_empty"):
|
||||
with self.subTest(mutation=mutation), tempfile.TemporaryDirectory() as tmp:
|
||||
root = Path(tmp)
|
||||
e = self.gmail_fixture(root)
|
||||
if mutation == "missing":
|
||||
del e["coverage"]["gmail_brandemails"]
|
||||
elif mutation == "truncated":
|
||||
e["gmail_collection"]["enumeration_complete"] = False
|
||||
elif mutation == "screening":
|
||||
e["gmail_collection"]["messages_screened"] = 1
|
||||
elif mutation == "unchecked_empty":
|
||||
e["gmail_collection"].update(pages_read=0, messages_enumerated=0, messages_screened=0)
|
||||
else:
|
||||
e["coverage"]["gmail_brandemails"] = "unavailable"
|
||||
e["gmail_collection"].update(status="unavailable", limitations=["Connector unavailable"])
|
||||
w.atomic_json(root / "evidence/run.json", e)
|
||||
with self.assertRaises(ValueError):
|
||||
w.finalize(root, "evidence/run.json")
|
||||
self.assertFalse((root / "state/last-successful-run.json").exists())
|
||||
|
||||
def test_unavailable_gmail_retains_valid_partial_artifacts(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
root = Path(tmp)
|
||||
e = self.gmail_fixture(root, "unavailable")
|
||||
e["status"] = "incomplete"
|
||||
e["gmail_collection"].update(pages_read=0, messages_enumerated=0, messages_screened=0,
|
||||
enumeration_complete=False, screening_complete=False, limitations=["Connector unavailable"])
|
||||
receipt = w.read(root / "receipts/run.json")
|
||||
receipt.update(status="incomplete", capture_completeness="partial", gaps=["Gmail unavailable"])
|
||||
w.atomic_json(root / "receipts/run.json", receipt)
|
||||
w.atomic_json(root / "evidence/run.json", e)
|
||||
w.validate_run(root, root / "evidence/run.json")
|
||||
|
||||
def test_checked_empty_scan_is_valid(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
root = Path(tmp)
|
||||
e = self.gmail_fixture(root)
|
||||
e["gmail_collection"].update(pages_read=1, messages_enumerated=0, messages_screened=0)
|
||||
w.atomic_json(root / "evidence/run.json", e)
|
||||
w.finalize(root, "evidence/run.json")
|
||||
|
||||
|
||||
class SiaTranscriptTests(unittest.TestCase):
|
||||
fixture = WorkflowTests.fixture
|
||||
|
||||
def sia_fixture(self, root):
|
||||
e = self.fixture(root)
|
||||
e["sources"][0].update(kind="podcast", podcast_series="sia_inside_line", format="publisher_transcript",
|
||||
episode_title="Synthetic SIA episode", speaker="Verified speaker", timestamps="00:01-01:00",
|
||||
transcript_url="https://example.com/transcript", transcript_provider="Publisher",
|
||||
transcript_completeness="full", transcript_limitations=[])
|
||||
return e
|
||||
|
||||
def test_provided_transcript_formats(self):
|
||||
for fmt in ("publisher_transcript", "provided_speech_to_text"):
|
||||
with self.subTest(fmt=fmt), tempfile.TemporaryDirectory() as tmp:
|
||||
root = Path(tmp)
|
||||
e = self.sia_fixture(root)
|
||||
e["sources"][0]["format"] = fmt
|
||||
w.atomic_json(root / "evidence/run.json", e)
|
||||
w.finalize(root, "evidence/run.json")
|
||||
|
||||
def test_rejects_audio_notes_and_missing_provenance(self):
|
||||
for mutation in ("audio_transcribed", "show_notes", "outline", "missing_url", "partial_without_limits"):
|
||||
with self.subTest(mutation=mutation), tempfile.TemporaryDirectory() as tmp:
|
||||
root = Path(tmp)
|
||||
e = self.sia_fixture(root)
|
||||
source = e["sources"][0]
|
||||
if mutation == "missing_url":
|
||||
del source["transcript_url"]
|
||||
elif mutation == "partial_without_limits":
|
||||
source["transcript_completeness"] = "partial"
|
||||
else:
|
||||
source["format"] = mutation
|
||||
w.atomic_json(root / "evidence/run.json", e)
|
||||
with self.assertRaises(ValueError):
|
||||
w.finalize(root, "evidence/run.json")
|
||||
self.assertFalse((root / "state/last-successful-run.json").exists())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user