Esempio n. 1
0
 def test_PackageManager_suse(self):
     """
     Test Packagemanager assignments based on `patform` mocks.
     """
     pm.__grains__ = {'os': 'suse'}
     ret = PackageManager()
     assert isinstance(ret.pm, Zypper) is True
Esempio n. 2
0
 def test_PackageManager_ubuntu(self):
     """
     Test Packagemanager assignments based on `patform` mocks.
     """
     pm.__grains__ = {'os': 'ubuntu'}
     ret = PackageManager()
     assert isinstance(ret.pm, Apt) is True
Esempio n. 3
0
 def test_PackageManager_ubuntu(self, dist_return):
     """
     Test Packagemanager assignments based on `patform` mocks.
     """
     dist_return.return_value = ('ubuntu', '23', 'x86_64')
     ret = PackageManager()
     assert isinstance(ret.pm, Apt) is True
Esempio n. 4
0
 def zypp(self):
     """
     Fixture to always get Zypper.
     """
     pm.__grains__ = {'os': 'suse'}
     args = {'debug': False, 'kernel': False, 'reboot': False}
     yield PackageManager(**args).pm
Esempio n. 5
0
 def test_PackageManager_suse(self, dist_return):
     """
     Test Packagemanager assignments based on `patform` mocks.
     """
     dist_return.return_value = ('SUSE', '12.2', 'x86_64')
     ret = PackageManager()
     assert isinstance(ret.pm, Zypper) is True
Esempio n. 6
0
 def test_not_implemented(self, po):
     """
     Your platform is not supported
     """
     pm.__grains__ = {'os': 'UnknownOS'}
     with pytest.raises(ValueError) as excinfo:
         PackageManager()
     excinfo.match('Failed to detect PackageManager for OS.*')
Esempio n. 7
0
 def test_not_implemented(self, po, dist_return):
     """
     Your platform is not supported
     """
     dist_return.return_value = ('ScientificLinux', '42.2', 'x86_64')
     with pytest.raises(ValueError) as excinfo:
         PackageManager()
     excinfo.match('Failed to detect PackageManager for OS.*')
Esempio n. 8
0
 def zypp(self):
     """
     Fixture to always get Zypper.
     """
     self.linux_dist = patch('srv.salt._modules.packagemanager.linux_distribution')
     self.lnx_dist_object = self.linux_dist.start()
     self.lnx_dist_object.return_value = ('opensuse', '42.2', 'x86_64')
     args = {'debug': False, 'kernel': False, 'reboot': False}
     yield PackageManager(**args).pm
     self.linux_dist.stop()
Esempio n. 9
0
 def apt(self):
     """
     Fixture to always get Apt.
     """
     pm.__grains__ = {'os': 'ubuntu'}
     args = {'debug': False, 'kernel': False, 'reboot': False}
     def pass_through(*args, **kwargs):
         return args[0]
     mock_func = create_autospec(lambda x: x, side_effect=pass_through)
     pm.__salt__ = {'helper.convert_out': mock_func}
     yield PackageManager(**args).pm
Esempio n. 10
0
 def apt(self):
     """
     Fixture to always get Apt.
     """
     self.linux_dist = patch('srv.salt._modules.packagemanager.linux_distribution')
     self.lnx_dist_object = self.linux_dist.start()
     self.lnx_dist_object.return_value = ('ubuntu', '42.2', 'x86_64')
     # Test all permutations of :debug :kernel and :reboot
     args = {'debug': False, 'kernel': False, 'reboot': False}
     yield PackageManager(**args).pm
     self.linux_dist.stop()