"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tests/integration/modules/test_localemod.py" between
salt-3002.1.tar.gz and salt-3002.2.tar.gz

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

test_localemod.py  (salt-3002.1):test_localemod.py  (salt-3002.2)
import pytest import pytest
import salt.utils.platform import salt.utils.platform
from tests.support.case import ModuleCase from tests.support.case import ModuleCase
from tests.support.helpers import destructiveTest, requires_salt_modules, slowTe st from tests.support.helpers import destructiveTest, requires_salt_modules, slowTe st
from tests.support.unit import skipIf from tests.support.unit import skipIf
def _find_new_locale(current_locale):
for locale in ["en_US.UTF-8", "de_DE.UTF-8", "fr_FR.UTF-8"]:
if locale != current_locale:
return locale
@skipIf(salt.utils.platform.is_windows(), "minion is windows") @skipIf(salt.utils.platform.is_windows(), "minion is windows")
@skipIf(salt.utils.platform.is_darwin(), "locale method is not supported on mac" ) @skipIf(salt.utils.platform.is_darwin(), "locale method is not supported on mac" )
@skipIf( @skipIf(
salt.utils.platform.is_freebsd(), salt.utils.platform.is_freebsd(),
"locale method is supported only within login classes or environment variabl es", "locale method is supported only within login classes or environment variabl es",
) )
@requires_salt_modules("locale") @requires_salt_modules("locale")
@pytest.mark.windows_whitelisted @pytest.mark.windows_whitelisted
class LocaleModuleTest(ModuleCase): class LocaleModuleTest(ModuleCase):
def _find_new_locale(self, current_locale):
test_locales = ["en_US.UTF-8", "de_DE.UTF-8", "fr_FR.UTF-8", "en_AU.UTF-
8"]
for locale in test_locales:
if locale != current_locale and self.run_function("locale.avail", [l
ocale]):
return locale
self.skipTest(
"The test locals: {} do not exist on the host. Skipping test.".forma
t(
",".join(test_locales)
)
)
def test_get_locale(self): def test_get_locale(self):
locale = self.run_function("locale.get_locale") locale = self.run_function("locale.get_locale")
self.assertNotIn("Unsupported platform!", locale) self.assertNotIn("Unsupported platform!", locale)
@destructiveTest @destructiveTest
@slowTest @slowTest
def test_gen_locale(self): def test_gen_locale(self):
# Make sure charmaps are available on test system before attempting # Make sure charmaps are available on test system before attempting
# call gen_locale. We log this error to the user in the function, but # call gen_locale. We log this error to the user in the function, but
# we don't want to fail this test if this is missing on the test system. # we don't want to fail this test if this is missing on the test system.
char_maps = self.run_function("cmd.run_all", ["locale -m"]) char_maps = self.run_function("cmd.run_all", ["locale -m"])
if char_maps["stdout"] == "": if char_maps["stdout"] == "":
self.skipTest("locale charmaps not available. Skipping test.") self.skipTest("locale charmaps not available. Skipping test.")
if char_maps["retcode"] and char_maps["stderr"]: if char_maps["retcode"] and char_maps["stderr"]:
self.skipTest( self.skipTest(
"{}. Cannot generate locale. Skipping test.".format(char_maps["s tderr"]) "{}. Cannot generate locale. Skipping test.".format(char_maps["s tderr"])
) )
locale = self.run_function("locale.get_locale") locale = self.run_function("locale.get_locale")
new_locale = _find_new_locale(locale) new_locale = self._find_new_locale(locale)
ret = self.run_function("locale.gen_locale", [new_locale]) ret = self.run_function("locale.gen_locale", [new_locale])
self.assertTrue(ret) self.assertTrue(ret)
@destructiveTest @destructiveTest
@slowTest @slowTest
def test_set_locale(self): def test_set_locale(self):
original_locale = self.run_function("locale.get_locale") original_locale = self.run_function("locale.get_locale")
locale_to_set = _find_new_locale(original_locale) locale_to_set = self._find_new_locale(original_locale)
self.run_function("locale.gen_locale", [locale_to_set]) self.run_function("locale.gen_locale", [locale_to_set])
ret = self.run_function("locale.set_locale", [locale_to_set]) ret = self.run_function("locale.set_locale", [locale_to_set])
new_locale = self.run_function("locale.get_locale") new_locale = self.run_function("locale.get_locale")
self.assertTrue(ret) self.assertTrue(ret)
self.assertEqual(locale_to_set, new_locale) self.assertEqual(locale_to_set, new_locale)
self.run_function("locale.set_locale", [original_locale]) self.run_function("locale.set_locale", [original_locale])
 End of changes. 4 change blocks. 
7 lines changed or deleted 17 lines changed or added

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