|
@@ -27,44 +27,66 @@ from resource_management.core import shell
|
|
|
|
|
|
class TestPackageResource(TestCase):
|
|
|
|
|
|
+ @patch.object(shell, "call", new = MagicMock(return_value=(1, None)))
|
|
|
@patch.object(shell, "checked_call")
|
|
|
@patch.object(System, "os_family", new = 'redhat')
|
|
|
- def test_action_install_rhel(self, shell_mock):
|
|
|
+ def test_action_install_rhel(self, shell_mock):
|
|
|
with Environment('/') as env:
|
|
|
Package("some_package",
|
|
|
)
|
|
|
shell_mock.assert_called_with("/usr/bin/yum -d 0 -e 0 -y install some_package")
|
|
|
-
|
|
|
+
|
|
|
+ @patch.object(shell, "call", new = MagicMock(return_value=(1, None)))
|
|
|
@patch.object(shell, "checked_call")
|
|
|
@patch.object(System, "os_family", new = 'suse')
|
|
|
- def test_action_install_suse(self, shell_mock):
|
|
|
+ def test_action_install_suse(self, shell_mock):
|
|
|
with Environment('/') as env:
|
|
|
Package("some_package",
|
|
|
)
|
|
|
shell_mock.assert_called_with("/usr/bin/zypper --quiet install --auto-agree-with-licenses --no-confirm some_package")
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+ @patch.object(shell, "call", new = MagicMock(return_value=(0, None)))
|
|
|
+ @patch.object(shell, "checked_call")
|
|
|
+ @patch.object(System, "os_family", new = 'redhat')
|
|
|
+ def test_action_install_existent_rhel(self, shell_mock):
|
|
|
+ with Environment('/') as env:
|
|
|
+ Package("some_package",
|
|
|
+ )
|
|
|
+ self.assertFalse(shell_mock.mock_calls)
|
|
|
+
|
|
|
+ @patch.object(shell, "call", new = MagicMock(return_value=(0, None)))
|
|
|
+ @patch.object(shell, "checked_call")
|
|
|
+ @patch.object(System, "os_family", new = 'suse')
|
|
|
+ def test_action_install_existent_suse(self, shell_mock):
|
|
|
+ with Environment('/') as env:
|
|
|
+ Package("some_package",
|
|
|
+ )
|
|
|
+ self.assertFalse(shell_mock.mock_calls)
|
|
|
+
|
|
|
+ @patch.object(shell, "call", new = MagicMock(return_value=(0, None)))
|
|
|
@patch.object(shell, "checked_call")
|
|
|
@patch.object(System, "os_family", new = 'redhat')
|
|
|
- def test_action_remove_rhel(self, shell_mock):
|
|
|
+ def test_action_remove_rhel(self, shell_mock):
|
|
|
with Environment('/') as env:
|
|
|
Package("some_package",
|
|
|
action = "remove"
|
|
|
)
|
|
|
shell_mock.assert_called_with("/usr/bin/yum -d 0 -e 0 -y erase some_package")
|
|
|
-
|
|
|
+
|
|
|
+ @patch.object(shell, "call", new = MagicMock(return_value=(0, None)))
|
|
|
@patch.object(shell, "checked_call")
|
|
|
@patch.object(System, "os_family", new = 'suse')
|
|
|
- def test_action_remove_suse(self, shell_mock):
|
|
|
+ def test_action_remove_suse(self, shell_mock):
|
|
|
with Environment('/') as env:
|
|
|
Package("some_package",
|
|
|
action = "remove"
|
|
|
)
|
|
|
shell_mock.assert_called_with("/usr/bin/zypper --quiet remove --no-confirm some_package")
|
|
|
-
|
|
|
+
|
|
|
+ @patch.object(shell, "call", new = MagicMock(return_value=(1, None)))
|
|
|
@patch.object(shell, "checked_call")
|
|
|
@patch.object(System, "os_family", new = 'redhat')
|
|
|
- def test_action_install_version_attr(self, shell_mock):
|
|
|
+ def test_action_install_version_attr(self, shell_mock):
|
|
|
with Environment('/') as env:
|
|
|
Package("some_package",
|
|
|
version = "3.5.0"
|