Skip to content

Commit

Permalink
When identifying a macOS or Windows platform, do not include the version
Browse files Browse the repository at this point in the history
  • Loading branch information
ataylor32 committed May 22, 2024
1 parent 6fc87ce commit bf0d675
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 47 deletions.
68 changes: 34 additions & 34 deletions tests/test_template_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,46 +49,46 @@ def test_locations(self):
class PlatformTemplateFilterTest(TestCase):
def test_windows(self):
# Generic Windows
self.assertEqual("Windows XP", platform("NT 5.1 not a real browser/10.3"))
self.assertEqual("Windows Vista", platform("NT 6.0 not a real browser/10.3"))
self.assertEqual("Windows 7", platform("NT 6.1 not a real browser/10.3"))
self.assertEqual("Windows 8", platform("NT 6.2 not a real browser/10.3"))
self.assertEqual("Windows 8.1", platform("NT 6.3 not a real browser/10.3"))
self.assertEqual("Windows", platform("Windows NT 5.1 not a real browser/10.3"))
self.assertEqual("Windows", platform("Windows NT 6.0 not a real browser/10.3"))
self.assertEqual("Windows", platform("Windows NT 6.1 not a real browser/10.3"))
self.assertEqual("Windows", platform("Windows NT 6.2 not a real browser/10.3"))
self.assertEqual("Windows", platform("Windows NT 6.3 not a real browser/10.3"))
self.assertEqual("Windows", platform("Windows not a real browser/10.3"))

# IE
self.assertEqual(
'Windows XP',
'Windows',
platform('Mozilla/4.0 (Windows; MSIE 6.0; Windows NT 5.1; SV1; '
'.NET CLR 2.0.50727)')
)
self.assertEqual(
'Windows Vista',
'Windows',
platform('Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; '
'Trident/4.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 1.1.4322;'
' InfoPath.2; .NET CLR 3.5.21022; .NET CLR 3.5.30729; '
'MS-RTC LM 8; OfficeLiveConnector.1.4; OfficeLivePatch.1.3;'
' .NET CLR 3.0.30729)')
)
self.assertEqual(
'Windows 7',
'Windows',
platform('Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; '
'Trident/6.0)')
)
self.assertEqual(
'Windows 8',
'Windows',
platform('Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; '
'Win64; x64; Trident/6.0)')
)
self.assertEqual(
'Windows 8.1',
'Windows',
platform('Mozilla/5.0 (IE 11.0; Windows NT 6.3; Trident/7.0; '
'.NET4.0E; .NET4.0C; rv:11.0) like Gecko')
)

# Edge
self.assertEqual(
'Windows 10',
'Windows',
platform('Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, '
'like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10136')
)
Expand All @@ -101,22 +101,22 @@ def test_windows(self):

# Edge Chromium
self.assertEqual(
'Windows 10',
'Windows',
platform('Mozilla/5.0 (Windows NT 10.0; Win64; x64) '
'AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.113 '
'Safari/537.36 Edg/81.0.416.62')
)

# Firefox
self.assertEqual(
'Windows 7',
'Windows',
platform('Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:22.0) '
'Gecko/20130328 Firefox/22.0')
)

# Chrome
self.assertEqual(
'Windows 8.1',
'Windows',
platform('Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 ('
'KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36')
)
Expand All @@ -143,13 +143,13 @@ def test_apple(self):
)

self.assertEqual(
'macOS Mojave',
'macOS',
platform('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) '
'AppleWebKit/537.36 (KHTML, like Gecko) '
'Chrome/85.0.4178.0 Safari/537.36')
)
self.assertEqual(
'macOS Catalina',
'macOS',
platform('Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:77.0) '
'Gecko/20100101 Firefox/77.0')
)
Expand All @@ -162,7 +162,7 @@ def test_apple(self):

