[open-ils-commits] r8181 - trunk/build/i18n/tests
svn at svn.open-ils.org
svn at svn.open-ils.org
Sun Dec 9 00:24:43 EST 2007
Author: dbs
Date: 2007-12-09 00:04:34 -0500 (Sun, 09 Dec 2007)
New Revision: 8181
Added:
trunk/build/i18n/tests/testbase.py
Log:
Unit test for generating and loading PO files.
Added: trunk/build/i18n/tests/testbase.py
===================================================================
--- trunk/build/i18n/tests/testbase.py (rev 0)
+++ trunk/build/i18n/tests/testbase.py 2007-12-09 05:04:34 UTC (rev 8181)
@@ -0,0 +1,72 @@
+#!/usr/bin/env python
+# vim: set fileencoding=utf-8 :
+"""
+Test the BaseL10N class to ensure that we have a solid foundation.
+"""
+
+import os
+import polib
+import sys
+import unittest
+
+class TestBaseL10N(unittest.TestCase):
+
+ tmpdirs = ('tmp')
+ poentries = [{
+ 'msgid': 'Using Library',
+ 'msgstr': 'Utiliser la bibliothèque',
+ 'occurences': [
+ {'line': 240, 'name': 'field.aihu.org_unit.label'},
+ {'line': 257, 'name': 'field.ancihu.org_unit.label'},
+ ]},
+ {
+ 'msgid': '\nSuper crazy long and repetitive message ID from hell\nSuper crazy long and repetitive message ID from hell\nSuper crazy long and repetitive message ID from hell\nSuper crazy long and repetitive message ID from hell\nSuper crazy long and repetitive message ID from hell',
+ 'msgstr': 'ôèàéç',
+ 'occurences': [
+ {'line': 2475, 'name': 'field.rxbt.voided.label'},
+ ]},
+ {
+ 'msgid': 'Record Source',
+ 'occurences': [
+ {'line': 524, 'name': 'field.bre.source.label'},
+ ]},
+ ]
+
+ def setUp(self):
+ sys.path.append('../scripts/')
+ self.tearDown()
+ for dir in self.tmpdirs:
+ os.mkdir(dir)
+
+ def tearDown(self):
+ for dir in self.tmpdirs:
+ if os.access(dir, os.F_OK):
+ for file in os.listdir(dir):
+ os.remove(os.path.join(dir, file))
+ os.rmdir(dir)
+
+ def testload(self):
+ """
+ Load a translated PO file and compare to a generated one
+ """
+ import basel10n
+ poload = basel10n.BaseL10N()
+ poload.loadpo('data/complex.po')
+ pogen = basel10n.BaseL10N()
+ pogen.pothead('Evergreen 1.4', '1999-12-31 23:59:59 -0400')
+ pogen.pot.metadata['PO-Revision-Date'] = '2007-12-08 23:14:20 -0400'
+ pogen.pot.metadata['Last-Translator'] = ' Dan Scott <dscott at laurentian.ca>'
+ pogen.pot.metadata['Language-Team'] = 'fr-CA <LL at li.org>'
+ for msg in self.poentries:
+ poe = polib.POEntry()
+ for x in msg['occurences']:
+ poe.occurences.append((x['line'], x['name']))
+ poe.msgid = msg['msgid']
+ if msg.has_key('msgstr'):
+ poe.msgstr = msg['msgstr']
+ pogen.pot.append(poe)
+
+ self.assertEqual(str(poload), str(pogen))
+
+if __name__ == '__main__':
+ unittest.main()
More information about the open-ils-commits
mailing list