File size: 786 Bytes
7cc81cb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import pytest
from app.projects.repositories.notification_repository import NotificationRepository
from app.projects.services.notification_service import NotificationService

@pytest.mark.asyncio
async def test_notification_preferences(db_session):
    repo = NotificationRepository(db_session)
    service = NotificationService(repo)
    
    workspace_id = "ws1"
    user_id = "user1"
    event = "approval_request"
    
    # Test initial fetch (should be empty or defaults)
    prefs = await service.get_preferences(workspace_id, user_id)
    
    # Test update
    await service.update_preference(workspace_id, user_id, event, False)
    
    prefs = await service.get_preferences(workspace_id, user_id)
    assert any(p['event_type'] == event and not p['enabled'] for p in prefs)