summaryrefslogtreecommitdiff
path: root/tests/unittests/test_handler/test_handler_debug.py
diff options
context:
space:
mode:
authorRyan Harper <ryan.harper@canonical.com>2017-08-16 16:50:07 -0500
committerScott Moser <smoser@brickies.net>2017-08-30 21:10:08 -0400
commit7e76c57b590c7c2c13f7b1a2a8b5b7d4f2d18396 (patch)
treef0eb82212d46bc6373e104c864ab9810663a7417 /tests/unittests/test_handler/test_handler_debug.py
parent300e4516f78dbb0a9533749aa84f7e366b023d04 (diff)
downloadvyos-cloud-init-7e76c57b590c7c2c13f7b1a2a8b5b7d4f2d18396.tar.gz
vyos-cloud-init-7e76c57b590c7c2c13f7b1a2a8b5b7d4f2d18396.zip
distro: allow distro to specify a default locale
Currently the cloud-init default locale (en_US.UTF-8) is set by the base datasource class. This patch allows a distro to overide the fallback value with one that's available in the distro but continues to respect an image which has preconfigured a locale. - Distro object now has a get_locale method which will return a preconfigure locale setting by checking the distros locale system configuration file. If not set or not present, return the default locale of en_US.UTF-8 which retains behavior of all previous cloud-init releases. - Apply locale now handles regenerating locales or system configuration files as needed. - Adjust apply_locale logic to skip locale-regen if the specified LANG value is C.UTF-8,C, or POSIX; they do not require regeneration. - Further add unittests to exercise the default paths for Ubuntu and non-ubuntu paths to validate they get the LANG expected.
Diffstat (limited to 'tests/unittests/test_handler/test_handler_debug.py')
-rw-r--r--tests/unittests/test_handler/test_handler_debug.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/tests/unittests/test_handler/test_handler_debug.py b/tests/unittests/test_handler/test_handler_debug.py
index 929f786e..1873c3e1 100644
--- a/tests/unittests/test_handler/test_handler_debug.py
+++ b/tests/unittests/test_handler/test_handler_debug.py
@@ -11,7 +11,7 @@ from cloudinit import util
from cloudinit.sources import DataSourceNone
-from .. import helpers as t_help
+from ..helpers import (FilesystemMockingTestCase, mock)
import logging
import shutil
@@ -20,7 +20,8 @@ import tempfile
LOG = logging.getLogger(__name__)
-class TestDebug(t_help.FilesystemMockingTestCase):
+@mock.patch('cloudinit.distros.debian.read_system_locale')
+class TestDebug(FilesystemMockingTestCase):
def setUp(self):
super(TestDebug, self).setUp()
self.new_root = tempfile.mkdtemp()
@@ -36,7 +37,8 @@ class TestDebug(t_help.FilesystemMockingTestCase):
ds.metadata.update(metadata)
return cloud.Cloud(ds, paths, {}, d, None)
- def test_debug_write(self):
+ def test_debug_write(self, m_locale):
+ m_locale.return_value = 'en_US.UTF-8'
cfg = {
'abc': '123',
'c': u'\u20a0',
@@ -54,7 +56,8 @@ class TestDebug(t_help.FilesystemMockingTestCase):
for k in cfg.keys():
self.assertIn(k, contents)
- def test_debug_no_write(self):
+ def test_debug_no_write(self, m_locale):
+ m_locale.return_value = 'en_US.UTF-8'
cfg = {
'abc': '123',
'debug': {