async def test_subscribe_sync_job_found(self, mock_db, mock_user):
        """Test subscribing to a sync job that exists."""
        # Arrange
        job_id = uuid.uuid4()

        # Create a mock Redis PubSub instance
        mock_pubsub = AsyncMock()

        # Create an async generator for listen()
        async def mock_listen():
            # First yield a subscribe message
            yield {"type": "subscribe", "data": None}
            # Then yield a data message
            test_update = schemas.SyncJobUpdate(
                job_id=job_id,
                status=SyncJobStatus.IN_PROGRESS,
                progress=50,
                message="Test message",
            )
            yield {"type": "message", "data": test_update.model_dump_json()}
            # Stop iteration after these messages

        mock_pubsub.listen = mock_listen
        mock_pubsub.close = AsyncMock()

        with patch(
            "airweave.platform.sync.pubsub.sync_pubsub.subscribe", new_callable=AsyncMock
        ) as mock_subscribe:
            mock_subscribe.return_value = mock_pubsub

            # Act - Use new signature with user dependency injection
            response = await sync.subscribe_sync_job(job_id=job_id, user=mock_user)

            # Assert
            mock_subscribe.assert_called_once_with(job_id)
            assert isinstance(response, StreamingResponse)
            assert response.media_type == "text/event-stream"
            assert response.headers["Cache-Control"] == "no-cache, no-transform"
            assert response.headers["Connection"] == "keep-alive"
            assert response.headers["X-Accel-Buffering"] == "no"
Test subscribing to a sync job that exists.
backend/tests/unit/api/test_sync.py