fix: remove dead automated user filtering code
The _is_automated_user method was never called - loop prevention is handled by debouncing instead. User email filtering was intentionally removed because the notification email is the page CREATOR, not editor. - Remove unused _is_automated_user method - Update test to verify notifications are processed regardless of user - Remove obsolete test_automated_user_filtering test 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -50,22 +50,6 @@ class TestWikiChangeListener:
|
||||
assert listener._debounce_seconds == 5
|
||||
assert len(listener._recent_notifications) == 0
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_automated_user_filtering(self, listener):
|
||||
"""Test that automated users are correctly identified."""
|
||||
# Automated users should be filtered
|
||||
assert listener._is_automated_user("librarian@schweitz.net") is True
|
||||
assert listener._is_automated_user("library-desk@system") is True
|
||||
assert listener._is_automated_user("automation@system") is True
|
||||
assert listener._is_automated_user("bot@system") is True
|
||||
|
||||
# Case insensitive
|
||||
assert listener._is_automated_user("LIBRARIAN@SCHWEITZ.NET") is True
|
||||
|
||||
# Regular users should not be filtered
|
||||
assert listener._is_automated_user("user@example.com") is False
|
||||
assert listener._is_automated_user("john@example.com") is False
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_debouncing_prevents_duplicates(self, listener):
|
||||
"""Test that debouncing prevents duplicate processing."""
|
||||
@@ -163,19 +147,29 @@ class TestWikiChangeListener:
|
||||
assert mock_process.call_args[1]['event'] == 'page.delete'
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_automated_user_notification_filtered(self, listener):
|
||||
"""Test that notifications from automated users are filtered out."""
|
||||
async def test_any_user_notification_processed(self, listener):
|
||||
"""Test that notifications are processed regardless of user email.
|
||||
|
||||
Note: The user_email in PostgreSQL notifications is the page CREATOR,
|
||||
not the editor. We cannot filter by user email because:
|
||||
- A page created by 'librarian' but edited by a human should be processed
|
||||
- Filtering by creator would break legitimate page ingestion
|
||||
Loop prevention is handled by debouncing instead.
|
||||
"""
|
||||
mock_connection = AsyncMock()
|
||||
|
||||
with patch.object(listener, '_process_page_change', new_callable=AsyncMock) as mock_process:
|
||||
# Notification from automated user should be skipped
|
||||
# Even system user notifications should be processed
|
||||
# (debouncing handles loop prevention, not user filtering)
|
||||
await listener._handle_notification(
|
||||
mock_connection, 1234, 'wiki_page_changes',
|
||||
'UPDATE:123:librarian@schweitz.net'
|
||||
)
|
||||
|
||||
# Process should NOT be called
|
||||
mock_process.assert_not_called()
|
||||
# Process SHOULD be called (user filtering is not used)
|
||||
mock_process.assert_called_once()
|
||||
assert mock_process.call_args[1]['page_id'] == 123
|
||||
assert mock_process.call_args[1]['event'] == 'page.update'
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_duplicate_notification_filtered(self, listener):
|
||||
|
||||
Reference in New Issue
Block a user