async def test_process_sync_due(self, mock_sync_multiple):
        """Test processing a sync that is due."""
        due_sync = mock_sync_multiple[0]  # Get the due sync
        scheduler = PlatformScheduler()
        mock_db = AsyncMock()

        # Create a proper mock user that will pass Pydantic validation
        mock_user = schemas.User(
            id=uuid.uuid4(),
            email="test@example.com",
            full_name="Test User",
            organization_id=uuid.uuid4(),
            is_active=True,
        )

        # Set up a datetime that will make the sync due
        now = datetime.now(timezone.utc)
        next_run = now - timedelta(minutes=5)  # 5 minutes in the past

        # Mock database operations
        with (
            patch(
                "airweave.platform.scheduler.crud.user.get_by_email",
                new_callable=AsyncMock,
                return_value=mock_user,
            ),
            patch(
                "airweave.platform.scheduler.crud.sync_job.get_latest_by_sync_id",
                new_callable=AsyncMock,
                return_value=None,
            ),
            patch(
                "airweave.platform.scheduler.crud.sync.get",
                new_callable=AsyncMock,
                return_value=due_sync,
            ),
            patch("airweave.platform.scheduler.crud.sync.update", new_callable=AsyncMock),
            patch(
                "airweave.platform.scheduler.PlatformScheduler._trigger_sync",
                new_callable=AsyncMock,
                return_value=True,
            ),
            patch("airweave.platform.scheduler.datetime") as mock_datetime,
            patch("airweave.platform.scheduler.croniter") as mock_croniter,
        ):
            # Set the mock datetime to return our fixed "now"
            mock_datetime.now.return_value = now
            mock_datetime.fromtimestamp.return_value = datetime.fromtimestamp(0, tz=timezone.utc)

            # Make croniter return our fixed next_run time
            mock_cron = MagicMock()
            mock_cron.get_next.return_value = next_run
            mock_croniter.return_value = mock_cron

            result = await scheduler._process_sync(mock_db, due_sync)

            # Assert sync was triggered
            assert result is True
            scheduler._trigger_sync.assert_called_once()
Test processing a sync that is due.
backend/tests/unit/platform/test_scheduler.py