guanghu-ice-heart/server-tools/heartbeat-engineering-shelf/test_engineering_shelf.py

20 lines
1.7 KiB
Python

#!/usr/bin/env python3
import importlib.util,tempfile,unittest
from pathlib import Path
S=Path(__file__).with_name('engineering_shelf.py');spec=importlib.util.spec_from_file_location('shelf',S);M=importlib.util.module_from_spec(spec);spec.loader.exec_module(M)
class Tests(unittest.TestCase):
def test_full_registry_and_cumulative_order(self):
r=M.audit();self.assertEqual(r['outcome'],'PASS');self.assertEqual(r['module_count'],17);self.assertEqual(r['cumulative_gate_count'],17)
def test_sync_builds_live_current_without_claiming_engineering(self):
with tempfile.TemporaryDirectory() as t:
M.sync(Path(t));v=M.load(Path(t)/'CURRENT.json');self.assertFalse(v['reality_engineering_started']);self.assertEqual(v['zero_core_dispatch'],'NOT_ISSUED')
def test_exact_query_finds_current_and_legacy_parts(self):
self.assertEqual(M.query('HLP-LANG-MOD-005')['matches'][0]['module_id'],'HLP-LANG-MOD-005')
self.assertTrue(any(x.get('part_id')=='HLP-PART-MODEL-RECEIPT-DONOR-0_5_8' for x in M.query('旧模型回执供体')['matches']))
self.assertTrue(any(x.get('part_id')=='HLP-PART-MODEL-RECEIPT-DONOR-0_5_8' for x in M.query('旧模型回执供体现在能不能用')['matches']))
def test_resume_returns_first_unimplemented_module(self):
r=M.resume();self.assertEqual(r['current']['module_id'],'HLP-LANG-MOD-001');self.assertEqual(r['next_gate'],'GATE-HLP-STAGE1-001')
def test_smart_query_model_can_only_return_registered_ids(self):
def fake(_): return {'response':'{"module_ids":["HLP-LANG-MOD-015","FAKE"]}','selected_model':'mock'}
r=M.smart_query('监管审核',fake);self.assertEqual([x['module_id'] for x in r['matches']],['HLP-LANG-MOD-015'])
if __name__=='__main__':unittest.main()