Skip to content

Commit

Permalink
Merge pull request #8 from jfindlay/merge_develop
Browse files Browse the repository at this point in the history
Merge develop
  • Loading branch information
basepi committed Mar 17, 2015
2 parents 0997e3d + b1fe4f0 commit 6be1f22
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 12 deletions.
6 changes: 3 additions & 3 deletions salt/modules/localemod.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,14 +231,14 @@ def gen_locale(locale, **kwargs):
'''
Generate a locale. Options:
verbose
Show extra warnings about errors that are normally ignored.
.. versionadded:: 2014.7.0
:param locale: Any locale listed in /usr/share/i18n/locales or
/usr/share/i18n/SUPPORTED for debian and gentoo based distros
verbose
Show extra warnings about errors that are normally ignored.
CLI Example:
.. code-block:: bash
Expand Down
33 changes: 24 additions & 9 deletions tests/unit/modules/localemod_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,53 +97,68 @@ def test_gen_locale_not_valid(self):
self.assertFalse(localemod.gen_locale('foo'))

@patch('salt.utils.which', MagicMock(return_value='/some/dir/path'))
def test_gen_locale_valid_debian(self):
def test_gen_locale_debian(self):
'''
Tests the return of successful gen_locale on Debian system
'''
ret = {'stdout': 'saltines', 'stderr': 'biscuits', 'retcode': '31337', 'pid': '1337'}
with patch.dict(localemod.__grains__, {'os': 'Debian'}):
with patch.dict(localemod.__salt__,
{'file.search': MagicMock(return_value=True),
'file.replace': MagicMock(return_value=True),
'cmd.retcode': MagicMock(return_value='test')}):
self.assertEqual(localemod.gen_locale('foo bar'), 'test')
'cmd.run_all': MagicMock(return_value=ret)}):
self.assertEqual(localemod.gen_locale('en_US.UTF-8 UTF-8'), ret['retcode'])

@patch('salt.utils.which', MagicMock(return_value='/some/dir/path'))
@patch('os.listdir', MagicMock(return_value=['en_US']))
def test_gen_locale_ubuntu(self):
'''
Test the return of successful gen_locale on Ubuntu system
'''
ret = {'stdout': 'saltines', 'stderr': 'biscuits', 'retcode': '31337', 'pid': '1337'}
with patch.dict(localemod.__salt__,
{'file.replace': MagicMock(return_value=True),
'file.touch': MagicMock(return_value=None),
'file.append': MagicMock(return_value=None),
'cmd.retcode': MagicMock(return_value='A')}):
'cmd.run_all': MagicMock(return_value=ret)}):
with patch.dict(localemod.__grains__, {'os': 'Ubuntu'}):
self.assertEqual(localemod.gen_locale('en_US.UTF-8'), 'A')
self.assertEqual(localemod.gen_locale('en_US.UTF-8'), ret['retcode'])

@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):
'''
Tests the return of successful gen_locale on Gentoo system
'''
ret = {'stdout': 'saltines', 'stderr': 'biscuits', 'retcode': '31337', 'pid': '1337'}
with patch.dict(localemod.__grains__, {'os_family': 'Gentoo'}):
with patch.dict(localemod.__salt__,
{'file.search': MagicMock(return_value=True),
'file.replace': MagicMock(return_value=True),
'cmd.retcode': MagicMock(return_value='A')}):
self.assertEqual(localemod.gen_locale('en_US.UTF-8 UTF-8'), 'A')
'cmd.run_all': MagicMock(return_value=ret)}):
self.assertEqual(localemod.gen_locale('en_US.UTF-8 UTF-8'), ret['retcode'])

@patch('salt.utils.which', MagicMock(return_value='/some/dir/path'))
@patch('os.listdir', MagicMock(return_value=['en_US']))
def test_gen_locale(self):
'''
Tests the return of successful gen_locale
'''
ret = {'stdout': 'saltines', 'stderr': 'biscuits', 'retcode': '31337', 'pid': '1337'}
with patch.dict(localemod.__salt__,
{'cmd.retcode': MagicMock(return_value='A')}):
self.assertEqual(localemod.gen_locale('en_US.UTF-8'), 'A')
{'cmd.run_all': MagicMock(return_value=ret)}):
self.assertEqual(localemod.gen_locale('en_US.UTF-8'), ret['retcode'])

@patch('salt.utils.which', MagicMock(return_value='/some/dir/path'))
@patch('os.listdir', MagicMock(return_value=['en_US']))
def test_gen_locale_verbose(self):
'''
Tests the return of successful gen_locale
'''
ret = {'stdout': 'saltines', 'stderr': 'biscuits', 'retcode': '31337', 'pid': '1337'}
with patch.dict(localemod.__salt__,
{'cmd.run_all': MagicMock(return_value=ret)}):
self.assertEqual(localemod.gen_locale('en_US.UTF-8', verbose=True), ret)


if __name__ == '__main__':
Expand Down

0 comments on commit 6be1f22

Please sign in to comment.