From 94bd2b47578bf6423b41a913d846ab07d54889ac Mon Sep 17 00:00:00 2001 From: Yuya Takeyama Date: Sun, 1 Mar 2015 20:20:15 +0900 Subject: [PATCH 1/4] Update testset --- woothee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/woothee b/woothee index 61766c8..a03d10a 160000 --- a/woothee +++ b/woothee @@ -1 +1 @@ -Subproject commit 61766c87f52a1fd866509b06a55b93186b5c4921 +Subproject commit a03d10a77d5aaea9b8e5a0a3ba5accaa71720d78 From d62397234812d070dac1fa6c10b84c2189cd0f3c Mon Sep 17 00:00:00 2001 From: Yuya Takeyama Date: Sun, 1 Mar 2015 20:21:07 +0900 Subject: [PATCH 2/4] Add blank case tests blank cases are now included in blank.yml --- tests/test.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/tests/test.py b/tests/test.py index 4d3022c..92c8934 100644 --- a/tests/test.py +++ b/tests/test.py @@ -31,6 +31,7 @@ ['pc_lowpriority.yaml', 'PC/LowPriority'], ['misc.yaml', 'Misc'], ['crawler_nonmajor.yaml', 'Crawler/NonMajor'], + ['blank.yaml', 'Blank'], ] @@ -101,16 +102,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", @@ -268,6 +259,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" From 6ae102da31b91a3197bdcfb6f8d47f2c4ebace4c Mon Sep 17 00:00:00 2001 From: Yuya Takeyama Date: Sun, 1 Mar 2015 20:21:57 +0900 Subject: [PATCH 3/4] Check None value --- lib/woothee/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/woothee/__init__.py b/lib/woothee/__init__.py index 600e7b9..eb4a6bc 100644 --- a/lib/woothee/__init__.py +++ b/lib/woothee/__init__.py @@ -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): From 8b6aba5b011b7f33069575ec14adb507bcc9e10d Mon Sep 17 00:00:00 2001 From: Yuya Takeyama Date: Sun, 1 Mar 2015 20:41:31 +0900 Subject: [PATCH 4/4] Fix for flake8 tests/test.py:13:1: E402 module level import not at top of file --- tests/test.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/test.py b/tests/test.py index 92c8934..a7eba44 100644 --- a/tests/test.py +++ b/tests/test.py @@ -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 = [