1+ # flake8: noqa
2+
13import unittest
24
35from ua_parser import user_agent_parser
2527google_bot_ua_string = 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)'
2628nokia_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'
2729android_firefox_aurora_ua_string = 'Mozilla/5.0 (Android; Mobile; rv:27.0) Gecko/27.0 Firefox/27.0'
30+ samsung_galaxy_s_ua_string = 'Mozilla/5.0 (Linux; Android 4.4.2; en-us; SAMSUNG SCH-I545 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Version/1.5 Chrome/28.0.1500.94 Mobile Safari/537.36'
2831
2932iphone_ua = parse (iphone_ua_string )
3033ipad_ua = parse (ipad_ua_string )
4750google_bot_ua = parse (google_bot_ua_string )
4851nokia_n97_ua = parse (nokia_n97_ua_string )
4952android_firefox_aurora_ua = parse (android_firefox_aurora_ua_string )
53+ samsung_galaxy_s_ua = parse (samsung_galaxy_s_ua_string )
5054
5155
5256class UserAgentsTest (unittest .TestCase ):
@@ -61,7 +65,7 @@ def test_user_agent_object_assignments(self):
6165 iphone_ua .browser .version ,
6266 (int (ua_dict ['user_agent' ]['major' ]), int (ua_dict ['user_agent' ]['minor' ]))
6367 )
64-
68+
6569 # Ensure os attributes are assigned correctly
6670 self .assertEqual (iphone_ua .os .family , ua_dict ['os' ]['family' ])
6771 self .assertEqual (
@@ -93,6 +97,7 @@ def test_is_tablet_property(self):
9397 self .assertTrue (kindle_fire_ua .is_tablet )
9498 self .assertTrue (nexus_7_ua .is_tablet )
9599 self .assertFalse (android_firefox_aurora_ua .is_tablet )
100+ self .assertFalse (samsung_galaxy_s_ua .is_tablet )
96101
97102 def test_is_mobile_property (self ):
98103 self .assertTrue (iphone_ua .is_mobile )
@@ -114,6 +119,7 @@ def test_is_mobile_property(self):
114119 self .assertFalse (ubuntu_firefox_ua .is_mobile )
115120 self .assertFalse (google_bot_ua .is_mobile )
116121 self .assertTrue (android_firefox_aurora_ua .is_mobile )
122+ self .assertTrue (samsung_galaxy_s_ua .is_mobile )
117123
118124 def test_is_touch_property (self ):
119125 self .assertTrue (iphone_ua .is_touch_capable )
@@ -135,6 +141,7 @@ def test_is_touch_property(self):
135141 self .assertFalse (google_bot_ua .is_touch_capable )
136142 self .assertFalse (nokia_n97_ua .is_touch_capable )
137143 self .assertTrue (android_firefox_aurora_ua .is_touch_capable )
144+ self .assertTrue (samsung_galaxy_s_ua .is_touch_capable )
138145
139146 def test_is_pc (self ):
140147 self .assertFalse (iphone_ua .is_pc )
@@ -156,6 +163,7 @@ def test_is_pc(self):
156163 self .assertTrue (ie_touch_ua .is_pc )
157164 self .assertTrue (ie_ua .is_pc )
158165 self .assertFalse (android_firefox_aurora_ua .is_pc )
166+ self .assertFalse (samsung_galaxy_s_ua .is_pc )
159167
160168 def test_is_bot (self ):
161169 self .assertTrue (google_bot_ua .is_bot )
@@ -177,6 +185,7 @@ def test_is_bot(self):
177185 self .assertFalse (ie_ua .is_bot )
178186 self .assertFalse (nokia_n97_ua .is_bot )
179187 self .assertFalse (android_firefox_aurora_ua .is_bot )
188+ self .assertFalse (samsung_galaxy_s_ua .is_bot )
180189
181190 def test_strings (self ):
182191 self .assertEqual (str (iphone_ua ), "iPhone / iOS 5.1 / Mobile Safari 5.1" )
0 commit comments