import pytest
import numpy as np
import tempfile
import os
import pandas as pd
from privacy_tuner.output.exporter import CSVExporter

def test_csv_exporter():
    data = np.array([[1, 2], [3, 4], [5, 6]])
    with tempfile.NamedTemporaryFile(suffix='.csv', delete=False) as tmp:
        filepath = tmp.name

    exporter = CSVExporter()
    exporter.export(data, filepath, index=False, header=False)

    # 验证文件存在且内容正确
    assert os.path.exists(filepath)
    df = pd.read_csv(filepath, header=None)
    np.testing.assert_array_equal(df.values, data)

    # 清理
    os.unlink(filepath)