fix(campaign): initialize delivery worker runtime
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@govoplan/campaign-webui",
|
"name": "@govoplan/campaign-webui",
|
||||||
"version": "0.1.10",
|
"version": "0.1.11",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "webui/src/index.ts",
|
"main": "webui/src/index.ts",
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "govoplan-campaign"
|
name = "govoplan-campaign"
|
||||||
version = "0.1.10"
|
version = "0.1.11"
|
||||||
description = "GovOPlaN campaigns module with backend and WebUI integration."
|
description = "GovOPlaN campaigns module with backend and WebUI integration."
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
requires-python = ">=3.12"
|
requires-python = ">=3.12"
|
||||||
|
|||||||
@@ -279,6 +279,12 @@ class CampaignDeliveryTaskService(CampaignDeliveryTaskProvider):
|
|||||||
|
|
||||||
|
|
||||||
def delivery_tasks_capability(context: object) -> CampaignDeliveryTaskService:
|
def delivery_tasks_capability(context: object) -> CampaignDeliveryTaskService:
|
||||||
|
from govoplan_campaign.backend.runtime import configure_runtime
|
||||||
|
|
||||||
|
configure_runtime(
|
||||||
|
registry=getattr(context, "registry", None),
|
||||||
|
settings=getattr(context, "settings", None),
|
||||||
|
)
|
||||||
return CampaignDeliveryTaskService()
|
return CampaignDeliveryTaskService()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ def _campaigns_router(context: ModuleContext):
|
|||||||
manifest = ModuleManifest(
|
manifest = ModuleManifest(
|
||||||
id="campaigns",
|
id="campaigns",
|
||||||
name="Campaigns",
|
name="Campaigns",
|
||||||
version="0.1.10",
|
version="0.1.11",
|
||||||
required_capabilities=(CAPABILITY_AUTH_PRINCIPAL_RESOLVER, CAPABILITY_AUTH_PERMISSION_EVALUATOR),
|
required_capabilities=(CAPABILITY_AUTH_PRINCIPAL_RESOLVER, CAPABILITY_AUTH_PERMISSION_EVALUATOR),
|
||||||
optional_dependencies=("files", "mail", "notifications", "addresses"),
|
optional_dependencies=("files", "mail", "notifications", "addresses"),
|
||||||
provides_interfaces=(
|
provides_interfaces=(
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ from govoplan_campaign.backend.db.models import (
|
|||||||
JobSendStatus,
|
JobSendStatus,
|
||||||
JobValidationStatus,
|
JobValidationStatus,
|
||||||
)
|
)
|
||||||
|
from govoplan_campaign.backend.capabilities import delivery_tasks_capability
|
||||||
from govoplan_campaign.backend.sending.jobs import (
|
from govoplan_campaign.backend.sending.jobs import (
|
||||||
SendJobResult,
|
SendJobResult,
|
||||||
_queue_validation_statuses,
|
_queue_validation_statuses,
|
||||||
@@ -48,6 +49,17 @@ def _job(entry_id: str, **overrides):
|
|||||||
|
|
||||||
|
|
||||||
class CampaignQueueSelectionTests(unittest.TestCase):
|
class CampaignQueueSelectionTests(unittest.TestCase):
|
||||||
|
def test_delivery_task_capability_configures_module_runtime_for_worker_processes(self):
|
||||||
|
registry = object()
|
||||||
|
settings = object()
|
||||||
|
context = SimpleNamespace(registry=registry, settings=settings)
|
||||||
|
|
||||||
|
with patch("govoplan_campaign.backend.runtime.configure_runtime") as configure:
|
||||||
|
capability = delivery_tasks_capability(context)
|
||||||
|
|
||||||
|
self.assertIsNotNone(capability)
|
||||||
|
configure.assert_called_once_with(registry=registry, settings=settings)
|
||||||
|
|
||||||
def test_selects_queueable_jobs_without_reclassifying_retry_states(self):
|
def test_selects_queueable_jobs_without_reclassifying_retry_states(self):
|
||||||
skipped_send = _job("1", send_status=JobSendStatus.FAILED_TEMPORARY.value)
|
skipped_send = _job("1", send_status=JobSendStatus.FAILED_TEMPORARY.value)
|
||||||
skipped_queue = _job("2", queue_status=JobQueueStatus.PAUSED.value)
|
skipped_queue = _job("2", queue_status=JobQueueStatus.PAUSED.value)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@govoplan/campaign-webui",
|
"name": "@govoplan/campaign-webui",
|
||||||
"version": "0.1.10",
|
"version": "0.1.11",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
|
|||||||
Reference in New Issue
Block a user