fix: FCM must not break ingest; add requests dependency (0.9.3)
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
"""FCM push must not break event ingest."""
|
||||
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
from app.services.mobile_notify import MobileNotConfiguredError, _send_fcm_data
|
||||
|
||||
|
||||
def test_send_fcm_data_swallows_token_errors_by_default():
|
||||
with patch(
|
||||
"app.services.mobile_notify._fcm_access_token",
|
||||
side_effect=MobileNotConfiguredError("FCM: install requests"),
|
||||
):
|
||||
with patch("app.services.mobile_notify.get_effective_fcm_config") as mock_cfg:
|
||||
mock_cfg.return_value.enabled = True
|
||||
mock_cfg.return_value.project_id = "proj"
|
||||
mock_cfg.return_value.service_account_path = "/etc/fcm.json"
|
||||
mock_cfg.return_value.configured = True
|
||||
mock_cfg.return_value.active = True
|
||||
_send_fcm_data(["token"], {"kind": "test"}, title="t", body="b")
|
||||
|
||||
|
||||
def test_send_fcm_data_raises_token_errors_when_required():
|
||||
with patch(
|
||||
"app.services.mobile_notify._fcm_access_token",
|
||||
side_effect=MobileNotConfiguredError("FCM: install requests"),
|
||||
):
|
||||
with patch("app.services.mobile_notify.get_effective_fcm_config") as mock_cfg:
|
||||
mock_cfg.return_value.enabled = True
|
||||
mock_cfg.return_value.project_id = "proj"
|
||||
mock_cfg.return_value.service_account_path = "/etc/fcm.json"
|
||||
mock_cfg.return_value.configured = True
|
||||
mock_cfg.return_value.active = True
|
||||
with pytest.raises(MobileNotConfiguredError):
|
||||
_send_fcm_data(
|
||||
["token"],
|
||||
{"kind": "test"},
|
||||
title="t",
|
||||
body="b",
|
||||
require_success=True,
|
||||
)
|
||||
Reference in New Issue
Block a user