Commit f8e83af8 authored by Thomas Gambier's avatar Thomas Gambier 🚴🏼

slapgrid: compare os name in lower case

See merge request !268
parents 0b7eff7b bc79d780
...@@ -58,8 +58,7 @@ def _debianize(os_): ...@@ -58,8 +58,7 @@ def _debianize(os_):
distname_lower = distname.lower() distname_lower = distname.lower()
if distname_lower == 'debian' and '.' in version: if distname_lower == 'debian' and '.' in version:
version = version.split('.')[0] version = version.split('.')[0]
distname = distname_lower return distname_lower, version, id_
return distname, version, id_
def os_matches(os1, os2): def os_matches(os1, os2):
......
...@@ -35,17 +35,18 @@ class TestDebianize(unittest.TestCase): ...@@ -35,17 +35,18 @@ class TestDebianize(unittest.TestCase):
def test_debian_major(self): def test_debian_major(self):
""" """
On debian, we only care about major release. On debian, we only care about major release.
All the other tuples are unchanged. All the other tuples are unchanged (except distribution name which is lower case).
""" """
for provided, expected in [ for provided, expected in [
(('CentOS', '6.3', 'Final'), None), (('CentOS', '6.3', 'Final'), ('centos', '6.3', 'Final')),
(('Ubuntu', '12.04', 'precise'), None), (('Ubuntu', '12.04', 'precise'), ('ubuntu', '12.04', 'precise')),
(('Ubuntu', '13.04', 'raring'), None), (('Ubuntu', '13.04', 'raring'), ('ubuntu', '13.04', 'raring')),
(('Fedora', '17', 'Beefy Miracle'), None), (('Fedora', '17', 'Beefy Miracle'), ('fedora', '17', 'Beefy Miracle')),
(('debian', '6.0.6', ''), ('debian', '6', '')), (('debian', '6.0.6', ''), ('debian', '6', '')),
(('debian', '7.0', ''), ('debian', '7', '')), (('debian', '7.0', ''), ('debian', '7', '')),
(('Debian', '8.11', ''), ('debian', '8', '')),
]: ]:
self.assertEqual(distribution._debianize(provided), expected or provided) self.assertEqual(distribution._debianize(provided), expected)
class TestOSMatches(unittest.TestCase): class TestOSMatches(unittest.TestCase):
...@@ -70,3 +71,5 @@ class TestOSMatches(unittest.TestCase): ...@@ -70,3 +71,5 @@ class TestOSMatches(unittest.TestCase):
('debian', '6.0.5', ''))) ('debian', '6.0.5', '')))
self.assertTrue(distribution.os_matches(('debian', '6.0.6', ''), self.assertTrue(distribution.os_matches(('debian', '6.0.6', ''),
('debian', '6.1', ''))) ('debian', '6.1', '')))
self.assertTrue(distribution.os_matches(('Debian', '8.11', ''),
('debian', '8.4', '')))
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment