Merge pull request #7607 from s0undt3ch/features/named-salt-versions

Fix remaining test cases and some minor fixes for named versions support
This commit is contained in:
Pedro Algarvio 2013-10-04 05:39:50 -07:00
commit 4c15422828
12 changed files with 68 additions and 48 deletions

View File

@ -578,7 +578,7 @@ def minion_config(path,
'Helium',
'The functionality behind the \'check_dns\' keyword argument is '
'no longer required, as such, it became unnecessary and is now '
'deprecated. \'check_dns\' will be removed {version}.'
'deprecated. \'check_dns\' will be removed in Salt {version}.'
)
if defaults is None:
defaults = DEFAULT_MINION_OPTS
@ -772,7 +772,7 @@ def apply_minion_config(overrides=None, defaults=None, check_dns=None):
'Helium',
'The functionality behind the \'check_dns\' keyword argument is '
'no longer required, as such, it became unnecessary and is now '
'deprecated. \'check_dns\' will be removed {version}.'
'deprecated. \'check_dns\' will be removed in Salt {version}.'
)
if defaults is None:

View File

@ -146,7 +146,8 @@ def latest_version(*names, **kwargs):
salt.utils.warn_until(
'Hydrogen',
'The \'repo\' argument to apt.latest_version is deprecated, and '
'will be removed in {version}. Please use \'fromrepo\' instead.'
'will be removed in Salt {version}. Please use \'fromrepo\' '
'instead.'
)
fromrepo = _get_repo(**kwargs)
kwargs.pop('fromrepo', None)

View File

