def test_get_locale_with_no_systemd_redhat(self): ''' Test getting current system locale with systemd and dbus available on RedHat. :return: ''' localemod.get_locale() assert localemod.__salt__['cmd.run'].call_args[0][0] == 'grep "^LANG=" /etc/sysconfig/i18n'
def test_get_locale_with_systemd_and_dbus_sle12(self): ''' Test getting current system locale with systemd and dbus available on SLE12. :return: ''' localemod.get_locale() assert localemod.__salt__['cmd.run'].call_args[0][0] == 'grep "^RC_LANG" /etc/sysconfig/language'
def test_get_locale(self): ''' Test for Get the current system locale ''' with patch.dict(localemod.__context__, {'systemd.sd_booted': True}): localemod.HAS_DBUS = True with patch.object(localemod, '_parse_dbus_locale', return_value={'LANG': 'A'}): self.assertEqual('A', localemod.get_locale()) localemod._parse_dbus_locale.assert_called_once_with() localemod.HAS_DBUS = False with patch.object(localemod, '_parse_localectl', return_value={'LANG': 'A'}): self.assertEqual('A', localemod.get_locale()) localemod._parse_localectl.assert_called_once_with() with patch.dict(localemod.__context__, {'systemd.sd_booted': False}): with patch.dict(localemod.__grains__, {'os_family': ['Gentoo']}): with patch.dict(localemod.__salt__, {'cmd.run': MagicMock(return_value='A')}): self.assertEqual(localemod.get_locale(), 'A') with patch.dict(localemod.__grains__, {'os_family': ['RedHat']}): with patch.dict(localemod.__salt__, {'cmd.run': MagicMock(return_value='A=B')}): self.assertEqual(localemod.get_locale(), 'B') with patch.dict(localemod.__grains__, {'os_family': ['Unknown']}): self.assertRaises(CommandExecutionError, localemod.get_locale)
def test_get_locale_with_no_systemd_slowlaris(self): ''' Test getting current system locale with systemd and dbus available on Solaris. :return: ''' localemod.get_locale() assert localemod.__salt__['cmd.run'].call_args[0][0] == 'grep "^LANG=" /etc/default/init'
def test_get_locale_with_no_systemd_gentoo(self): ''' Test getting current system locale with systemd and dbus available on Gentoo. :return: ''' localemod.get_locale() assert localemod.__salt__['cmd.run'].call_args[0][0] == 'eselect --brief locale show'
def test_get_locale_with_no_systemd_gentoo(self): """ Test getting current system locale with systemd and dbus available on Gentoo. :return: """ localemod.get_locale() assert (localemod.__salt__["cmd.run"].call_args[0][0] == "eselect --brief locale show")
def test_get_locale_debian(self): with patch.dict(localemod.__grains__, {'os_family': ['Debian']}): with patch.object(localemod, '_localectl_get', return_value=True): self.assertTrue(localemod.get_locale()) with patch.dict(localemod.__salt__, {'cmd.run': MagicMock(return_value='LC_ALL=C')}): self.assertEqual(localemod.get_locale(), 'C')
def test_get_locale_with_no_systemd_unknown(self): """ Test getting current system locale with systemd and dbus available on Gentoo. :return: """ with pytest.raises(CommandExecutionError) as exc_info: localemod.get_locale() assert '"DrunkDragon" is unsupported' in str(exc_info.value)
def test_get_locale_with_no_systemd_unknown(self): ''' Test getting current system locale with systemd and dbus available on Gentoo. :return: ''' with pytest.raises(CommandExecutionError) as err: localemod.get_locale() assert '"DrunkDragon" is unsupported' in six.text_type(err)
def test_get_locale_with_no_systemd_debian(self): """ Test getting current system locale with systemd and dbus available on Debian. :return: """ localemod.get_locale() assert (localemod.__salt__["cmd.run"].call_args[0][0] == 'grep "^LANG=" /etc/default/locale')
def test_get_locale(self): """ Test for Get the current system locale """ with patch.dict(localemod.__grains__, {"os_family": ["Arch"]}): with patch.object(localemod, "_localectl_get", return_value=True): self.assertTrue(localemod.get_locale()) with patch.dict(localemod.__grains__, {"os_family": ["Gentoo"]}): with patch.dict(localemod.__salt__, {"cmd.run": MagicMock(return_value="A")}): self.assertEqual(localemod.get_locale(), "A") with patch.dict(localemod.__grains__, {"os_family": ["A"]}): with patch.dict(localemod.__salt__, {"cmd.run": MagicMock(return_value="A=B")}): self.assertEqual(localemod.get_locale(), "B") with patch.dict(localemod.__grains__, {"os_family": ["A"]}): with patch.dict(localemod.__salt__, {"cmd.run": MagicMock(return_value="A")}): self.assertEqual(localemod.get_locale(), "")
def test_get_locale(self): ''' Test for Get the current system locale ''' with patch.dict(localemod.__grains__, {'os_family': ['Arch']}): with patch.object(localemod, '_locale_get', return_value=True): self.assertTrue(localemod.get_locale()) with patch.dict(localemod.__grains__, {'os_family': ['Gentoo']}): with patch.dict(localemod.__salt__, {'cmd.run': MagicMock(return_value='A')}): self.assertEqual(localemod.get_locale(), 'A') with patch.dict(localemod.__grains__, {'os_family': ['RedHat']}): with patch.dict(localemod.__salt__, {'cmd.run': MagicMock(return_value='A=B')}): self.assertEqual(localemod.get_locale(), 'B') with patch.dict(localemod.__grains__, {'os_family': ['Unknown']}): self.assertRaises(CommandExecutionError, localemod.get_locale)
def test_get_locale(self): ''' Test for Get the current system locale ''' with patch.dict(localemod.__grains__, {'os_family': ['Arch']}): with patch.object(localemod, '_localectl_get', return_value=True): self.assertTrue(localemod.get_locale()) with patch.dict(localemod.__grains__, {'os_family': ['Gentoo']}): with patch.dict(localemod.__salt__, {'cmd.run': MagicMock(return_value='A')}): self.assertEqual(localemod.get_locale(), 'A') with patch.dict(localemod.__grains__, {'os_family': ['A']}): with patch.dict(localemod.__salt__, {'cmd.run': MagicMock(return_value='A=B')}): self.assertEqual(localemod.get_locale(), 'B') with patch.dict(localemod.__grains__, {'os_family': ['A']}): with patch.dict(localemod.__salt__, {'cmd.run': MagicMock(return_value='A')}): self.assertEqual(localemod.get_locale(), '')
def test_get_locale(self): ''' Test for Get the current system locale ''' with patch.dict(localemod.__context__, {'salt.utils.systemd.booted': True}): localemod.HAS_DBUS = True with patch.object(localemod, '_parse_dbus_locale', return_value={'LANG': 'A'}): self.assertEqual('A', localemod.get_locale()) localemod._parse_dbus_locale.assert_called_once_with() localemod.HAS_DBUS = False with patch.object(localemod, '_parse_localectl', return_value={'LANG': 'A'}): self.assertEqual('A', localemod.get_locale()) localemod._parse_localectl.assert_called_once_with() with patch.dict(localemod.__context__, {'salt.utils.systemd.booted': False}): with patch.dict(localemod.__grains__, {'os_family': ['Gentoo']}): with patch.dict(localemod.__salt__, {'cmd.run': MagicMock(return_value='A')}): with patch.object(localemod, '_parse_localectl', return_value={'LANG': 'A'}): self.assertEqual(localemod.get_locale(), 'A') with patch.dict(localemod.__grains__, {'os_family': ['RedHat']}): with patch.dict(localemod.__salt__, {'cmd.run': MagicMock(return_value='A=B')}): with patch.object(localemod, '_parse_localectl', return_value={'LANG': 'B'}): self.assertEqual(localemod.get_locale(), 'B') with patch.dict(localemod.__grains__, {'os_family': ['Unknown']}): with patch.dict(localemod.__salt__, {'cmd.run': MagicMock(return_value='A=B')}): self.assertRaises(CommandExecutionError, localemod.get_locale)
def test_get_locale_with_systemd_and_dbus(self): ''' Test getting current system locale with systemd and dbus available. :return: ''' assert localemod.get_locale() == 'en_US.utf8'
def test_get_locale_with_systemd_nodbus(self): ''' Test getting current system locale with systemd but no dbus available. :return: ''' assert localemod.get_locale() == 'de_DE.utf8'