From: Andrey Bychkov Date: Tue, 18 Dec 2018 07:01:51 +0000 (+0300) Subject: Tests altlinux platform for pull request #472 X-Git-Tag: v2.1.0~24^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F475%2Fhead;p=ceph-deploy.git Tests altlinux platform for pull request #472 --- diff --git a/ceph_deploy/tests/test_remotes.py b/ceph_deploy/tests/test_remotes.py index 4378ab7..4c7ac03 100644 --- a/ceph_deploy/tests/test_remotes.py +++ b/ceph_deploy/tests/test_remotes.py @@ -234,3 +234,22 @@ UBUNTU_CODENAME=xenial assert distro == 'ubuntu' assert release == '16.04' assert codename == 'xenial' + + def test_handles_alt_8_2(self, tmpdir): + path = str(tmpdir.join('os_release')) + with open(path, 'w') as os_release: + os_release.write(""" +NAME="ALT" +VERSION="8.2 " +ID=altlinux +VERSION_ID=8.2 +PRETTY_NAME="ALT Workstation K 8.2 (Centaurea Ruthenica)" +ANSI_COLOR="1;33" +CPE_NAME="cpe:/o:alt:kworkstation:8.2" +HOME_URL="http://www.basealt.ru" +BUG_REPORT_URL="https://bugs.altlinux.org/" +""") + distro, release, codename = parse_os_release(path) + assert distro == 'altlinux' + assert release == '8.2' + assert codename == '8.2' diff --git a/ceph_deploy/tests/unit/hosts/test_altlinux.py b/ceph_deploy/tests/unit/hosts/test_altlinux.py new file mode 100644 index 0000000..d24dfc2 --- /dev/null +++ b/ceph_deploy/tests/unit/hosts/test_altlinux.py @@ -0,0 +1,11 @@ +from ceph_deploy.hosts.alt.install import map_components, NON_SPLIT_PACKAGES + + +class TestALTMapComponents(object): + def test_valid(self): + pkgs = map_components(NON_SPLIT_PACKAGES, ['ceph-osd', 'ceph-common', 'ceph-radosgw']) + print(pkgs) + assert 'ceph' in pkgs + assert 'ceph-common' in pkgs + assert 'ceph-radosgw' in pkgs + assert 'ceph-osd' not in pkgs diff --git a/ceph_deploy/tests/unit/hosts/test_hosts.py b/ceph_deploy/tests/unit/hosts/test_hosts.py index 60e98b7..dbc448c 100644 --- a/ceph_deploy/tests/unit/hosts/test_hosts.py +++ b/ceph_deploy/tests/unit/hosts/test_hosts.py @@ -427,3 +427,7 @@ class TestGetDistro(object): def test_get_arch(self): result = hosts._get_distro('Arch Linux') assert result.__name__.endswith('arch') + + def test_get_altlinux(self): + result = hosts._get_distro('ALT Linux') + assert result.__name__.endswith('alt') diff --git a/ceph_deploy/tests/unit/util/test_pkg_managers.py b/ceph_deploy/tests/unit/util/test_pkg_managers.py index 1e4cedc..5f06ad0 100644 --- a/ceph_deploy/tests/unit/util/test_pkg_managers.py +++ b/ceph_deploy/tests/unit/util/test_pkg_managers.py @@ -154,3 +154,42 @@ class TestDNF(object): pkg_managers.DNF(Mock()).remove(['vim', 'zsh']) result = fake_run.call_args_list[-1] assert 'remove' in result[0][-1] + + +class TestAtpRpm(object): + + def setup(self): + self.to_patch = 'ceph_deploy.util.pkg_managers.remoto.process.run' + + def test_install_single_package(self): + fake_run = Mock() + with patch(self.to_patch, fake_run): + pkg_managers.AptRpm(Mock()).install('vim') + result = fake_run.call_args_list[-1] + assert 'install' in result[0][-1] + assert result[0][-1][-1] == 'vim' + + def test_install_multiple_packages(self): + fake_run = Mock() + with patch(self.to_patch, fake_run): + pkg_managers.AptRpm(Mock()).install(['vim', 'zsh']) + result = fake_run.call_args_list[-1] + assert 'install' in result[0][-1] + assert result[0][-1][-2:] == ['vim', 'zsh'] + + def test_remove_single_package(self): + fake_run = Mock() + with patch(self.to_patch, fake_run): + pkg_managers.AptRpm(Mock()).remove('vim') + result = fake_run.call_args_list[-1] + assert 'remove' in result[0][-1] + assert result[0][-1][-1] == 'vim' + + def test_remove_multiple_packages(self): + fake_run = Mock() + with patch(self.to_patch, fake_run): + pkg_managers.AptRpm(Mock()).remove(['vim', 'zsh']) + result = fake_run.call_args_list[-1] + assert 'remove' in result[0][-1] + assert result[0][-1][-2:] == ['vim', 'zsh'] +