Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 19 additions & 17 deletions backend/tests/unit/test_lock_bypass_fixes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Tests for locked conversation bypass fixes (#6089).

Check warning on line 1 in backend/tests/unit/test_lock_bypass_fixes.py

View workflow job for this annotation

GitHub Actions / Hygiene

Large changed file

backend/tests/unit/test_lock_bypass_fixes.py is 1905 lines; consider splitting files over 800 lines.

Verifies that is_locked conversations/memories are properly guarded
across all previously-bypassed endpoints by calling the real code paths.
Expand Down Expand Up @@ -1062,18 +1062,19 @@
unlocked_conv = _make_conversation(locked=False, conversation_id='conv-2')
conversations_db.get_conversations = MagicMock(return_value=[locked_conv, unlocked_conv])

with patch('utils.other.notifications.is_trial_paywalled', return_value=False):
with patch('utils.other.notifications.try_acquire_daily_summary_lock', return_value=True):
with patch(
'utils.other.notifications.generate_comprehensive_daily_summary',
return_value={'headline': 'Test', 'day_emoji': '📅', 'overview': 'ok'},
) as mock_gen:
daily_summaries_db.create_daily_summary = MagicMock(return_value='summary-1')
daily_summaries_db.get_daily_summary_by_date = MagicMock(return_value=None)
with patch('utils.other.notifications.send_notification'):
from utils.other.notifications import _send_summary_notification

_send_summary_notification(('test-uid', 'token', 'UTC'))
# The daily recap is no longer gated on is_trial_paywalled (#9357 removed that call from
# _send_summary_notification), so this test only exercises the locked-conversation filter.
with patch('utils.other.notifications.try_acquire_daily_summary_lock', return_value=True):
with patch(
'utils.other.notifications.generate_comprehensive_daily_summary',
return_value={'headline': 'Test', 'day_emoji': '📅', 'overview': 'ok'},
) as mock_gen:
daily_summaries_db.create_daily_summary = MagicMock(return_value='summary-1')
daily_summaries_db.get_daily_summary_by_date = MagicMock(return_value=None)
with patch('utils.other.notifications.send_notification'):
from utils.other.notifications import _send_summary_notification

_send_summary_notification(('test-uid', 'token', 'UTC'))

# generate_comprehensive_daily_summary must be called only with unlocked conversations
mock_gen.assert_called_once()
Expand All @@ -1089,12 +1090,13 @@
conversations_db.get_conversations = MagicMock(return_value=[_make_conversation(locked=True)])
daily_summaries_db.get_daily_summary_by_date = MagicMock(return_value=None)

with patch('utils.other.notifications.is_trial_paywalled', return_value=False):
with patch('utils.other.notifications.try_acquire_daily_summary_lock', return_value=True):
with patch('utils.other.notifications.generate_comprehensive_daily_summary') as mock_gen:
from utils.other.notifications import _send_summary_notification
# Recap is no longer gated on is_trial_paywalled (#9357); only the all-locked early return
# is under test here.
with patch('utils.other.notifications.try_acquire_daily_summary_lock', return_value=True):
with patch('utils.other.notifications.generate_comprehensive_daily_summary') as mock_gen:
from utils.other.notifications import _send_summary_notification

_send_summary_notification(('test-uid', 'token', 'UTC'))
_send_summary_notification(('test-uid', 'token', 'UTC'))

# Should not call LLM when no unlocked conversations remain
mock_gen.assert_not_called()
Expand Down
Loading