45 lines
1.3 KiB
Python
45 lines
1.3 KiB
Python
from __future__ import annotations
|
|
|
|
import unittest
|
|
|
|
from sentiment_engine import _adaptive_score, _confirmed_phase
|
|
|
|
|
|
class SentimentEngineTests(unittest.TestCase):
|
|
def test_adaptive_score_uses_latest_250_observations(self):
|
|
history = [0.0] * 50 + [100.0] * 250
|
|
self.assertEqual(_adaptive_score(50.0, 50.0, history), 12.5)
|
|
|
|
def test_ice_must_repair_before_fermentation(self):
|
|
phase, reason = _confirmed_phase(
|
|
{"phase": "冰点"},
|
|
score=70,
|
|
day_change=45,
|
|
systemic_health=70,
|
|
profit_score=70,
|
|
ecology_score=75,
|
|
phase_signal="发酵",
|
|
extreme_ice=False,
|
|
fermentation_signal_count=2,
|
|
)
|
|
self.assertEqual(phase, "修复")
|
|
self.assertIn("冰点后", reason)
|
|
|
|
def test_repair_requires_continuous_fermentation_confirmation(self):
|
|
phase, _ = _confirmed_phase(
|
|
{"phase": "修复"},
|
|
score=58,
|
|
day_change=5,
|
|
systemic_health=55,
|
|
profit_score=60,
|
|
ecology_score=65,
|
|
phase_signal="发酵",
|
|
extreme_ice=False,
|
|
fermentation_signal_count=1,
|
|
)
|
|
self.assertEqual(phase, "修复")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|