Commit bc79d780 authored by Thomas Gambier's avatar Thomas Gambier

slapgrid: compare os name in lower case

When comparing OS to see if they match for binary cache, we only compare
the lower case distribution name because sometimes "Debian' is
capitalized and sometimes not.
parent ee941d0e
......@@ -58,8 +58,7 @@ def _debianize(os_):
distname_lower = distname.lower()
if distname_lower == 'debian' and '.' in version:
version = version.split('.')[0]
distname = distname_lower
return distname, version, id_
return distname_lower, version, id_
def os_matches(os1, os2):
......
......@@ -35,17 +35,18 @@ class TestDebianize(unittest.TestCase):
def test_debian_major(self):
"""
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 [
(('CentOS', '6.3', 'Final'), None),
(('Ubuntu', '12.04', 'precise'), None),
(('Ubuntu', '13.04', 'raring'), None),
(('Fedora', '17', 'Beefy Miracle'), None),
(('CentOS', '6.3', 'Final'), ('centos', '6.3', 'Final')),
(('Ubuntu', '12.04', 'precise'), ('ubuntu', '12.04', 'precise')),
(('Ubuntu', '13.04', 'raring'), ('ubuntu', '13.04', 'raring')),
(('Fedora', '17', 'Beefy Miracle'), ('fedora', '17', 'Beefy Miracle')),
(('debian', '6.0.6', ''), ('debian', '6', '')),
(('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):
......@@ -70,3 +71,5 @@ class TestOSMatches(unittest.TestCase):
('debian', '6.0.5', '')))
self.assertTrue(distribution.os_matches(('debian', '6.0.6', ''),
('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