Use managed Files in Campaign smoke fixtures

This commit is contained in:
2026-07-21 03:18:08 +02:00
parent 844f934379
commit 37a5dfb182

View File

@@ -3743,7 +3743,8 @@ class ApiSmokeTests(unittest.TestCase):
def test_non_blocking_review_conditions_can_be_accepted_in_bulk(self) -> None: def test_non_blocking_review_conditions_can_be_accepted_in_bulk(self) -> None:
headers, _ = self._login() headers, login = self._login()
user_id = login["user"]["id"]
campaign_json = { campaign_json = {
"version": "1.0", "version": "1.0",
"campaign": {"id": "bulk-review", "name": "Bulk review", "mode": "test"}, "campaign": {"id": "bulk-review", "name": "Bulk review", "mode": "test"},
@@ -3751,10 +3752,25 @@ class ApiSmokeTests(unittest.TestCase):
"server": {"smtp": {"host": "smtp.example.invalid", "port": 587, "security": "starttls"}}, "server": {"smtp": {"host": "smtp.example.invalid", "port": 587, "security": "starttls"}},
"recipients": {"from": {"email": "sender@example.org", "type": "to"}, "allow_individual_to": True}, "recipients": {"from": {"email": "sender@example.org", "type": "to"}, "allow_individual_to": True},
"template": {"subject": "Warning test", "text": "Body"}, "template": {"subject": "Warning test", "text": "Body"},
"attachments": {"base_path": ".", "base_paths": [], "global": [{ "attachments": {
"id": "optional-missing", "base_dir": ".", "file_filter": "not-there.pdf", "base_path": "review-files",
"required": False, "missing_behavior": "warn", "zip": {"archive_id": "exclude"} "base_paths": [{
}], "zip": {"enabled": False, "archives": []}}, "id": "managed-review-files",
"name": "Review files",
"source": f"managed:user:{user_id}",
"path": "review-files",
}],
"global": [{
"id": "optional-missing",
"base_path_id": "managed-review-files",
"base_dir": "review-files",
"file_filter": "not-there.pdf",
"required": False,
"missing_behavior": "warn",
"zip": {"archive_id": "exclude"},
}],
"zip": {"enabled": False, "archives": []},
},
"entries": {"inline": [{"id": "warning-entry", "to": [{"email": "recipient@example.org", "type": "to"}]}]}, "entries": {"inline": [{"id": "warning-entry", "to": [{"email": "recipient@example.org", "type": "to"}]}]},
"validation_policy": {"missing_email": "block", "template_error": "block", "missing_optional_attachment": "warn"}, "validation_policy": {"missing_email": "block", "template_error": "block", "missing_optional_attachment": "warn"},
"delivery": {"imap_append_sent": {"enabled": False}}, "status_tracking": {"enabled": True}, "delivery": {"imap_append_sent": {"enabled": False}}, "status_tracking": {"enabled": True},
@@ -3779,7 +3795,8 @@ class ApiSmokeTests(unittest.TestCase):
self.assertEqual(review_state["reviewed_message_keys"], ["warning-entry"]) self.assertEqual(review_state["reviewed_message_keys"], ["warning-entry"])
def test_inactive_recipients_are_aggregated_but_not_built_or_reviewed(self) -> None: def test_inactive_recipients_are_aggregated_but_not_built_or_reviewed(self) -> None:
headers, _ = self._login() headers, login = self._login()
user_id = login["user"]["id"]
campaign_json = { campaign_json = {
"version": "1.0", "version": "1.0",
"campaign": {"id": "inactive-recipients", "name": "Inactive recipients", "mode": "test"}, "campaign": {"id": "inactive-recipients", "name": "Inactive recipients", "mode": "test"},
@@ -3788,10 +3805,30 @@ class ApiSmokeTests(unittest.TestCase):
"server": {"smtp": {"host": "smtp.example.invalid", "port": 587, "security": "starttls"}}, "server": {"smtp": {"host": "smtp.example.invalid", "port": 587, "security": "starttls"}},
"recipients": {"from": {"email": "sender@example.org", "name": "Sender", "type": "to"}, "allow_individual_to": True}, "recipients": {"from": {"email": "sender@example.org", "name": "Sender", "type": "to"}, "allow_individual_to": True},
"template": {"subject": "Hello", "text": "Active recipient only"}, "template": {"subject": "Hello", "text": "Active recipient only"},
"attachments": {"base_path": ".", "base_paths": [], "global": [], "zip": {"enabled": False, "archives": []}}, "attachments": {
"base_path": "inactive-files",
"base_paths": [{
"id": "managed-inactive-files",
"name": "Inactive files",
"source": f"managed:user:{user_id}",
"path": "inactive-files",
}],
"global": [],
"zip": {"enabled": False, "archives": []},
},
"entries": {"inline": [ "entries": {"inline": [
{"id": "active", "active": True, "to": [{"email": "active@example.org", "type": "to"}]}, {"id": "active", "active": True, "to": [{"email": "active@example.org", "type": "to"}]},
{"id": "inactive", "active": False, "to": [], "attachments": [{"base_dir": "missing", "file_filter": "missing.pdf", "required": True}]}, {
"id": "inactive",
"active": False,
"to": [],
"attachments": [{
"base_path_id": "managed-inactive-files",
"base_dir": "inactive-files",
"file_filter": "missing.pdf",
"required": True,
}],
},
]}, ]},
"validation_policy": {"missing_email": "block", "template_error": "block", "missing_required_attachment": "block"}, "validation_policy": {"missing_email": "block", "template_error": "block", "missing_required_attachment": "block"},
"delivery": {"imap_append_sent": {"enabled": False}}, "delivery": {"imap_append_sent": {"enabled": False}},