forked from Ikalus1988/MisakaNet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_clean_pipeline.py
More file actions
59 lines (47 loc) 路 2.43 KB
/
Copy pathtest_clean_pipeline.py
File metadata and controls
59 lines (47 loc) 路 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import unittest
import sys
from pathlib import Path
# Add project script dir to sys.path so we can import clean_pipeline
PROJECT_ROOT = Path(__file__).parent.parent
sys.path.insert(0, str(PROJECT_ROOT / "misakanet" / "scripts"))
from clean_pipeline import DOMAIN_KEYWORDS, step_classify
class TestCleanPipeline(unittest.TestCase):
def test_docker_keywords_present(self):
# Verify docker domain exists and has expected keywords
self.assertIn("docker", DOMAIN_KEYWORDS)
self.assertIn("devops", DOMAIN_KEYWORDS)
docker_kws = DOMAIN_KEYWORDS["docker"]
self.assertIn("docker", docker_kws)
self.assertIn("dockerfile", docker_kws)
self.assertIn("docker-compose", docker_kws)
self.assertIn("container", docker_kws)
self.assertIn("image", docker_kws)
self.assertIn("buildx", docker_kws)
# Verify docker keyword is removed from devops
self.assertNotIn("docker", DOMAIN_KEYWORDS["devops"])
def test_step_classify_docker(self):
# Input lesson with general domain and docker keywords
lesson = {
"content": "---\ntitle: Docker build error\ndomain: general\nstatus: draft\n---\n\nUsing docker-compose we hit an issue when downloading the base image.",
"fm": {"title": "Docker build error", "domain": "general", "status": "draft"},
"body": "Using docker-compose we hit an issue when downloading the base image.",
"relpath": ".nodes/staging/node2/test-docker.md"
}
lessons = [lesson]
result = step_classify(lessons)
# Verify that it got classified as 'docker'
self.assertEqual(result[0]["fm"]["domain"], "docker")
def test_step_classify_devops(self):
# Input lesson with general domain and devops keywords
lesson = {
"content": "---\ntitle: WSL terminal setup\ndomain: general\nstatus: draft\n---\n\nConfiguring bash shell environment in wsl.",
"fm": {"title": "WSL terminal setup", "domain": "general", "status": "draft"},
"body": "Configuring bash shell environment in wsl.",
"relpath": ".nodes/staging/node2/test-devops.md"
}
lessons = [lesson]
result = step_classify(lessons)
# Verify that it got classified as 'devops'
self.assertEqual(result[0]["fm"]["domain"], "devops")
if __name__ == "__main__":
unittest.main()