summaryrefslogtreecommitdiffstats
path: root/tests/pyanaconda_test
diff options
context:
space:
mode:
authorAles Kozumplik <akozumpl@redhat.com>2011-09-05 14:18:06 +0200
committerAles Kozumplik <akozumpl@redhat.com>2011-09-07 08:15:29 +0200
commit2dfbb942eef6c7c92ac95da671bb6fac7ad26a27 (patch)
tree9c9375de99ad6314e5b8adee5e7407a784b50d6e /tests/pyanaconda_test
parent14bfaba9f29b3347534b6dc401c7e9e1143a3414 (diff)
downloadanaconda-2dfbb942eef6c7c92ac95da671bb6fac7ad26a27.tar.gz
anaconda-2dfbb942eef6c7c92ac95da671bb6fac7ad26a27.tar.xz
anaconda-2dfbb942eef6c7c92ac95da671bb6fac7ad26a27.zip
isolate localeInfo and expandLangs() from langauges.py into a separate module.
After 0c662ebeaf4043ff2e2a1f7d09b527f4bf243047, we can not build due to imports problem during build time (importing pyanaconda.constants tries to import pyanaconda.__init__ which tries to import isys etc.). This change separates the language.py bits and the bits needed during build time. Includes new unit tests.
Diffstat (limited to 'tests/pyanaconda_test')
-rw-r--r--tests/pyanaconda_test/language_test.py12
-rw-r--r--tests/pyanaconda_test/localeinfo_test.py35
2 files changed, 41 insertions, 6 deletions
diff --git a/tests/pyanaconda_test/language_test.py b/tests/pyanaconda_test/language_test.py
index 3d4498a24..daf500b1c 100644
--- a/tests/pyanaconda_test/language_test.py
+++ b/tests/pyanaconda_test/language_test.py
@@ -13,12 +13,7 @@ class LanguageTest(mock.TestCase):
self.fs = mock.DiskIO()
def fake_os_access(path, _):
- return path == 'lang-table' or path == 'lang-names'
-
- self.fs.open('lang-table', 'w').write(
- "Czech cs latarcyrheb-sun16 cs_CZ.UTF-8 cz-lat2 Europe/Prague\n"
- "English en latarcyrheb-sun16 en_US.UTF-8 us America/New_York\n"
- "Hebrew he none he_IL.UTF-8 us Asia/Jerusalem")
+ return path == 'lang-names'
self.fs.open('lang-names', 'w').write(
"Czech\tCestina\n"
@@ -33,6 +28,11 @@ class LanguageTest(mock.TestCase):
pyanaconda.language.os.access = fake_os_access
pyanaconda.language.os.environ = {'LANG': ENVIRON_LANG}
pyanaconda.language.locale = mock.Mock()
+ pyanaconda.language.localeinfo.get = mock.Mock(return_value={
+ 'C': ('English', 'en', 'latarcyrheb-sun16', 'us', 'America/New_York'),
+ 'cs_CZ.UTF-8': ('Czech', 'cs', 'latarcyrheb-sun16', 'cz-lat2', 'Europe/Prague'),
+ 'en_US.UTF-8': ('English', 'en', 'latarcyrheb-sun16', 'us', 'America/New_York'),
+ 'he_IL.UTF-8': ('Hebrew', 'he', 'none', 'us', 'Asia/Jerusalem')})
def tearDown(self):
self.tearDownModules()
diff --git a/tests/pyanaconda_test/localeinfo_test.py b/tests/pyanaconda_test/localeinfo_test.py
new file mode 100644
index 000000000..32f09164d
--- /dev/null
+++ b/tests/pyanaconda_test/localeinfo_test.py
@@ -0,0 +1,35 @@
+import mock
+
+class LocaleinfoTest(mock.TestCase):
+ def setUp(self):
+ self.setupModules(
+ ['_isys', 'logging', 'pyanaconda.anaconda_log', 'block'])
+
+ import pyanaconda
+ pyanaconda.anaconda_log = mock.Mock()
+
+ def tearDown(self):
+ self.tearDownModules()
+
+ def expandLangs_test(self):
+ from pyanaconda import localeinfo
+ exp = localeinfo.expandLangs("fr_FR.utf8@euro")
+ self.assertEqual(exp, ['fr_FR.utf8@euro', 'fr_FR', 'fr@euro', 'fr'])
+
+ def get_test(self):
+ from pyanaconda import localeinfo
+
+ fs = mock.DiskIO()
+ fs['/lang-table'] = """
+Czech cs latarcyrheb-sun16 cs_CZ.UTF-8 cz-lat2 Europe/Prague\n
+English en latarcyrheb-sun16 en_US.UTF-8 us America/New_York\n
+Hebrew he none he_IL.UTF-8 us Asia/Jerusalem"""
+ self.take_over_io(fs, localeinfo)
+
+ info = localeinfo.get("en_US.UTF-8")
+ self.assertEqual(
+ info,
+ {'C': ('English', 'en', 'latarcyrheb-sun16', 'us', 'America/New_York'),
+ 'cs_CZ.UTF-8': ('Czech', 'cs', 'latarcyrheb-sun16', 'cz-lat2', 'Europe/Prague'),
+ 'en_US.UTF-8': ('English', 'en', 'latarcyrheb-sun16', 'us', 'America/New_York'),
+ 'he_IL.UTF-8': ('Hebrew', 'he', 'none', 'us', 'Asia/Jerusalem')})