import pytest
import numpy as np
from privacy_tuner.core.privacy_mechanism import PrivacyMechanism
from typing import Dict, Any

# 创建一个简单的虚拟子类用于测试
class DummyMechanism(PrivacyMechanism):
    def apply(self, data: np.ndarray, params: Dict[str, Any]) -> np.ndarray:
        # 简单的实现：返回原数据（不扰动）
        return data

def test_privacy_mechanism_interface():
    """测试 PrivacyMechanism 接口可被实现并调用"""
    mechanism = DummyMechanism()
    data = np.array([[1, 2], [3, 4]])
    params = {"dummy": 1}
    result = mechanism.apply(data, params)
    # 验证返回的是 ndarray 且形状相同
    assert isinstance(result, np.ndarray)
    assert result.shape == data.shape
    # 验证数据内容相同（因为 dummy 实现未改动）
    np.testing.assert_array_equal(result, data)