部署:kp_graph 缺文件降级不 500,systemd 服务文件补腾讯凭据与 data 目录,README 说明首次初始化可省
This commit is contained in:
@@ -149,5 +149,24 @@ class ExplainRetreatTest(unittest.TestCase):
|
||||
self.assertIsNone(r["retreat"])
|
||||
|
||||
|
||||
class GraphMissingTest(unittest.TestCase):
|
||||
"""数据文件缺失时不能 500——「退一层」只是建议。"""
|
||||
|
||||
def test_missing_file_degrades_to_empty(self):
|
||||
import tempfile
|
||||
from backend import kp_graph
|
||||
orig = kp_graph.GRAPH_PATH
|
||||
try:
|
||||
kp_graph.GRAPH_PATH = Path(tempfile.gettempdir()) / "no_such_kp_graph.json"
|
||||
kp_graph._load.cache_clear()
|
||||
self.assertIsNone(kp_graph.topic("M041"))
|
||||
self.assertEqual(kp_graph.parents("M041"), [])
|
||||
self.assertIsNone(kp_graph.retreat("M041"))
|
||||
self.assertEqual(kp_graph.validate(), [])
|
||||
finally:
|
||||
kp_graph.GRAPH_PATH = orig
|
||||
kp_graph._load.cache_clear()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user