Beispiel #1
0
    def test_list_upgrades_error_handling(self):
        '''
        Test error handling in the list package upgrades.
        :return:
        '''
        # Test handled errors
        ref_out = {
            'stdout': '''<?xml version='1.0'?>
<stream>
 <message type="info">Refreshing service &apos;container-suseconnect&apos;.</message>
 <message type="error">Some handled zypper internal error</message>
 <message type="error">Another zypper internal error</message>
</stream>
            ''',
            'stderr': '',
            'retcode': 1,
        }
        with patch.dict('salt.modules.zypper.__salt__',
                        {'cmd.run_all': MagicMock(return_value=ref_out)}):
            with self.assertRaisesRegexp(
                    CommandExecutionError,
                    "^Zypper command failure: Some handled zypper internal error\nAnother zypper internal error$"
            ):
                zypper.list_upgrades(refresh=False)

        # Test unhandled error
        ref_out = {'retcode': 1, 'stdout': '', 'stderr': ''}
        with patch.dict('salt.modules.zypper.__salt__',
                        {'cmd.run_all': MagicMock(return_value=ref_out)}):
            with self.assertRaisesRegexp(
                    CommandExecutionError,
                    "^Zypper command failure: Check Zypper's logs.$"):
                zypper.list_upgrades(refresh=False)
Beispiel #2
0
    def test_list_upgrades_error_handling(self):
        '''
        Test error handling in the list package upgrades.
        :return:
        '''
        # Test handled errors
        ref_out = {
            'stdout': '''<?xml version='1.0'?>
<stream>
 <message type="info">Refreshing service &apos;container-suseconnect&apos;.</message>
 <message type="error">Some handled zypper internal error</message>
 <message type="error">Another zypper internal error</message>
</stream>
            ''',
            'stderr': '',
            'retcode': 1,
        }
        with patch.dict('salt.modules.zypper.__salt__', {'cmd.run_all': MagicMock(return_value=ref_out)}):
            with self.assertRaisesRegexp(CommandExecutionError,
                    "^Zypper command failure: Some handled zypper internal error\nAnother zypper internal error$"):
                zypper.list_upgrades(refresh=False)

        # Test unhandled error
        ref_out = {
            'retcode': 1,
            'stdout': '',
            'stderr': ''
        }
        with patch.dict('salt.modules.zypper.__salt__', {'cmd.run_all': MagicMock(return_value=ref_out)}):
            with self.assertRaisesRegexp(CommandExecutionError, "^Zypper command failure: Check Zypper's logs.$"):
                zypper.list_upgrades(refresh=False)
Beispiel #3
0
    def test_list_upgrades_error_handling(self):
        '''
        Test error handling in the list package upgrades.
        :return:
        '''
        # Test handled errors
        ref_out = {
            'stderr': 'Some handled zypper internal error',
            'retcode': 1
        }
        with patch.dict(zypper.__salt__,
                        {'cmd.run_all': MagicMock(return_value=ref_out)}):
            try:
                zypper.list_upgrades(refresh=False)
            except CommandExecutionError as error:
                assert error.message == ref_out['stderr']

        # Test unhandled error
        ref_out = {'retcode': 1}
        with patch.dict(zypper.__salt__,
                        {'cmd.run_all': MagicMock(return_value=ref_out)}):
            try:
                zypper.list_upgrades(refresh=False)
            except CommandExecutionError as error:
                assert error.message == 'Zypper returned non-zero system exit. See Zypper logs for more details.'
Beispiel #4
0
 def test_list_upgrades(self):
     '''
     List package upgrades
     :return:
     '''
     ref_out = {
         'stdout': get_test_data('zypper-updates.xml'),
         'stderr': None,
         'retcode': 0
     }
     with patch.dict(zypper.__salt__, {'cmd.run_all': MagicMock(return_value=ref_out)}):
         upgrades = zypper.list_upgrades(refresh=False)
         self.assertEqual(len(upgrades), 3)
         for pkg, version in {'SUSEConnect': '0.2.33-7.1',
                              'bind-utils': '9.9.6P1-35.1',
                              'bind-libs': '9.9.6P1-35.1'}.items():
             self.assertIn(pkg, upgrades)
             self.assertEqual(upgrades[pkg], version)
Beispiel #5
0
 def test_list_upgrades(self):
     '''
     List package upgrades
     :return:
     '''
     ref_out = {
         'stdout': get_test_data('zypper-updates.xml'),
         'stderr': None,
         'retcode': 0
     }
     with patch.dict(zypper.__salt__, {'cmd.run_all': MagicMock(return_value=ref_out)}):
         upgrades = zypper.list_upgrades(refresh=False)
         self.assertEqual(len(upgrades), 3)
         for pkg, version in {'SUSEConnect': '0.2.33-7.1',
                              'bind-utils': '9.9.6P1-35.1',
                              'bind-libs': '9.9.6P1-35.1'}.items():
             self.assertIn(pkg, upgrades)
             self.assertEqual(upgrades[pkg], version)