-
Notifications
You must be signed in to change notification settings - Fork 569
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(refactor): Move get_crawl_args function to caller
- Loading branch information
1 parent
2179bea
commit a059e83
Showing
3 changed files
with
43 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from scrapyd.launcher import get_crawl_args | ||
|
||
|
||
def test_get_crawl_args(): | ||
msg = {"_project": "lolo", "_spider": "lala"} | ||
|
||
assert get_crawl_args(msg) == ["lala"] | ||
|
||
msg = {"_project": "lolo", "_spider": "lala", "arg1": "val1"} | ||
cargs = get_crawl_args(msg) | ||
|
||
assert cargs == ["lala", "-a", "arg1=val1"] | ||
assert all(isinstance(x, str) for x in cargs), cargs | ||
|
||
|
||
def test_get_crawl_args_with_settings(): | ||
msg = {"_project": "lolo", "_spider": "lala", "arg1": "val1", "settings": {"ONE": "two"}} | ||
cargs = get_crawl_args(msg) | ||
|
||
assert cargs == ["lala", "-a", "arg1=val1", "-s", "ONE=two"] | ||
assert all(isinstance(x, str) for x in cargs), cargs |