Files
Jyotisha/tests/test_probe_question_contract.py
T
Jesse_Chen 7f82428b44
Independent Staging Quality Gate / validate (push) Failing after 11m51s
Independent Staging Quality Gate / publish (push) Has been skipped
fix(rectification): unify discriminator question contract and rank by information gain
Python and TypeScript now share a four-option probe contract, persist Focus before asking, and pick the highest-value renderable probe instead of preferring low-gain career events over D24.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-28 00:25:35 +08:00

51 lines
2.1 KiB
Python

from __future__ import annotations
import unittest
from scripts.rectification.probe_question_contract import (
ANSWER_CLASSES,
EXISTENCE_STYLE_OPTIONS,
QUALITY_STYLE_OPTIONS,
complete_style_options,
is_renderable_probe,
)
class ProbeQuestionContractTests(unittest.TestCase):
def test_existence_completes_four_options(self) -> None:
completed = complete_style_options("existence")
self.assertEqual(completed, [dict(item) for item in EXISTENCE_STYLE_OPTIONS])
def test_quality_covers_unsure(self) -> None:
completed = complete_style_options("event_quality")
self.assertEqual(completed, [dict(item) for item in QUALITY_STYLE_OPTIONS])
self.assertEqual({item["answer_class"] for item in completed or []}, set(ANSWER_CLASSES))
def test_varga_style_needs_two_scoring_labels(self) -> None:
self.assertIsNone(complete_style_options("varga_style", [
{"label": "巨蟹相处主动热情", "answer_class": "yes"},
]))
completed = complete_style_options("varga_style", [
{"label": "巨蟹相处主动热情", "answer_class": "yes", "sign": "巨蟹"},
{"label": "狮子独立强势", "answer_class": "weak_yes", "sign": "狮子"},
])
self.assertIsNotNone(completed)
assert completed is not None
self.assertEqual(len(completed), 4)
self.assertEqual(next(item["label"] for item in completed if item["answer_class"] == "no"), "都不是这些特质")
def test_clock_copy_is_dropped_and_catalog_fills_existence(self) -> None:
completed = complete_style_options("existence", [
{"label": "08:12 左右发生", "answer_class": "yes"},
])
self.assertEqual(completed[0]["label"], "明确发生且时间吻合")
def test_unrenderable_varga_probe_is_rejected(self) -> None:
self.assertFalse(is_renderable_probe({
"information_gain": 1.2,
"candidate_ids": ["05:00", "05:04"],
"expected_outcomes": [{}, {}],
"choice_kind": "varga_style",
"style_options": [{"label": "外貌更接近第一种", "answer_class": "yes"}],
}))