-
-
Notifications
You must be signed in to change notification settings - Fork 253
/
test_harness.py
39 lines (25 loc) · 881 Bytes
/
test_harness.py
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
"""
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