Skip to content

Commit 82bf41a

Browse files
committed
Merge pull request #9 from woothee/test_blank_cases
Test blank cases
2 parents bef50ee + 8b6aba5 commit 82bf41a

File tree

3 files changed

+6
-16
lines changed

3 files changed

+6
-16
lines changed

lib/woothee/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ def parse(useragent):
2828

2929

3030
def is_crawler(useragent):
31-
return len(useragent) > 0 and useragent != '-'\
31+
return useragent is not None and len(useragent) > 0 and useragent != '-'\
3232
and try_crawler(useragent, {})
3333

3434

3535
def exec_parse(useragent):
3636
result = {}
3737

38-
if len(useragent) < 1 or useragent == '-':
38+
if useragent is None or len(useragent) < 1 or useragent == '-':
3939
return result
4040

4141
if try_crawler(useragent, result):

tests/test.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@
66
import os
77
import sys
88
import unittest
9+
import yaml
910

1011
BASE_PATH = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
1112
sys.path.insert(0, os.path.join(BASE_PATH, 'lib'))
12-
13-
import yaml
14-
1513
TESTSET_DIR = os.path.join(BASE_PATH, 'woothee', 'testsets')
1614

1715
TARGETS = [
@@ -31,6 +29,7 @@
3129
['pc_lowpriority.yaml', 'PC/LowPriority'],
3230
['misc.yaml', 'Misc'],
3331
['crawler_nonmajor.yaml', 'Crawler/NonMajor'],
32+
['blank.yaml', 'Blank'],
3433
]
3534

3635

@@ -101,16 +100,6 @@ def test_non_provide_testsets(self):
101100

102101
import woothee
103102

104-
# 33 line lib/woothee/__init__.py
105-
self.assertEqual({
106-
"name": "UNKNOWN",
107-
"version": "UNKNOWN",
108-
"os": "UNKNOWN",
109-
"os_version": "UNKNOWN",
110-
"category": "UNKNOWN",
111-
"vendor": "UNKNOWN",
112-
}, woothee.parse(""))
113-
114103
# 48 line in lib/woothee/appliance.py
115104
self.assertEqual({
116105
"name": "Nintendo DSi",
@@ -268,6 +257,7 @@ def _callFUT(self, *args, **kwargs):
268257
def test_false(self):
269258
self.assertFalse(self._callFUT(""))
270259
self.assertFalse(self._callFUT("-"))
260+
self.assertFalse(self._callFUT(None))
271261
self.assertFalse(self._callFUT(
272262
"Mozilla/5.0 (Windows NT 6.3; "
273263
"Trident/7.0; rv:11.0) like Gecko"

woothee

0 commit comments

Comments
 (0)