def test_evaluate_determines_metrics_correctly_for_perform_eval(
      self, mock_perform_eval
  ):
    """Test that the correct metrics list is passed to _perform_eval based on criteria/keys."""
    mock_perform_eval.return_value = MOCK_EVAL_RESULT

    # Test case 1: Only Coherence
    raw_data_1 = [[SAMPLE_TURN_1_ALL_KEYS]]
    criteria_1 = ["response_evaluation_score"]
    ResponseEvaluator.evaluate(raw_data_1, criteria_1)
    _, kwargs = mock_perform_eval.call_args
    assert kwargs["metrics"] == [
        MetricPromptTemplateExamples.Pointwise.COHERENCE
    ]
    mock_perform_eval.reset_mock()  # Reset mock for next call

    # Test case 2: Only Rouge
    raw_data_2 = [[SAMPLE_TURN_1_ALL_KEYS]]
    criteria_2 = ["response_match_score"]
    ResponseEvaluator.evaluate(raw_data_2, criteria_2)
    _, kwargs = mock_perform_eval.call_args
    assert kwargs["metrics"] == ["rouge_1"]
    mock_perform_eval.reset_mock()

    # Test case 3: No metrics if keys missing in first turn
    raw_data_3 = [[SAMPLE_TURN_4_MINIMAL, SAMPLE_TURN_1_ALL_KEYS]]
    criteria_3 = ["response_evaluation_score", "response_match_score"]
    ResponseEvaluator.evaluate(raw_data_3, criteria_3)
    _, kwargs = mock_perform_eval.call_args
    assert kwargs["metrics"] == []
    mock_perform_eval.reset_mock()

    # Test case 4: No metrics if criteria empty
    raw_data_4 = [[SAMPLE_TURN_1_ALL_KEYS]]
    criteria_4 = []
    ResponseEvaluator.evaluate(raw_data_4, criteria_4)
    _, kwargs = mock_perform_eval.call_args
    assert kwargs["metrics"] == []
    mock_perform_eval.reset_mock()
Test that the correct metrics list is passed to _perform_eval based on criteria/keys.
tests/unittests/evaluation/test_response_evaluator.py