-
-
Notifications
You must be signed in to change notification settings - Fork 253
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
93 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
.cache | ||
__pycache__ | ||
/vendor/ | ||
/env/ | ||
*.egg-info/ |
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
This file was deleted.
Oops, something went wrong.
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,39 @@ | ||
""" | ||
Simple tests for python harness | ||
Usage: | ||
$ pytest test_harness.py | ||
""" | ||
from crawleruseragents import is_crawler, matching_crawlers | ||
|
||
|
||
def test_match(): | ||
assert is_crawler("test Googlebot/2.0 test") is True | ||
|
||
|
||
def test_nomatch(): | ||
assert is_crawler("!!!!!!!!!!!!") is False | ||
|
||
|
||
def test_case(): | ||
assert is_crawler("test googlebot/2.0 test") is False | ||
|
||
|
||
def test_matching_crawlers_match(): | ||
result = matching_crawlers("test Googlebot/2.0 test") | ||
assert isinstance(result, list) | ||
assert len(result) > 0 | ||
assert all(isinstance(val, int) for val in result) | ||
|
||
|
||
def test_matching_crawlers_nomatch(): | ||
result = matching_crawlers("!!!!!!!!!!!!") | ||
assert isinstance(result, list) | ||
assert len(result) == 0 | ||
|
||
|
||
def test_matching_crawlers_case(): | ||
result = matching_crawlers("test googlebot/2.0 test") | ||
assert isinstance(result, list) | ||
assert len(result) == 0 |