22
22
mac_safari_ua_string = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.13+ (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2'
23
23
windows_ie_ua_string = 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)'
24
24
ubuntu_firefox_ua_string = 'Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:15.0) Gecko/20100101 Firefox/15.0.1'
25
+ google_bot_ua_string = 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)'
26
+ nokia_n97_ua_string = 'Mozilla/5.0 (SymbianOS/9.4; Series60/5.0 NokiaN97-1/12.0.024; Profile/MIDP-2.1 Configuration/CLDC-1.1; en-us) AppleWebKit/525 (KHTML, like Gecko) BrowserNG/7.1.12344'
25
27
26
28
iphone_ua = parse (iphone_ua_string )
27
29
ipad_ua = parse (ipad_ua_string )
41
43
mac_safari_ua = parse (mac_safari_ua_string )
42
44
windows_ie_ua = parse (windows_ie_ua_string )
43
45
ubuntu_firefox_ua = parse (ubuntu_firefox_ua_string )
46
+ google_bot_ua = parse (google_bot_ua_string )
47
+ nokia_n97_ua = parse (nokia_n97_ua_string )
44
48
45
49
46
50
class UserAgentsTest (unittest .TestCase ):
@@ -79,6 +83,8 @@ def test_is_tablet_property(self):
79
83
self .assertFalse (windows_ie_ua .is_tablet )
80
84
self .assertFalse (ubuntu_firefox_ua .is_tablet )
81
85
self .assertFalse (j2me_opera_ua .is_tablet )
86
+ self .assertFalse (google_bot_ua .is_tablet )
87
+ self .assertFalse (nokia_n97_ua .is_tablet )
82
88
self .assertTrue (windows_rt_ua .is_tablet )
83
89
self .assertTrue (ipad_ua .is_tablet )
84
90
self .assertTrue (playbook_ua .is_tablet )
@@ -92,6 +98,7 @@ def test_is_mobile_property(self):
92
98
self .assertTrue (blackberry_bold_ua .is_mobile )
93
99
self .assertTrue (windows_phone_ua .is_mobile )
94
100
self .assertTrue (j2me_opera_ua .is_mobile )
101
+ self .assertTrue (nokia_n97_ua .is_mobile )
95
102
self .assertFalse (windows_rt_ua .is_mobile )
96
103
self .assertFalse (ipad_ua .is_mobile )
97
104
self .assertFalse (playbook_ua .is_mobile )
@@ -102,6 +109,7 @@ def test_is_mobile_property(self):
102
109
self .assertFalse (mac_safari_ua .is_mobile )
103
110
self .assertFalse (windows_ie_ua .is_mobile )
104
111
self .assertFalse (ubuntu_firefox_ua .is_mobile )
112
+ self .assertFalse (google_bot_ua .is_mobile )
105
113
106
114
def test_is_touch_property (self ):
107
115
self .assertTrue (iphone_ua .is_touch_capable )
@@ -120,6 +128,8 @@ def test_is_touch_property(self):
120
128
self .assertFalse (mac_safari_ua .is_touch_capable )
121
129
self .assertFalse (windows_ie_ua .is_touch_capable )
122
130
self .assertFalse (ubuntu_firefox_ua .is_touch_capable )
131
+ self .assertFalse (google_bot_ua .is_touch_capable )
132
+ self .assertFalse (nokia_n97_ua .is_touch_capable )
123
133
124
134
def test_is_pc (self ):
125
135
self .assertFalse (iphone_ua .is_pc )
@@ -133,8 +143,30 @@ def test_is_pc(self):
133
143
self .assertFalse (blackberry_torch_ua .is_pc )
134
144
self .assertFalse (blackberry_bold_ua .is_pc )
135
145
self .assertFalse (j2me_opera_ua .is_pc )
146
+ self .assertFalse (google_bot_ua .is_pc )
147
+ self .assertFalse (nokia_n97_ua .is_pc )
136
148
self .assertTrue (mac_safari_ua .is_pc )
137
149
self .assertTrue (windows_ie_ua .is_pc )
138
150
self .assertTrue (ubuntu_firefox_ua .is_pc )
139
151
self .assertTrue (ie_touch_ua .is_pc )
140
152
self .assertTrue (ie_ua .is_pc )
153
+
154
+ def test_is_spider (self ):
155
+ self .assertTrue (google_bot_ua .is_spider )
156
+ self .assertFalse (iphone_ua .is_spider )
157
+ self .assertFalse (galaxy_s3_ua .is_spider )
158
+ self .assertFalse (ipad_ua .is_spider )
159
+ self .assertFalse (playbook_ua .is_spider )
160
+ self .assertFalse (kindle_fire_ua .is_spider )
161
+ self .assertFalse (nexus_7_ua .is_spider )
162
+ self .assertFalse (windows_phone_ua .is_spider )
163
+ self .assertFalse (blackberry_bold_touch_ua .is_spider )
164
+ self .assertFalse (blackberry_torch_ua .is_spider )
165
+ self .assertFalse (blackberry_bold_ua .is_spider )
166
+ self .assertFalse (j2me_opera_ua .is_spider )
167
+ self .assertFalse (mac_safari_ua .is_spider )
168
+ self .assertFalse (windows_ie_ua .is_spider )
169
+ self .assertFalse (ubuntu_firefox_ua .is_spider )
170
+ self .assertFalse (ie_touch_ua .is_spider )
171
+ self .assertFalse (ie_ua .is_spider )
172
+ self .assertFalse (nokia_n97_ua .is_spider )
0 commit comments