@ -787,7 +787,7 @@ def script(source,
salt.utils.warn_until(
'Helium',
'Passing a salt environment should be done using \'__env__\' not '
'\'env\'.'
'\'env\'. This functionality will be removed in Salt {version}.'
)
# Backwards compatibility
__env__ = env

View File

@ -250,7 +250,7 @@ def install(pkgs=None,
salt.utils.warn_until(
'Hydrogen',
'The \'runas\' argument to pip.install is deprecated, and will be '
'removed in {version}. Please use \'user\' instead.'
'removed in Salt {version}. Please use \'user\' instead.'
)
# "There can only be one"
@ -561,7 +561,7 @@ def uninstall(pkgs=None,
salt.utils.warn_until(
'Hydrogen',
'The \'runas\' argument to pip.install is deprecated, and will be '
'removed in {version}. Please use \'user\' instead.'
'removed in Salt {version}. Please use \'user\' instead.'
)
# "There can only be one"
@ -685,7 +685,7 @@ def freeze(bin_env=None,
salt.utils.warn_until(
'Hydrogen',
'The \'runas\' argument to pip.install is deprecated, and will be '
'removed in {version}. Please use \'user\' instead.'
'removed in Salt {version}. Please use \'user\' instead.'
)
# "There can only be one"
@ -737,7 +737,7 @@ def list_(prefix=None,
salt.utils.warn_until(
'Hydrogen',
'The \'runas\' argument to pip.install is deprecated, and will be '
'removed in {version}. Please use \'user\' instead.'
'removed in Salt {version}. Please use \'user\' instead.'
)
# "There can only be one"

View File

@ -93,7 +93,8 @@ def create(path,
'Helium',
'\'no_site_packages\' has been deprecated. Please start using '
'\'system_site_packages=False\' which means exactly the same '
'as \'no_site_packages=True\''
'as \'no_site_packages=True\'. This warning and respective '
'workaround will be removed in Salt {version}'
)
if no_site_packages is True and system_site_packages is True:

View File

@ -639,7 +639,7 @@ def script(name,
if isinstance(env, string_types):
msg = (
'Passing a salt environment should be done using \'__env__\' not '
'\'env\'. This warning will go away in salt {version} and this '
'\'env\'. This warning will go away in Salt {version} and this '
'will be the default and expected behaviour. Please update your '
'state files.'
)

View File

@ -24,6 +24,7 @@ import logging
# Import salt libs
import salt.utils
from salt.version import SaltStackVersion as _SaltStackVersion
from salt.exceptions import CommandExecutionError, CommandNotFoundError
# Import 3rd-party libs
@ -149,9 +150,14 @@ def installed(name,
if repo is not None:
msg = ('The \'repo\' argument to pip.installed is deprecated and will '
'be removed in {version}. Please use \'name\' instead. The '
'current value for name, {0!r} will be replaced by the value '
'of repo, {1!r}'.format(name, repo))
'be removed in Salt {version}. Please use \'name\' instead. '
'The current value for name, {0!r} will be replaced by the '
'value of repo, {1!r}'.format(
name,
repo,
version=_SaltStackVersion.from_name(
'Hydrogen').formatted_version
))
salt.utils.warn_until('Hydrogen', msg)
ret.setdefault('warnings', []).append(msg)
name = repo
@ -208,10 +214,12 @@ def installed(name,
if runas is not None:
# The user is using a deprecated argument, warn!
msg = (
'The \'runas\' argument to pip.installed is deprecated, and will '
'be removed in {version}. Please use \'user\' instead.'
)
msg = ('The \'runas\' argument to pip.installed is deprecated, and '
'will be removed in Salt {version}. Please use \'user\' '
'instead.'.format(
version=_SaltStackVersion.from_name(
'Hydrogen').formatted_version
))
salt.utils.warn_until('Hydrogen', msg)
ret.setdefault('warnings', []).append(msg)
@ -397,10 +405,12 @@ def removed(name,
if runas is not None:
# The user is using a deprecated argument, warn!
msg = (
'The \'runas\' argument to pip.installed is deprecated, and will '
'be removed in {version}. Please use \'user\' instead.'
)
msg = ('The \'runas\' argument to pip.installed is deprecated, and '
'will be removed in Salt {version}. Please use \'user\' '
'instead.'.format(
version=_SaltStackVersion.from_name(
'Hydrogen').formatted_version
))
salt.utils.warn_until('Hydrogen', msg)
ret.setdefault('warnings', []).append(msg)

View File

@ -1658,7 +1658,7 @@ def memoize(func):
'Helium',
'The \'memoize\' decorator was moved to \'salt.utils.decorators\', '
'please start importing it from there. This warning and wrapper '
'will be removed on salt > {version}.',
'will be removed in Salt {version}.',
stacklevel=3
)

View File

@ -26,6 +26,7 @@ import salt.minion
import salt.utils
import integration
from salt import config as sconfig, version as salt_version
from salt.version import SaltStackVersion
class ConfigTestCase(TestCase):
@ -298,7 +299,8 @@ class ConfigTestCase(TestCase):
self.assertEquals(syndic_opts['_minion_conf_file'], syndic_conf_path)
def test_check_dns_deprecation_warning(self):
if salt_version.__version_info__ >= 'Helium':
helium_version = SaltStackVersion.from_name('Helium')
if salt_version.__version_info__ >= helium_version:
raise AssertionError(
'Failing this test on purpose! Please delete this test case, '
'the \'check_dns\' keyword argument and the deprecation '
@ -316,8 +318,9 @@ class ConfigTestCase(TestCase):
self.assertEqual(
'The functionality behind the \'check_dns\' keyword argument '
'is no longer required, as such, it became unnecessary and is '
'now deprecated. \'check_dns\' will be removed in salt > '
'0.18.0', str(w[-1].message)
'now deprecated. \'check_dns\' will be removed in Salt '
'{0}.'.format(helium_version.formatted_version),
str(w[-1].message)
)
with warnings.catch_warnings(record=True) as w:
@ -327,8 +330,9 @@ class ConfigTestCase(TestCase):
self.assertEqual(
'The functionality behind the \'check_dns\' keyword argument '
'is no longer required, as such, it became unnecessary and is '
'now deprecated. \'check_dns\' will be removed in salt > '
'0.18.0', str(w[-1].message)
'now deprecated. \'check_dns\' will be removed in Salt '
'{0}.'.format(helium_version.formatted_version),
str(w[-1].message)
)
with warnings.catch_warnings(record=True) as w:
@ -336,8 +340,9 @@ class ConfigTestCase(TestCase):
self.assertEqual(
'The functionality behind the \'check_dns\' keyword argument '
'is no longer required, as such, it became unnecessary and is '
'now deprecated. \'check_dns\' will be removed in salt > '
'0.18.0', str(w[-1].message)
'now deprecated. \'check_dns\' will be removed in Salt '
'{0}.'.format(helium_version.formatted_version),
str(w[-1].message)
)
with warnings.catch_warnings(record=True) as w:
@ -347,8 +352,9 @@ class ConfigTestCase(TestCase):
self.assertEqual(
'The functionality behind the \'check_dns\' keyword argument '
'is no longer required, as such, it became unnecessary and is '
'now deprecated. \'check_dns\' will be removed in salt > '
'0.18.0', str(w[-1].message)
'now deprecated. \'check_dns\' will be removed in Salt '
'{0}.'.format(helium_version.formatted_version),
str(w[-1].message)
)

View File

@ -885,8 +885,8 @@ class PipTestCase(TestCase):
pip.install('pep8', runas='me!')
self.assertEqual(
'The \'runas\' argument to pip.install is deprecated, and '
'will be removed in 0.18.0. Please use \'user\' instead.',
str(w[-1].message)
'will be removed in Salt Hydrogen (Unreleased). Please '
'use \'user\' instead.', str(w[-1].message)
)
def test_uninstall_deprecated_runas_triggers_warning(self):
@ -900,8 +900,8 @@ class PipTestCase(TestCase):
pip.uninstall('pep8', runas='me!')
self.assertEqual(
'The \'runas\' argument to pip.install is deprecated, and '
'will be removed in 0.18.0. Please use \'user\' instead.',
str(w[-1].message)
'will be removed in Salt Hydrogen (Unreleased). Please '
'use \'user\' instead.', str(w[-1].message)
)
def test_freeze_deprecated_runas_triggers_warning(self):
@ -915,8 +915,8 @@ class PipTestCase(TestCase):
pip.freeze('/tmp/pip-env', runas='me!')
self.assertEqual(
'The \'runas\' argument to pip.install is deprecated, and '
'will be removed in 0.18.0. Please use \'user\' instead.',
str(w[-1].message)
'will be removed in Salt Hydrogen (Unreleased). Please '
'use \'user\' instead.', str(w[-1].message)
)
def test_list_deprecated_runas_triggers_warning(self):
@ -930,8 +930,8 @@ class PipTestCase(TestCase):
pip.list_('blah', runas='me!')
self.assertEqual(
'The \'runas\' argument to pip.install is deprecated, and '
'will be removed in 0.18.0. Please use \'user\' instead.',
str(w[-1].message)
'will be removed in Salt Hydrogen (Unreleased). Please '
'use \'user\' instead.', str(w[-1].message)
)
def test_install_user_and_runas_raises_exception(self):

View File

@ -177,7 +177,9 @@ class VirtualenvTestCase(TestCase):
self.assertEqual(
'\'no_site_packages\' has been deprecated. Please '
'start using \'system_site_packages=False\' which '
'means exactly the same as \'no_site_packages=True\'',
'means exactly the same as \'no_site_packages=True\'. '
'This warning and respective workaround will be removed '
'in Salt Helium (Unreleased)',
str(w[-1].message)
)

View File

@ -48,16 +48,16 @@ class PipStateTest(TestCase, integration.SaltReturnAssertsMixIn):
ret = pip_state.installed('pep8', runas='me!')
self.assertEqual(
'The \'runas\' argument to pip.installed is deprecated, '
'and will be removed in 0.18.0. Please use \'user\' '
'instead.', str(w[-1].message)
'and will be removed in Salt Hydrogen (Unreleased). '
'Please use \'user\' instead.', str(w[-1].message)
)
self.assertSaltTrueReturn({'testsuite': ret})
# Is the state returning a warnings key with the deprecation
# message?
self.assertInSalStatetWarning(
'The \'runas\' argument to pip.installed is deprecated, '
'and will be removed in 0.18.0. Please use \'user\' '
'instead.', {'testsuite': ret}
'and will be removed in Salt Hydrogen (Unreleased). '
'Please use \'user\' instead.', {'testsuite': ret}
)
def test_installed_runas_and_user_raises_exception(self):
@ -86,16 +86,16 @@ class PipStateTest(TestCase, integration.SaltReturnAssertsMixIn):
ret = pip_state.removed('pep8', runas='me!')
self.assertEqual(
'The \'runas\' argument to pip.installed is deprecated, '
'and will be removed in 0.18.0. Please use \'user\' '
'instead.', str(w[-1].message)
'and will be removed in Salt Hydrogen (Unreleased). '
'Please use \'user\' instead.', str(w[-1].message)
)
self.assertSaltTrueReturn({'testsuite': ret})
# Is the state returning a warnings key with the deprecation
# message?
self.assertInSalStatetWarning(
'The \'runas\' argument to pip.installed is deprecated, '
'and will be removed in 0.18.0. Please use \'user\' '
'instead.', {'testsuite': ret}
'and will be removed in Salt Hydrogen (Unreleased). '
'Please use \'user\' instead.', {'testsuite': ret}
)
def test_removed_runas_and_user_raises_exception(self):