feat(campaigns): add pending_approval state to campaign domain entity

This commit is contained in:
kitos
2026-07-02 16:00:18 +02:00
parent 62e3bfebe8
commit a113f3687c
2 changed files with 99 additions and 1 deletions
+52
View File
@@ -173,3 +173,55 @@ def test_from_orm_handles_none_tags():
orm.tags = None
e = CampaignEntity.from_orm(orm)
assert e.tags == []
# ── 9. Submit for approval ────────────────────────────────────────────
def test_submit_for_approval_from_draft_with_tests_success():
e = _entity("draft", test_count=1)
e.submit_for_approval()
assert e.status == CampaignStatus.pending_approval
def test_submit_for_approval_from_draft_with_zero_tests_raises():
e = _entity("draft", test_count=0)
with pytest.raises(BusinessRuleViolation, match="at least one test"):
e.submit_for_approval()
assert e.status == CampaignStatus.draft
def test_submit_for_approval_from_active_raises():
e = _entity("active", test_count=1)
with pytest.raises(InvalidStateTransition):
e.submit_for_approval()
# ── 10. Approve ────────────────────────────────────────────────────────
def test_approve_from_pending_approval_success():
e = _entity("pending_approval", test_count=1)
e.approve()
assert e.status == CampaignStatus.active
def test_approve_from_draft_raises():
e = _entity("draft", test_count=1)
with pytest.raises(InvalidStateTransition):
e.approve()
# ── 11. Reject ─────────────────────────────────────────────────────────
def test_reject_from_pending_approval_returns_to_draft():
e = _entity("pending_approval", test_count=1)
e.reject()
assert e.status == CampaignStatus.draft
def test_reject_from_draft_raises():
e = _entity("draft", test_count=1)
with pytest.raises(InvalidStateTransition):
e.reject()