fix localemod unit tests for merge forward

This commit is contained in:
Justin Findlay 2015-03-17 15:13:23 -06:00
parent 3f9fb6824c
commit b1fe4f02c3

View File

@ -97,16 +97,17 @@ class LocalemodTestCase(TestCase):
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']))
@ -114,13 +115,14 @@ class LocalemodTestCase(TestCase):
'''
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']))
@ -128,12 +130,13 @@ class LocalemodTestCase(TestCase):
'''
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']))
@ -141,9 +144,21 @@ class LocalemodTestCase(TestCase):
'''
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__':