mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
parent
bfd812c56b
commit
5eb97f0973
@ -261,6 +261,11 @@ def gen_locale(locale, **kwargs):
|
||||
if on_debian or on_gentoo: # file-based search
|
||||
search = '/usr/share/i18n/SUPPORTED'
|
||||
valid = __salt__['file.search'](search, '^{0}$'.format(locale))
|
||||
if not valid and not locale_info['charmap']:
|
||||
# charmap was not supplied, so try copying the codeset
|
||||
locale_info['charmap'] = locale_info['codeset']
|
||||
locale = _join_locale(locale_info)
|
||||
valid = __salt__['file.search'](search, '^{0}$'.format(locale))
|
||||
else: # directory-based search
|
||||
if on_suse:
|
||||
search = '/usr/share/locale'
|
||||
|
@ -109,6 +109,28 @@ class LocalemodTestCase(TestCase):
|
||||
'cmd.run_all': MagicMock(return_value=ret)}):
|
||||
self.assertTrue(localemod.gen_locale('en_US.UTF-8 UTF-8'))
|
||||
|
||||
@patch('salt.utils.which', MagicMock(return_value='/some/dir/path'))
|
||||
def test_gen_locale_debian_no_charmap(self):
|
||||
'''
|
||||
Tests the return of successful gen_locale on Debian system without a charmap
|
||||
'''
|
||||
def file_search(search, pattern):
|
||||
'''
|
||||
mock file.search
|
||||
'''
|
||||
if len(pattern.split()) == 1:
|
||||
return False
|
||||
else: # charmap was supplied
|
||||
return True
|
||||
|
||||
ret = {'stdout': 'saltines', 'stderr': 'biscuits', 'retcode': 0, 'pid': 1337}
|
||||
with patch.dict(localemod.__grains__, {'os': 'Debian'}):
|
||||
with patch.dict(localemod.__salt__,
|
||||
{'file.search': file_search,
|
||||
'file.replace': MagicMock(return_value=True),
|
||||
'cmd.run_all': MagicMock(return_value=ret)}):
|
||||
self.assertTrue(localemod.gen_locale('en_US.UTF-8'))
|
||||
|
||||
@patch('salt.utils.which', MagicMock(return_value='/some/dir/path'))
|
||||
@patch('os.listdir', MagicMock(return_value=['en_US']))
|
||||
def test_gen_locale_ubuntu(self):
|
||||
@ -124,7 +146,6 @@ class LocalemodTestCase(TestCase):
|
||||
with patch.dict(localemod.__grains__, {'os': 'Ubuntu'}):
|
||||
self.assertTrue(localemod.gen_locale('en_US.UTF-8'))
|
||||
|
||||
@patch('salt.utils.which', MagicMock(return_value='/some/dir/path'))
|
||||
@patch('os.listdir', MagicMock(return_value=['en_US.UTF-8']))
|
||||
def test_gen_locale_gentoo(self):
|
||||
'''
|
||||
@ -138,6 +159,28 @@ class LocalemodTestCase(TestCase):
|
||||
'cmd.run_all': MagicMock(return_value=ret)}):
|
||||
self.assertTrue(localemod.gen_locale('en_US.UTF-8 UTF-8'))
|
||||
|
||||
@patch('os.listdir', MagicMock(return_value=['en_US.UTF-8']))
|
||||
def test_gen_locale_gentoo_no_charmap(self):
|
||||
'''
|
||||
Tests the return of successful gen_locale on Gentoo system without a charmap
|
||||
'''
|
||||
def file_search(search, pattern):
|
||||
'''
|
||||
mock file.search
|
||||
'''
|
||||
if len(pattern.split()) == 1:
|
||||
return False
|
||||
else: # charmap was supplied
|
||||
return True
|
||||
|
||||
ret = {'stdout': 'saltines', 'stderr': 'biscuits', 'retcode': 0, 'pid': 1337}
|
||||
with patch.dict(localemod.__grains__, {'os_family': 'Gentoo'}):
|
||||
with patch.dict(localemod.__salt__,
|
||||
{'file.search': file_search,
|
||||
'file.replace': MagicMock(return_value=True),
|
||||
'cmd.run_all': MagicMock(return_value=ret)}):
|
||||
self.assertTrue(localemod.gen_locale('en_US.UTF-8'))
|
||||
|
||||
@patch('salt.utils.which', MagicMock(return_value='/some/dir/path'))
|
||||
@patch('os.listdir', MagicMock(return_value=['en_US']))
|
||||
def test_gen_locale(self):
|
||||
|
Loading…
Reference in New Issue
Block a user