"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tests/integration/states/test_pkgrepo.py" between
salt-2019.2.0.tar.gz and salt-2019.2.1.tar.gz

About: SaltStack is a systems management software for data center automation, cloud orchestration, server provisioning, configuration management and more. Community version.

test_pkgrepo.py  (salt-2019.2.0):test_pkgrepo.py  (salt-2019.2.1)
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
''' '''
tests for pkgrepo states tests for pkgrepo states
''' '''
# Import Python libs # Import Python libs
from __future__ import absolute_import, print_function, unicode_literals from __future__ import absolute_import, print_function, unicode_literals
import os
# Import Salt Testing libs # Import Salt Testing libs
from tests.support.case import ModuleCase from tests.support.case import ModuleCase
from tests.support.mixins import SaltReturnAssertsMixin from tests.support.mixins import SaltReturnAssertsMixin
from tests.support.unit import skipIf from tests.support.unit import skipIf
from tests.support.helpers import ( from tests.support.helpers import (
destructiveTest, destructiveTest,
requires_system_grains requires_system_grains,
) )
# Import Salt libs # Import Salt libs
import salt.utils.platform import salt.utils.platform
# Import 3rd-party libs # Import 3rd-party libs
from salt.ext import six from salt.ext import six
@destructiveTest @destructiveTest
@skipIf(salt.utils.platform.is_windows(), 'minion is windows') @skipIf(salt.utils.platform.is_windows(), 'minion is windows')
skipping to change at line 130 skipping to change at line 131
self.assertSaltTrueReturn(ret) self.assertSaltTrueReturn(ret)
ret = ret[next(iter(ret))] ret = ret[next(iter(ret))]
self.assertFalse(ret['changes']) self.assertFalse(ret['changes'])
self.assertEqual( self.assertEqual(
ret['comment'], ret['comment'],
"Package repo '{0}' already configured".format(kwargs['name']) "Package repo '{0}' already configured".format(kwargs['name'])
) )
finally: finally:
# Clean up # Clean up
self.run_state('pkgrepo.absent', name=kwargs['name']) self.run_state('pkgrepo.absent', name=kwargs['name'])
@requires_system_grains
def test_pkgrepo_04_apt_with_architectures(self, grains):
'''
Test managing a repo with architectures specified
'''
if grains['os_family'].lower() != 'debian':
self.skipTest('APT-only test')
name = 'deb {{arch}}http://foo.com/bar/latest {oscodename} main'.format(
oscodename=grains['oscodename'])
def _get_arch(arch):
return '[arch={0}] '.format(arch) if arch else ''
def _run(arch='', test=False):
ret = self.run_state(
'pkgrepo.managed',
name=name.format(arch=_get_arch(arch)),
file=fn_,
refresh=False,
test=test)
return ret[next(iter(ret))]
fn_ = salt.utils.files.mkstemp(dir='/etc/apt/sources.list.d', suffix='.l
ist')
try:
# Run with test=True
ret = _run(test=True)
assert ret['changes'] == {'repo': name.format(arch='')}, ret['change
s']
assert 'would be' in ret['comment'], ret['comment']
assert ret['result'] is None, ret['result']
# Run for real
ret = _run()
assert ret['changes'] == {'repo': name.format(arch='')}, ret['change
s']
assert ret['comment'].startswith('Configured'), ret['comment']
assert ret['result'] is True, ret['result']
# Run again with test=True, should exit with no changes and a True
# result.
ret = _run(test=True)
assert not ret['changes'], ret['changes']
assert 'already' in ret['comment'], ret['comment']
assert ret['result'] is True, ret['result']
# Run for real again, results should be the same as above (i.e. we
# should never get to the point where we exit with a None result).
ret = _run()
assert not ret['changes'], ret['changes']
assert 'already' in ret['comment'], ret['comment']
assert ret['result'] is True, ret['result']
expected_changes = {
'line': {
'new': name.format(arch=_get_arch('amd64')),
'old': name.format(arch=''),
},
'architectures': {
'new': ['amd64'],
'old': [],
},
}
# Run with test=True and the architecture set. We should get a None
# result with some expected changes.
ret = _run(arch='amd64', test=True)
assert ret['changes'] == expected_changes, ret['changes']
assert 'would be' in ret['comment'], ret['comment']
assert ret['result'] is None, ret['result']
# Run for real, with the architecture set. We should get a True
# result with the same changes.
ret = _run(arch='amd64')
assert ret['changes'] == expected_changes, ret['changes']
assert ret['comment'].startswith('Configured'), ret['comment']
assert ret['result'] is True, ret['result']
# Run again with test=True, should exit with no changes and a True
# result.
ret = _run(arch='amd64', test=True)
assert not ret['changes'], ret['changes']
assert 'already' in ret['comment'], ret['comment']
assert ret['result'] is True, ret['result']
# Run for real again, results should be the same as above (i.e. we
# should never get to the point where we exit with a None result).
ret = _run(arch='amd64')
assert not ret['changes'], ret['changes']
assert 'already' in ret['comment'], ret['comment']
assert ret['result'] is True, ret['result']
expected_changes = {
'line': {
'new': name.format(arch=''),
'old': name.format(arch=_get_arch('amd64')),
},
'architectures': {
'new': [],
'old': ['amd64'],
},
}
# Run with test=True and the architecture set back to the original
# value. We should get a None result with some expected changes.
ret = _run(test=True)
assert ret['changes'] == expected_changes, ret['changes']
assert 'would be' in ret['comment'], ret['comment']
assert ret['result'] is None, ret['result']
# Run for real, with the architecture set. We should get a True
# result with the same changes.
ret = _run()
assert ret['changes'] == expected_changes, ret['changes']
assert ret['comment'].startswith('Configured'), ret['comment']
assert ret['result'] is True, ret['result']
# Run again with test=True, should exit with no changes and a True
# result.
ret = _run(test=True)
assert not ret['changes'], ret['changes']
assert 'already' in ret['comment'], ret['comment']
assert ret['result'] is True, ret['result']
# Run for real again, results should be the same as above (i.e. we
# should never get to the point where we exit with a None result).
ret = _run()
assert not ret['changes'], ret['changes']
assert 'already' in ret['comment'], ret['comment']
assert ret['result'] is True, ret['result']
finally:
try:
os.remove(fn_)
except OSError:
pass
 End of changes. 3 change blocks. 
1 lines changed or deleted 2 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)