@@ -0,0 +1,40 @@
|
||||
import importlib.util
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
SCRIPT = (
|
||||
Path(__file__).resolve().parents[3]
|
||||
/ "skills"
|
||||
/ "tsl-api-reference"
|
||||
/ "scripts"
|
||||
/ "lookup.py"
|
||||
)
|
||||
|
||||
|
||||
def load_script():
|
||||
spec = importlib.util.spec_from_file_location("tsl_lookup", SCRIPT)
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(module)
|
||||
return module
|
||||
|
||||
|
||||
class LookupTest(unittest.TestCase):
|
||||
def test_keyword_search_includes_tags_and_summary(self):
|
||||
module = load_script()
|
||||
rows = [
|
||||
{
|
||||
"name": "demo",
|
||||
"signature": "demo()",
|
||||
"module": "base",
|
||||
"tags": "数组 列表",
|
||||
"summary": "返回示例值",
|
||||
}
|
||||
]
|
||||
|
||||
self.assertEqual(rows, module.search_keyword(rows, ["数组"]))
|
||||
self.assertEqual(rows, module.search_keyword(rows, ["返回示例"]))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user