summaryrefslogtreecommitdiff
path: root/tests/unittests/test_handler/test_handler_locale.py
diff options
context:
space:
mode:
authorJuerg Haefliger <juergh@gmail.com>2013-07-17 15:46:58 -0400
committerScott Moser <smoser@ubuntu.com>2013-07-17 15:46:58 -0400
commit1edfb2a7a36a2bdddfe0ca48ba5d23721bf17a35 (patch)
tree8bfb54ecf85b55b663f9b182789141df59cc0446 /tests/unittests/test_handler/test_handler_locale.py
parent8f70bb7e7144f2225b4e9a589d16ae6d15992a3d (diff)
parent67162bca0c49d415f92aefa22972fd3ffe179da6 (diff)
downloadvyos-cloud-init-1edfb2a7a36a2bdddfe0ca48ba5d23721bf17a35.tar.gz
vyos-cloud-init-1edfb2a7a36a2bdddfe0ca48ba5d23721bf17a35.zip
adds support for SLES plus some basic unittests.
Some code from the RHEL handler was moved to a new file so that it can be used by the SLES handler.
Diffstat (limited to 'tests/unittests/test_handler/test_handler_locale.py')
-rw-r--r--tests/unittests/test_handler/test_handler_locale.py64
1 files changed, 64 insertions, 0 deletions
diff --git a/tests/unittests/test_handler/test_handler_locale.py b/tests/unittests/test_handler/test_handler_locale.py
new file mode 100644
index 00000000..72ad00fd
--- /dev/null
+++ b/tests/unittests/test_handler/test_handler_locale.py
@@ -0,0 +1,64 @@
+# Copyright (C) 2013 Hewlett-Packard Development Company, L.P.
+#
+# Author: Juerg Haefliger <juerg.haefliger@hp.com>
+#
+# Based on test_handler_set_hostname.py
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 3, as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+from cloudinit.config import cc_locale
+
+from cloudinit import cloud
+from cloudinit import distros
+from cloudinit import helpers
+from cloudinit import util
+
+from cloudinit.sources import DataSourceNoCloud
+
+from tests.unittests import helpers as t_help
+
+from configobj import ConfigObj
+
+from StringIO import StringIO
+
+import logging
+
+LOG = logging.getLogger(__name__)
+
+
+class TestLocale(t_help.FilesystemMockingTestCase):
+ def setUp(self):
+ super(TestLocale, self).setUp()
+ self.new_root = self.makeDir(prefix="unittest_")
+
+ def _get_cloud(self, distro):
+ self.patchUtils(self.new_root)
+ paths = helpers.Paths({})
+
+ cls = distros.fetch(distro)
+ d = cls(distro, {}, paths)
+ ds = DataSourceNoCloud.DataSourceNoCloud({}, d, paths)
+ cc = cloud.Cloud(ds, paths, {}, d, None)
+ return cc
+
+ def test_set_locale_sles(self):
+
+ cfg = {
+ 'locale': 'My.Locale',
+ }
+ cc = self._get_cloud('sles')
+ cc_locale.handle('cc_locale', cfg, cc, LOG, [])
+
+ contents = util.load_file('/etc/sysconfig/language')
+ n_cfg = ConfigObj(StringIO(contents))
+ self.assertEquals({'RC_LANG': cfg['locale']}, dict(n_cfg))