import pytest
import numpy as np
from privacy_tuner.core.risk_meter import RiskMeter
from typing import Optional, Dict, Any

class DummyRiskMeter(RiskMeter):
    def measure(self,
                original: np.ndarray,
                perturbed: np.ndarray,
                params: Optional[Dict[str, Any]] = None) -> float:
        # 返回一个固定风险值
        return 0.5

def test_risk_meter_interface():
    meter = DummyRiskMeter()
    orig = np.array([[1, 2], [3, 4]])
    pert = np.array([[1, 2], [3, 4]])  # 相同数据
    risk = meter.measure(orig, pert, params=None)
    assert isinstance(risk, float)
    assert risk == 0.5