# Edge Chromium
self.assertEqual(
'macOS Catalina',
'macOS',
platform('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) '
'AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 '
'Safari/537.36 Edg/85.0.564.51')
Expand Down Expand Up @@ -319,30 +319,30 @@ def test_android(self):
class DeviceTemplateFilterTest(TestCase):
def test_ie(self):
self.assertEqual(
'Internet Explorer on Windows XP',
'Internet Explorer on Windows',
device('Mozilla/4.0 (Windows; MSIE 6.0; Windows NT 5.1; SV1; '
'.NET CLR 2.0.50727)')
)
self.assertEqual(
'Internet Explorer on Windows Vista',
'Internet Explorer on Windows',
device('Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; '
'Trident/4.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 1.1.4322;'
' InfoPath.2; .NET CLR 3.5.21022; .NET CLR 3.5.30729; '
'MS-RTC LM 8; OfficeLiveConnector.1.4; OfficeLivePatch.1.3;'
' .NET CLR 3.0.30729)')
)
self.assertEqual(
'Internet Explorer on Windows 7',
'Internet Explorer on Windows',
device('Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; '
'Trident/6.0)')
)
self.assertEqual(
'Internet Explorer on Windows 8',
'Internet Explorer on Windows',
device('Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; '
'Win64; x64; Trident/6.0)')
)
self.assertEqual(
'Internet Explorer on Windows 8.1',
'Internet Explorer on Windows',
device('Mozilla/5.0 (IE 11.0; Windows NT 6.3; Trident/7.0; '
'.NET4.0E; .NET4.0C; rv:11.0) like Gecko')
)
Expand All @@ -361,13 +361,13 @@ def test_apple(self):
'Mobile/11A465 Safari/9537.53')
)
self.assertEqual(
'Chrome on macOS Mojave',
'Chrome on macOS',
device('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) '
'AppleWebKit/537.36 (KHTML, like Gecko) '
'Chrome/85.0.4178.0 Safari/537.36')
)
self.assertEqual(
'Firefox on macOS Catalina',
'Firefox on macOS',
device('Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:77.0) '
'Gecko/20100101 Firefox/77.0')
)
Expand All @@ -389,21 +389,21 @@ def test_android(self):

def test_firefox(self):
self.assertEqual(
'Firefox on Windows 7',
'Firefox on Windows',
device('Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:22.0) '
'Gecko/20130328 Firefox/22.0')
)

def test_chrome(self):
self.assertEqual(
'Chrome on Windows 8.1',
'Chrome on Windows',
device('Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 ('
'KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36')
)

def test_edge(self):
self.assertEqual(
'Edge on Windows 10',
'Edge on Windows',
device('Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, '
'like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10136')
)
Expand All @@ -416,13 +416,13 @@ def test_edge(self):

def test_edge_chromium(self):
self.assertEqual(
'Edge on Windows 10',
'Edge on Windows',
device('Mozilla/5.0 (Windows NT 10.0; Win64; x64) '
'AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.113 '
'Safari/537.36 Edg/81.0.416.62')
)
self.assertEqual(
'Edge on macOS Catalina',
'Edge on macOS',
device('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) '
'AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 '
'Safari/537.36 Edg/85.0.564.51')
Expand Down Expand Up @@ -453,19 +453,19 @@ def test_iphone_only(self):
self.assertEqual("iPhone", device("iPhone not a real browser/10.3"))

def test_windowsxp_only(self):
self.assertEqual("Windows XP", device("NT 5.1 not a real browser/10.3"))
self.assertEqual("Windows", device("Windows NT 5.1 not a real browser/10.3"))

def test_windowsvista_only(self):
self.assertEqual("Windows Vista", device("NT 6.0 not a real browser/10.3"))
self.assertEqual("Windows", device("Windows NT 6.0 not a real browser/10.3"))

def test_windows7_only(self):
self.assertEqual("Windows 7", device("NT 6.1 not a real browser/10.3"))
self.assertEqual("Windows", device("Windows NT 6.1 not a real browser/10.3"))

def test_windows8_only(self):
self.assertEqual("Windows 8", device("NT 6.2 not a real browser/10.3"))
self.assertEqual("Windows", device("Windows NT 6.2 not a real browser/10.3"))

def test_windows81_only(self):
self.assertEqual("Windows 8.1", device("NT 6.3 not a real browser/10.3"))
self.assertEqual("Windows", device("Windows NT 6.3 not a real browser/10.3"))

def test_windows_only(self):
self.assertEqual("Windows", device("Windows not a real browser/10.3"))
13 changes: 0 additions & 13 deletions user_sessions/templatetags/user_sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,7 @@
(re.compile('Linux'), _('Linux')),
(re.compile('iPhone'), _('iPhone')),
(re.compile('iPad'), _('iPad')),
(re.compile('Mac OS X 10[._]9'), _('OS X Mavericks')),
(re.compile('Mac OS X 10[._]10'), _('OS X Yosemite')),
(re.compile('Mac OS X 10[._]11'), _('OS X El Capitan')),
(re.compile('Mac OS X 10[._]12'), _('macOS Sierra')),
(re.compile('Mac OS X 10[._]13'), _('macOS High Sierra')),
(re.compile('Mac OS X 10[._]14'), _('macOS Mojave')),
(re.compile('Mac OS X 10[._]15'), _('macOS Catalina')),
(re.compile('Mac OS X'), _('macOS')),
(re.compile('NT 5.1'), _('Windows XP')),
(re.compile('NT 6.0'), _('Windows Vista')),
(re.compile('NT 6.1'), _('Windows 7')),
(re.compile('NT 6.2'), _('Windows 8')),
(re.compile('NT 6.3'), _('Windows 8.1')),
(re.compile('NT 10.0'), _('Windows 10')),
(re.compile('Windows'), _('Windows')),
)

Expand Down

0 comments on commit bf0d675

Please sign in to comment.