def test_install_advisory_patch_failure(self): ''' Test failing advisory patch installation because patch does not exist. :return: ''' with patch.dict(zypper.__salt__, {'pkg_resource.parse_targets': MagicMock(return_value=({'SUSE-PATCH-XXX': None}, 'advisory'))}): with patch('salt.modules.zypper.__zypper__.noraise.call', MagicMock()) as zypper_mock: with self.assertRaisesRegex(CommandExecutionError, '^Advisory id "SUSE-PATCH-XXX" not found$'): zypper.install(advisory_ids=['SUSE-PATCH-XXX'])
def test_install_with_downloadonly(self): ''' Test a package installation with downloadonly=True. :return: ''' with patch.dict( zypper.__salt__, { 'pkg_resource.parse_targets': MagicMock(return_value=({ 'vim': None }, 'repository')) }): with patch('salt.modules.zypper.__zypper__.noraise.call', MagicMock()) as zypper_mock: ret = zypper.install(pkgs=['vim'], downloadonly=True) zypper_mock.assert_called_once_with( '--no-refresh', 'install', '--name', '--auto-agree-with-licenses', '--download-only', 'vim') self.assertDictEqual( ret, { 'vim': { 'new': { '1.1': { 'path': '/foo/bar/test.rpm', 'size': 1234, 'creation_date_time_t': 1234567890, 'creation_date_time': '2009-02-13T23:31:30' } }, 'old': '' } })
def test_install_advisory_patch_ok(self): ''' Test successfully advisory patch installation. :return: ''' with patch.dict(zypper.__salt__, {'pkg_resource.parse_targets': MagicMock(return_value=({'SUSE-PATCH-1234': None}, 'advisory'))}): with patch('salt.modules.zypper.__zypper__.noraise.call', MagicMock()) as zypper_mock: ret = zypper.install(advisory_ids=['SUSE-PATCH-1234']) zypper_mock.assert_called_once_with( '--no-refresh', 'install', '--name', '--auto-agree-with-licenses', 'patch:SUSE-PATCH-1234' ) self.assertDictEqual(ret, {"vim": {"old": "1.1", "new": "1.2"}})
def test_install_with_downloadonly_already_downloaded(self): ''' Test a package installation with downloadonly=True when package is already downloaded. :return: ''' with patch.dict(zypper.__salt__, {'pkg_resource.parse_targets': MagicMock(return_value=({'vim': None}, 'repository'))}): with patch('salt.modules.zypper.__zypper__.noraise.call', MagicMock()) as zypper_mock: ret = zypper.install(pkgs=['vim'], downloadonly=True) zypper_mock.assert_called_once_with( '--no-refresh', 'install', '--name', '--auto-agree-with-licenses', '--download-only', 'vim' ) self.assertDictEqual(ret, {})