mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 07:27:15 +08:00
feat: make subscribe reports durable
This commit is contained in:
@@ -31,10 +31,13 @@ def test_subscription_and_outbox_intent_commit_together() -> None:
|
||||
result = command.execute({}, {"name": "demo"}, "user")
|
||||
|
||||
assert result == (42, "ok")
|
||||
assert calls == ["subscription", "outbox", "commit"]
|
||||
intent = outbox.stage.call_args.args[0]
|
||||
assert calls == ["subscription", "outbox", "outbox", "commit"]
|
||||
intent = outbox.stage.call_args_list[0].args[0]
|
||||
assert intent.event_key == "subscribe.added:42:unknown:unknown:v1"
|
||||
assert intent.payload["subscribe_id"] == 42
|
||||
report_intent = outbox.stage.call_args_list[1].args[0]
|
||||
assert report_intent.topic == "subscribe.added.report"
|
||||
assert report_intent.event_key.endswith(":report")
|
||||
|
||||
|
||||
def test_outbox_stage_failure_rolls_back_business_transaction() -> None:
|
||||
|
||||
@@ -9,6 +9,7 @@ from app.adapters.external.server import (
|
||||
)
|
||||
from app.application.server.report import ServerReportService
|
||||
from app.application.server.share import ServerSharingService
|
||||
from app.runtime.config import settings
|
||||
from app.schemas.types import MediaSource
|
||||
|
||||
|
||||
@@ -237,3 +238,19 @@ class MoviePilotServerHelperTests(unittest.TestCase):
|
||||
"tmdbid": 99,
|
||||
})
|
||||
)
|
||||
|
||||
def test_durable_subscribe_report_treats_disabled_sharing_as_success(self):
|
||||
"""用户关闭统计分享时,durable intent 应视为无需远端投递。"""
|
||||
with patch.object(settings, "SUBSCRIBE_STATISTIC_SHARE", False), patch.object(
|
||||
MoviePilotServerHelper,
|
||||
"sub_reg",
|
||||
) as reporter:
|
||||
self.assertTrue(MoviePilotServerHelper.sub_reg_durable({"media_id": "1"}))
|
||||
reporter.assert_not_called()
|
||||
|
||||
with patch.object(settings, "SUBSCRIBE_STATISTIC_SHARE", False), patch.object(
|
||||
MoviePilotServerHelper,
|
||||
"sub_done",
|
||||
) as reporter:
|
||||
self.assertTrue(MoviePilotServerHelper.sub_done_durable({"media_id": "1"}))
|
||||
reporter.assert_not_called()
|
||||
|
||||
Reference in New Issue
Block a user