|
@@ -308,11 +308,11 @@ class BaseRedHatMorphingToolsTestCase(test_base.CoriolisBaseTestCase):
|
|
|
|
|
|
|
|
@mock.patch.object(base.BaseLinuxOSMorphingTools, '_exec_cmd_chroot')
|
|
@mock.patch.object(base.BaseLinuxOSMorphingTools, '_exec_cmd_chroot')
|
|
|
def test__yum_install(self, mock_exec_cmd_chroot):
|
|
def test__yum_install(self, mock_exec_cmd_chroot):
|
|
|
- self.morphing_tools._yum_install(self.package_names, self.enable_repos)
|
|
|
|
|
|
|
+ self.morphing_tools._yum_install(self.package_names)
|
|
|
|
|
|
|
|
mock_exec_cmd_chroot.assert_called_once_with(
|
|
mock_exec_cmd_chroot.assert_called_once_with(
|
|
|
"yum install package1 package2 -y "
|
|
"yum install package1 package2 -y "
|
|
|
- "--enablerepo=repo1 --enablerepo=repo2"
|
|
|
|
|
|
|
+ "--setopt=strict=1 --setopt=skip_missing_names_on_install=0"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
@mock.patch.object(base.BaseLinuxOSMorphingTools, '_exec_cmd_chroot')
|
|
@mock.patch.object(base.BaseLinuxOSMorphingTools, '_exec_cmd_chroot')
|
|
@@ -322,7 +322,7 @@ class BaseRedHatMorphingToolsTestCase(test_base.CoriolisBaseTestCase):
|
|
|
self.assertRaises(
|
|
self.assertRaises(
|
|
|
exception.FailedPackageInstallationException,
|
|
exception.FailedPackageInstallationException,
|
|
|
self.morphing_tools._yum_install,
|
|
self.morphing_tools._yum_install,
|
|
|
- self.package_names, self.enable_repos
|
|
|
|
|
|
|
+ self.package_names
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
@mock.patch.object(base.BaseLinuxOSMorphingTools, '_exec_cmd_chroot')
|
|
@mock.patch.object(base.BaseLinuxOSMorphingTools, '_exec_cmd_chroot')
|
|
@@ -366,32 +366,31 @@ class BaseRedHatMorphingToolsTestCase(test_base.CoriolisBaseTestCase):
|
|
|
|
|
|
|
|
mock_exec_cmd_chroot.assert_called_once_with("yum clean all")
|
|
mock_exec_cmd_chroot.assert_called_once_with("yum clean all")
|
|
|
|
|
|
|
|
- @mock.patch.object(base.BaseLinuxOSMorphingTools, '_list_dir')
|
|
|
|
|
- @mock.patch.object(base.BaseLinuxOSMorphingTools, '_read_file_sudo')
|
|
|
|
|
- def test__find_yum_repos_found(self, mock_read_file_sudo, mock_list_dir):
|
|
|
|
|
- mock_list_dir.return_value = ['file1.repo', 'file2.repo']
|
|
|
|
|
- mock_read_file_sudo.return_value = '[repo1]\n[repo2]'
|
|
|
|
|
- repos_to_enable = ['repo1']
|
|
|
|
|
-
|
|
|
|
|
- result = self.morphing_tools._find_yum_repos(repos_to_enable)
|
|
|
|
|
|
|
+ @mock.patch.object(base.BaseLinuxOSMorphingTools, '_exec_cmd_chroot')
|
|
|
|
|
+ def test_enable_repos(self, mock_exec_cmd_chroot):
|
|
|
|
|
+ self.morphing_tools.enable_repos(self.enable_repos)
|
|
|
|
|
|
|
|
- mock_read_file_sudo.assert_has_calls([
|
|
|
|
|
- mock.call('etc/yum.repos.d/file1.repo'),
|
|
|
|
|
- mock.call('etc/yum.repos.d/file2.repo')
|
|
|
|
|
|
|
+ mock_exec_cmd_chroot.assert_has_calls([
|
|
|
|
|
+ mock.call("subscription-manager repos --enable=repo1"),
|
|
|
|
|
+ mock.call("subscription-manager repos --enable=repo2"),
|
|
|
])
|
|
])
|
|
|
|
|
|
|
|
- self.assertEqual(result, ['repo1'])
|
|
|
|
|
|
|
+ @mock.patch.object(base.BaseLinuxOSMorphingTools, '_exec_cmd_chroot')
|
|
|
|
|
+ def test_enable_repos_empty(self, mock_exec_cmd_chroot):
|
|
|
|
|
+ self.morphing_tools.enable_repos([])
|
|
|
|
|
+
|
|
|
|
|
+ mock_exec_cmd_chroot.assert_not_called()
|
|
|
|
|
|
|
|
- @mock.patch.object(base.BaseLinuxOSMorphingTools, '_list_dir')
|
|
|
|
|
- @mock.patch.object(base.BaseLinuxOSMorphingTools, '_read_file_sudo')
|
|
|
|
|
- def test__find_yum_repos_not_found(self, mock_read_file_sudo,
|
|
|
|
|
- mock_list_dir):
|
|
|
|
|
- mock_list_dir.return_value = ['file1.repo', 'file2.repo']
|
|
|
|
|
- mock_read_file_sudo.return_value = '[repo1]\n[repo2]'
|
|
|
|
|
- repos_to_enable = ['repo3']
|
|
|
|
|
|
|
+ @mock.patch.object(base.BaseLinuxOSMorphingTools, '_exec_cmd_chroot')
|
|
|
|
|
+ def test_enable_repos_with_exception(self, mock_exec_cmd_chroot):
|
|
|
|
|
+ mock_exec_cmd_chroot.side_effect = exception.CoriolisException()
|
|
|
|
|
|
|
|
- with self.assertLogs('coriolis.osmorphing.redhat', level=logging.WARN):
|
|
|
|
|
- self.morphing_tools._find_yum_repos(repos_to_enable)
|
|
|
|
|
|
|
+ with self.assertLogs(
|
|
|
|
|
+ 'coriolis.osmorphing.redhat', level=logging.WARN):
|
|
|
|
|
+ self.morphing_tools.enable_repos(['repo1'])
|
|
|
|
|
+
|
|
|
|
|
+ mock_exec_cmd_chroot.assert_called_once_with(
|
|
|
|
|
+ "subscription-manager repos --enable=repo1")
|
|
|
|
|
|
|
|
@mock.patch.object(redhat.BaseRedHatMorphingTools, '_yum_install')
|
|
@mock.patch.object(redhat.BaseRedHatMorphingTools, '_yum_install')
|
|
|
@mock.patch.object(redhat.BaseRedHatMorphingTools, '_yum_clean_all')
|
|
@mock.patch.object(redhat.BaseRedHatMorphingTools, '_yum_clean_all')
|
|
@@ -433,14 +432,16 @@ class BaseRedHatMorphingToolsTestCase(test_base.CoriolisBaseTestCase):
|
|
|
mock_post_packages_install.assert_called_once_with(self.package_names)
|
|
mock_post_packages_install.assert_called_once_with(self.package_names)
|
|
|
|
|
|
|
|
@mock.patch.object(redhat.BaseRedHatMorphingTools, '_yum_install')
|
|
@mock.patch.object(redhat.BaseRedHatMorphingTools, '_yum_install')
|
|
|
|
|
+ @mock.patch.object(redhat.BaseRedHatMorphingTools, 'enable_repos')
|
|
|
@mock.patch.object(redhat.BaseRedHatMorphingTools, '_get_repos_to_enable')
|
|
@mock.patch.object(redhat.BaseRedHatMorphingTools, '_get_repos_to_enable')
|
|
|
def test_install_packages(self, mock_get_repos_to_enable,
|
|
def test_install_packages(self, mock_get_repos_to_enable,
|
|
|
- mock_yum_install):
|
|
|
|
|
|
|
+ mock_enable_repos, mock_yum_install):
|
|
|
self.morphing_tools.install_packages(self.package_names)
|
|
self.morphing_tools.install_packages(self.package_names)
|
|
|
|
|
|
|
|
mock_get_repos_to_enable.assert_called_once()
|
|
mock_get_repos_to_enable.assert_called_once()
|
|
|
- mock_yum_install.assert_called_once_with(
|
|
|
|
|
- self.package_names, mock_get_repos_to_enable.return_value)
|
|
|
|
|
|
|
+ mock_enable_repos.assert_called_once_with(
|
|
|
|
|
+ mock_get_repos_to_enable.return_value)
|
|
|
|
|
+ mock_yum_install.assert_called_once_with(self.package_names)
|
|
|
|
|
|
|
|
@mock.patch.object(redhat.BaseRedHatMorphingTools, '_yum_uninstall')
|
|
@mock.patch.object(redhat.BaseRedHatMorphingTools, '_yum_uninstall')
|
|
|
def test_uninstall_packages(self, mock_yum_uninstall):
|
|
def test_uninstall_packages(self, mock_yum_uninstall):
|