예제 #1
0
파일: config_test.py 프로젝트: tligda/salt
    def test_check_dns_deprecation_warning(self):
        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 '
                'warnings in `salt.config.minion_config` and '
                'salt.config.apply_minion_config`'
            )

        # Let's force the warning to always be thrown
        warnings.resetwarnings()
        warnings.filterwarnings(
            'always', '(.*)check_dns(.*)', DeprecationWarning, 'salt.config'
        )
        with warnings.catch_warnings(record=True) as w:
            sconfig.minion_config(None, None, check_dns=True)
            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}.'.format(helium_version.formatted_version),
                str(w[-1].message)
            )

        with warnings.catch_warnings(record=True) as w:
            sconfig.apply_minion_config(
                overrides=None, defaults=None, check_dns=True
            )
            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}.'.format(helium_version.formatted_version),
                str(w[-1].message)
            )

        with warnings.catch_warnings(record=True) as w:
            sconfig.minion_config(None, None, check_dns=False)
            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}.'.format(helium_version.formatted_version),
                str(w[-1].message)
            )

        with warnings.catch_warnings(record=True) as w:
            sconfig.apply_minion_config(
                overrides=None, defaults=None, check_dns=False
            )
            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}.'.format(helium_version.formatted_version),
                str(w[-1].message)
            )
예제 #2
0
    def test_check_dns_deprecation_warning(self):
        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 '
                'warnings in `salt.config.minion_config` and '
                'salt.config.apply_minion_config`'
            )

        # Let's force the warning to always be thrown
        warnings.resetwarnings()
        warnings.filterwarnings(
            'always', '(.*)check_dns(.*)', DeprecationWarning, 'salt.config'
        )
        with warnings.catch_warnings(record=True) as w:
            sconfig.minion_config(None, None, check_dns=True)
            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}.'.format(helium_version.formatted_version),
                str(w[-1].message)
            )

        with warnings.catch_warnings(record=True) as w:
            sconfig.apply_minion_config(
                overrides=None, defaults=None, check_dns=True
            )
            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}.'.format(helium_version.formatted_version),
                str(w[-1].message)
            )

        with warnings.catch_warnings(record=True) as w:
            sconfig.minion_config(None, None, check_dns=False)
            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}.'.format(helium_version.formatted_version),
                str(w[-1].message)
            )

        with warnings.catch_warnings(record=True) as w:
            sconfig.apply_minion_config(
                overrides=None, defaults=None, check_dns=False
            )
            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}.'.format(helium_version.formatted_version),
                str(w[-1].message)
            )
예제 #3
0
    def test_check_dns_deprecation_warning(self):
        if salt_version.__version_info__ >= (0, 19):
            raise AssertionError(
                "Failing this test on purpose! Please delete this test case, "
                "the 'check_dns' keyword argument and the deprecation "
                "warnings in `salt.config.minion_config` and "
                "salt.config.apply_minion_config`"
            )

        # Let's force the warning to always be thrown
        warnings.resetwarnings()
        warnings.filterwarnings("always", "(.*)check_dns(.*)", DeprecationWarning, "salt.config")
        with warnings.catch_warnings(record=True) as w:
            sconfig.minion_config(None, None, check_dns=True)
            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),
            )

        with warnings.catch_warnings(record=True) as w:
            sconfig.apply_minion_config(overrides=None, defaults=None, check_dns=True)
            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),
            )

        with warnings.catch_warnings(record=True) as w:
            sconfig.minion_config(None, None, check_dns=False)
            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),
            )

        with warnings.catch_warnings(record=True) as w:
            sconfig.apply_minion_config(overrides=None, defaults=None, check_dns=False)
            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),
            )