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)