feat(campaign): bound synchronous delivery
This commit is contained in:
@@ -2,6 +2,7 @@ from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from types import SimpleNamespace
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -12,6 +13,7 @@ from govoplan_core.core.modules import DocumentationContext
|
||||
@dataclass(frozen=True)
|
||||
class _Principal:
|
||||
scopes: frozenset[str]
|
||||
tenant_id: str = "tenant-1"
|
||||
|
||||
def has(self, scope: str) -> bool:
|
||||
namespace, resource, _action = scope.split(":", 2)
|
||||
@@ -181,6 +183,32 @@ def test_runtime_documentation_full_composition_uses_only_user_facing_names() ->
|
||||
assert "secret" not in rendered.lower()
|
||||
|
||||
|
||||
def test_runtime_documentation_states_the_effective_synchronous_limit() -> None:
|
||||
session = SimpleNamespace(
|
||||
get=lambda _model, _id: SimpleNamespace(
|
||||
settings={
|
||||
"campaign_delivery_policy": {
|
||||
"synchronous_send_max_recipients": 12,
|
||||
}
|
||||
}
|
||||
)
|
||||
)
|
||||
with patch.dict("os.environ", {"GOVOPLAN_CAMPAIGN_SYNCHRONOUS_SEND_MAX_RECIPIENTS": "25"}):
|
||||
topic = documentation_topics(
|
||||
DocumentationContext(
|
||||
registry=_Registry({"mail.campaign_delivery"}),
|
||||
principal=_Principal(frozenset({"campaigns:campaign:read", "campaigns:campaign:send"})),
|
||||
session=session,
|
||||
documentation_type="user",
|
||||
)
|
||||
)[0]
|
||||
|
||||
assert any(
|
||||
"Send now is limited to 12 eligible recipient job(s)" in item
|
||||
for item in topic.metadata["current_configuration"]
|
||||
)
|
||||
|
||||
|
||||
def _visible_static_topics(
|
||||
scopes: set[str],
|
||||
*,
|
||||
|
||||
Reference in New Issue
Block a user