From 171462aace7857c2cf9faac24b28cc10a7aa60ee Mon Sep 17 00:00:00 2001 From: David Vossel Date: Mon, 30 Jun 2014 16:55:14 -0400 Subject: [PATCH] Add tests for rhel rpm dist detection --- ceph_deploy/hosts/centos/__init__.py | 2 +- ceph_deploy/tests/unit/hosts/test_centos.py | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/ceph_deploy/hosts/centos/__init__.py b/ceph_deploy/hosts/centos/__init__.py index c03ed63..10259ad 100644 --- a/ceph_deploy/hosts/centos/__init__.py +++ b/ceph_deploy/hosts/centos/__init__.py @@ -1,6 +1,6 @@ import mon # noqa import pkg # noqa -from install import install, mirror_install, repo_install, repository_url_part # noqa +from install import install, mirror_install, repo_install, repository_url_part, rpm_dist # noqa from uninstall import uninstall # noqa # Allow to set some information about this distro diff --git a/ceph_deploy/tests/unit/hosts/test_centos.py b/ceph_deploy/tests/unit/hosts/test_centos.py index a7d93a6..afb08f3 100644 --- a/ceph_deploy/tests/unit/hosts/test_centos.py +++ b/ceph_deploy/tests/unit/hosts/test_centos.py @@ -1,8 +1,7 @@ from ceph_deploy.hosts import centos from mock import Mock - -class TestCentosUrlPart(object): +class TestCentosVersionDetection(object): def setup(self): self.distro = Mock() @@ -23,3 +22,18 @@ class TestCentosUrlPart(object): self.distro.normalized_name = 'redhat' self.distro.release = '7.0' assert centos.repository_url_part(self.distro) == 'rhel7' + + def test_rpm_dist_fallsback_to_el6(self): + self.distro.normalized_name = 'redhat' + self.distro.release = '3' + assert centos.rpm_dist(self.distro) == 'el6' + + def test_rpm_dist_detects_rhel6(self): + self.distro.normalized_name = 'redhat' + self.distro.release = '6.6' + assert centos.rpm_dist(self.distro) == 'el6' + + def test_rpm_dist_detects_rhel7(self): + self.distro.normalized_name = 'redhat' + self.distro.release = '7.0' + assert centos.rpm_dist(self.distro) == 'el7' -- 2.47.3