Skip to content

Commit a71680c

Browse files
author
Derrick Petzold
committed
Added test.
1 parent 3dede6f commit a71680c

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

‎user_agents/tests.py‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# flake8: noqa
2+
13
import unittest
24

35
from ua_parser import user_agent_parser
@@ -25,6 +27,7 @@
2527
google_bot_ua_string = 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)'
2628
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'
2729
android_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

2932
iphone_ua = parse(iphone_ua_string)
3033
ipad_ua = parse(ipad_ua_string)
@@ -47,6 +50,7 @@
4750
google_bot_ua = parse(google_bot_ua_string)
4851
nokia_n97_ua = parse(nokia_n97_ua_string)
4952
android_firefox_aurora_ua = parse(android_firefox_aurora_ua_string)
53+
samsung_galaxy_s_ua = parse(samsung_galaxy_s_ua_string)
5054

5155

5256
class 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

Comments
 (0)