コード例 #1
0
 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'
コード例 #2
0
 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'
コード例 #3
0
    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)
コード例 #4
0
 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'
コード例 #5
0
 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'
コード例 #6
0
ファイル: test_localemod.py プロジェクト: steverweber/salt
 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")
コード例 #7
0
    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')
コード例 #8
0
ファイル: test_localemod.py プロジェクト: steverweber/salt
 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)
コード例 #9
0
ファイル: test_localemod.py プロジェクト: yvwulei/salt
 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)
コード例 #10
0
ファイル: test_localemod.py プロジェクト: steverweber/salt
 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')
コード例 #11
0
ファイル: localemod_test.py プロジェクト: DaveQB/salt
    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(), "")
コード例 #12
0
ファイル: localemod_test.py プロジェクト: HowardMei/saltstack
    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)
コード例 #13
0
    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)
コード例 #14
0
    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(), '')
コード例 #15
0
ファイル: localemod_test.py プロジェクト: shineforever/ops
    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(), '')
コード例 #16
0
ファイル: localemod_test.py プロジェクト: bryson/salt
    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)
コード例 #17
0
ファイル: test_localemod.py プロジェクト: yvwulei/salt
 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'
コード例 #18
0
ファイル: test_localemod.py プロジェクト: yvwulei/salt
 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'