MCPcopy Create free account
hub / github.com/NanmiCoder/MediaCrawler / test_crawler_manager_build_command

Function test_crawler_manager_build_command

tests/test_api_limits.py:29–63  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

27 config.CRAWLER_MAX_COMMENTS_COUNT_SINGLENOTES = orig_comments
28
29def test_crawler_manager_build_command():
30 cm = CrawlerManager()
31
32 # 1. No max limits passed in API request
33 req1 = CrawlerStartRequest(
34 platform=PlatformEnum.XHS,
35 login_type=LoginTypeEnum.QRCODE,
36 crawler_type=CrawlerTypeEnum.SEARCH,
37 keywords="test",
38 max_notes_count=None,
39 max_comments_count=None
40 )
41 cmd1 = cm._build_command(req1)
42 # Check that the custom arguments are NOT present
43 assert "--crawler_max_notes_count" not in cmd1
44 assert "--max_comments_count_singlenotes" not in cmd1
45
46 # 2. Both limits passed in API request
47 req2 = CrawlerStartRequest(
48 platform=PlatformEnum.XHS,
49 login_type=LoginTypeEnum.QRCODE,
50 crawler_type=CrawlerTypeEnum.SEARCH,
51 keywords="test",
52 max_notes_count=50,
53 max_comments_count=5
54 )
55 cmd2 = cm._build_command(req2)
56 # Check that they are correctly added
57 assert "--crawler_max_notes_count" in cmd2
58 idx_notes = cmd2.index("--crawler_max_notes_count")
59 assert cmd2[idx_notes + 1] == "50"
60
61 assert "--max_comments_count_singlenotes" in cmd2
62 idx_comments = cmd2.index("--max_comments_count_singlenotes")
63 assert cmd2[idx_comments + 1] == "5"
64
65def test_api_start_crawler_with_limits():
66 client = TestClient(app)

Callers

nothing calls this directly

Calls 3

_build_commandMethod · 0.95
CrawlerManagerClass · 0.90
CrawlerStartRequestClass · 0.90

Tested by

no test coverage detected