[verified] Fix P1-P2-P5 audit findings: simulation reuses board, source_summary clarity, dead-code removal + conftest
- P1: /api/v1/simulation now uses the canonical board score (default_scores)
instead of a divergent 3-theme recompute -> 'จำลอง' can't disagree with board
(live check: sim top pick PTT == top board combined 1.600). Removes binary
auto/en signs, restores quality+momentum+dividend screen consistency.
- P2: dashboard emits source_summary{factor_keys, rows}; frontend shows
'N ปัจจัย · M แหล่ง' so the 7-vs-5 count confusion is impossible.
- P5: removed dead themes.list_themes()/Theme/build_theme_scores/_map_index and
the tests that locked them; added tests/conftest.py so pytest needs no PYTHONPATH.
- docs: audit-and-plan-2026-08-26.md (full P0-P5 plan) + engineering-log entry.
- 203 backend tests pass; Vite build passes. Independent reviewer: no security or
logic blockers (minor error-leak suggestion applied: 503 message no longer leaks
exception detail).
This commit is contained in:
@@ -8,14 +8,6 @@ from app import themes
|
||||
|
||||
|
||||
class ThemesTest(unittest.TestCase):
|
||||
def test_list_themes_has_three(self) -> None:
|
||||
t = themes.list_themes()
|
||||
self.assertEqual(len(t), 3)
|
||||
ids = {x.id for x in t}
|
||||
self.assertEqual(ids, {"tourism", "auto_credit", "refining_energy"})
|
||||
for x in t:
|
||||
self.assertTrue(x.label_th) # Thai label present
|
||||
|
||||
def test_exposure_mapping_contains_expected(self) -> None:
|
||||
self.assertIn("AOT", themes.THEME_SYMBOLS["tourism"])
|
||||
self.assertIn("PTT", themes.THEME_SYMBOLS["refining_energy"])
|
||||
@@ -25,17 +17,6 @@ class ThemesTest(unittest.TestCase):
|
||||
self.assertEqual(themes.THEME_FREQUENCY["refining_energy"], "quarterly")
|
||||
self.assertEqual(themes.THEME_FREQUENCY["tourism"], "monthly")
|
||||
|
||||
def test_build_theme_scores_z_normalizes(self) -> None:
|
||||
signals = [
|
||||
{"symbol": "A", "score": 10.0},
|
||||
{"symbol": "B", "score": 5.0},
|
||||
{"symbol": "C", "score": 0.0},
|
||||
]
|
||||
scores = themes.build_theme_scores("tourism", signals)
|
||||
self.assertAlmostEqual(scores["A"], 1.224, places=2)
|
||||
self.assertAlmostEqual(scores["B"], 0.0, places=2)
|
||||
self.assertAlmostEqual(scores["C"], -1.224, places=2)
|
||||
|
||||
def test_siamchart_score_uses_growth_and_yield(self) -> None:
|
||||
factors = {
|
||||
"factors": [
|
||||
|
||||
Reference in New Issue
Block a user