Skip to content

Test blank cases #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 1, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/woothee/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ def parse(useragent):


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


def exec_parse(useragent):
result = {}

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

if try_crawler(useragent, result):
Expand Down
16 changes: 3 additions & 13 deletions tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@
import os
import sys
import unittest
import yaml

BASE_PATH = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, os.path.join(BASE_PATH, 'lib'))

import yaml

TESTSET_DIR = os.path.join(BASE_PATH, 'woothee', 'testsets')

TARGETS = [
Expand All @@ -31,6 +29,7 @@
['pc_lowpriority.yaml', 'PC/LowPriority'],
['misc.yaml', 'Misc'],
['crawler_nonmajor.yaml', 'Crawler/NonMajor'],
['blank.yaml', 'Blank'],
]


Expand Down Expand Up @@ -101,16 +100,6 @@ def test_non_provide_testsets(self):

import woothee

# 33 line lib/woothee/__init__.py
self.assertEqual({
"name": "UNKNOWN",
"version": "UNKNOWN",
"os": "UNKNOWN",
"os_version": "UNKNOWN",
"category": "UNKNOWN",
"vendor": "UNKNOWN",
}, woothee.parse(""))

# 48 line in lib/woothee/appliance.py
self.assertEqual({
"name": "Nintendo DSi",
Expand Down Expand Up @@ -268,6 +257,7 @@ def _callFUT(self, *args, **kwargs):
def test_false(self):
self.assertFalse(self._callFUT(""))
self.assertFalse(self._callFUT("-"))
self.assertFalse(self._callFUT(None))
self.assertFalse(self._callFUT(
"Mozilla/5.0 (Windows NT 6.3; "
"Trident/7.0; rv:11.0) like Gecko"
Expand Down
2 changes: 1 addition & 1 deletion woothee
Submodule woothee updated 2 files
+2 −0 README.md
+17 −20 testsets/blank.yaml