Refactor mock campaign send reporting
This commit is contained in:
66
tests/test_mock_campaign_helpers.py
Normal file
66
tests/test_mock_campaign_helpers.py
Normal file
@@ -0,0 +1,66 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import unittest
|
||||
from types import SimpleNamespace
|
||||
|
||||
from govoplan_campaign.backend.dev.mock_campaign import (
|
||||
_MockSendBatch,
|
||||
_mock_send_steps,
|
||||
)
|
||||
|
||||
|
||||
class MockCampaignStepTests(unittest.TestCase):
|
||||
def test_preview_marks_delivery_steps_as_skipped(self):
|
||||
validation = SimpleNamespace(ok=True)
|
||||
build = SimpleNamespace(
|
||||
built_count=2,
|
||||
queueable_count=2,
|
||||
needs_review_count=0,
|
||||
blocked_count=0,
|
||||
)
|
||||
|
||||
steps = _mock_send_steps(
|
||||
validation_report=validation,
|
||||
validation_payload={"ok": True},
|
||||
build_report=build,
|
||||
send_batch=_MockSendBatch(results=[]),
|
||||
send=False,
|
||||
append_sent=True,
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
[step["status"] for step in steps],
|
||||
["ok", "ok", "skipped", "skipped"],
|
||||
)
|
||||
|
||||
def test_delivery_failures_require_review(self):
|
||||
validation = SimpleNamespace(ok=False)
|
||||
build = SimpleNamespace(
|
||||
built_count=1,
|
||||
queueable_count=0,
|
||||
needs_review_count=1,
|
||||
blocked_count=0,
|
||||
)
|
||||
batch = _MockSendBatch(
|
||||
results=[],
|
||||
failed_count=1,
|
||||
imap_failed_count=1,
|
||||
)
|
||||
|
||||
steps = _mock_send_steps(
|
||||
validation_report=validation,
|
||||
validation_payload={"ok": False},
|
||||
build_report=build,
|
||||
send_batch=batch,
|
||||
send=True,
|
||||
append_sent=True,
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
[step["status"] for step in steps],
|
||||
["needs_review", "needs_review", "needs_review", "needs_review"],
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user