import pytest
import numpy as np
from privacy_tuner.core.utility_evaluator import UtilityEvaluator
from typing import Dict, Any, Optional

class DummyUtility(UtilityEvaluator):
    def evaluate(self, original: np.ndarray, perturbed: np.ndarray,
                 task: Optional[Dict[str, Any]] = None) -> float:
        # 返回固定效用值
        return 0.8

def test_utility_evaluator_interface():
    util = DummyUtility()
    orig = np.array([[1, 2], [3, 4]])
    pert = np.array([[1, 2], [3, 4]])
    score = util.evaluate(orig, pert, task={"type": "test"})
    assert isinstance(score, float)
    assert score == 0.8