feat(campaigns): add get_campaign_timeline service function

This commit is contained in:
kitos
2026-07-03 11:23:37 +02:00
parent fd47db7bea
commit 6749daa7cb
2 changed files with 58 additions and 0 deletions
+27
View File
@@ -377,3 +377,30 @@ class TestModificationRequests:
pending = list_modification_requests(db, status="pending")
assert len(pending) == 1
assert pending[0]["action"] == "remove_test"
from app.services.audit_service import log_action
from app.services.campaign_crud_service import get_campaign_timeline
class TestCampaignTimeline:
def test_timeline_returns_entries_in_chronological_order(self, db, draft_campaign_with_test, admin_user):
log_action(
db, user_id=admin_user.id, action="create_campaign",
entity_type="campaign", entity_id=str(draft_campaign_with_test.id), details={},
)
log_action(
db, user_id=admin_user.id, action="submit_campaign_for_approval",
entity_type="campaign", entity_id=str(draft_campaign_with_test.id), details={},
)
db.commit()
timeline = get_campaign_timeline(db, str(draft_campaign_with_test.id))
assert len(timeline) == 2
assert timeline[0]["action"] == "create_campaign"
assert timeline[1]["action"] == "submit_campaign_for_approval"
def test_timeline_missing_campaign_raises(self, db):
import uuid as uuid_mod
with pytest.raises(EntityNotFoundError):
get_campaign_timeline(db, str(uuid_mod.uuid4()))