fix unit tests

This commit is contained in:
Michael Calmer 2017-05-19 13:28:52 +02:00
parent 428baa9bce
commit f30f5c8a25

View File

@ -44,19 +44,20 @@ class LocalemodTestCase(TestCase):
Test for Get the current system locale Test for Get the current system locale
''' '''
with patch.dict(localemod.__context__, {'salt.utils.systemd.booted': True}): with patch.dict(localemod.__context__, {'salt.utils.systemd.booted': True}):
localemod.HAS_DBUS = True with patch.dict(localemod.__grains__, {'os_family': ['Unknown']}):
with patch.object(localemod, localemod.HAS_DBUS = True
'_parse_dbus_locale', with patch.object(localemod,
return_value={'LANG': 'A'}): '_parse_dbus_locale',
self.assertEqual('A', localemod.get_locale()) return_value={'LANG': 'A'}):
localemod._parse_dbus_locale.assert_called_once_with() self.assertEqual('A', localemod.get_locale())
localemod._parse_dbus_locale.assert_called_once_with()
localemod.HAS_DBUS = False localemod.HAS_DBUS = False
with patch.object(localemod, with patch.object(localemod,
'_parse_localectl', '_parse_localectl',
return_value={'LANG': 'A'}): return_value={'LANG': 'A'}):
self.assertEqual('A', localemod.get_locale()) self.assertEqual('A', localemod.get_locale())
localemod._parse_localectl.assert_called_once_with() localemod._parse_localectl.assert_called_once_with()
with patch.dict(localemod.__context__, {'salt.utils.systemd.booted': False}): with patch.dict(localemod.__context__, {'salt.utils.systemd.booted': False}):
with patch.dict(localemod.__grains__, {'os_family': ['Gentoo']}): with patch.dict(localemod.__grains__, {'os_family': ['Gentoo']}):
@ -82,8 +83,9 @@ class LocalemodTestCase(TestCase):
Test for Sets the current system locale Test for Sets the current system locale
''' '''
with patch.dict(localemod.__context__, {'salt.utils.systemd.booted': True}): with patch.dict(localemod.__context__, {'salt.utils.systemd.booted': True}):
with patch.object(localemod, '_localectl_set', return_value=True): with patch.dict(localemod.__grains__, {'os_family': ['Unknown']}):
self.assertTrue(localemod.set_locale('l')) with patch.object(localemod, '_localectl_set', return_value=True):
self.assertTrue(localemod.set_locale('l'))
with patch.dict(localemod.__context__, {'salt.utils.systemd.booted': False}): with patch.dict(localemod.__context__, {'salt.utils.systemd.booted': False}):
with patch.dict(localemod.__grains__, {'os_family': ['Gentoo']}): with patch.dict(localemod.__grains__, {'os_family': ['Gentoo']}):