def test_main_fetch_DT_exception(
        self,
        mock_mds_writer: MagicMock,
        mock_fetch_DT: MagicMock,
        mock_validate_cluster_info: MagicMock,
        mock_validate_columns: MagicMock,
        mock_workspace_client_class: MagicMock,
    ) -> None:
        """Test that main raises an exception when fetch_DT fails."""
        with patch(
            'databricks.sdk.WorkspaceClient',
            mock_workspace_client_class,
        ):
            from llmfoundry.command_utils.data_prep.convert_delta_to_contrastive_mds import \
                convert_delta_to_contrastive_mds

            # Setup mocks
            mock_workspace_client_instance = MagicMock()
            mock_workspace_client_class.return_value = mock_workspace_client_instance

            mock_validate_cluster_info.return_value = (
                'dbconnect',
                MagicMock(),
                MagicMock(),
            )
            mock_validate_columns.return_value = True

            args: dict[str, Any] = {
                'delta_table_name': 'test_table',
                'http_path': 'http://test_path',
                'cluster_id': 'cluster123',
                'use_serverless': False,
                'output_path': '/output/path',
                'batch_size': 1000,
                'processes': 4,
            }

            with self.assertLogs(
                'llmfoundry.command_utils.data_prep.convert_delta_to_contrastive_mds',
                level='ERROR',
            ) as log:
                with self.assertRaises(Exception) as cm:
                    convert_delta_to_contrastive_mds(**args)

            self.assertIn('Error fetching data: Fetch DT Error', log.output[0])
            self.assertEqual(str(cm.exception), 'Fetch DT Error')
Test that main raises an exception when fetch_DT fails.
tests/a_scripts/data_prep/test_delta_to_contrastive.py