[open-ils-commits] r8184 - in trunk/build/i18n/tests: . data

svn at svn.open-ils.org svn at svn.open-ils.org
Sun Dec 9 13:13:56 EST 2007


Author: dbs
Date: 2007-12-09 12:53:43 -0500 (Sun, 09 Dec 2007)
New Revision: 8184

Modified:
   trunk/build/i18n/tests/data/complex.pot
   trunk/build/i18n/tests/testbase.py
Log:
Add a unit test for saving POT files


Modified: trunk/build/i18n/tests/data/complex.pot
===================================================================
--- trunk/build/i18n/tests/data/complex.pot	2007-12-09 14:19:20 UTC (rev 8183)
+++ trunk/build/i18n/tests/data/complex.pot	2007-12-09 17:53:43 UTC (rev 8184)
@@ -3,7 +3,7 @@
 msgstr ""
 "Project-Id-Version: Evergreen 1.4"
 "Report-Msgid-Bugs-To: open-ils-dev at list.georgialibraries.org"
-"POT-Creation-Date: 2007-12-06 23:16:35 -0400"
+"POT-Creation-Date: 1999-12-31 23:59:59 -0400"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE"
 "Last-Translator: FULL NAME <EMAIL at ADDRESS>"
 "Language-Team: LANGUAGE <LL at li.org>"

Modified: trunk/build/i18n/tests/testbase.py
===================================================================
--- trunk/build/i18n/tests/testbase.py	2007-12-09 14:19:20 UTC (rev 8183)
+++ trunk/build/i18n/tests/testbase.py	2007-12-09 17:53:43 UTC (rev 8184)
@@ -4,6 +4,7 @@
 Test the BaseL10N class to ensure that we have a solid foundation.
 """
 
+import filecmp
 import os
 import polib
 import sys
@@ -11,7 +12,10 @@
 
 class TestBaseL10N(unittest.TestCase):
 
-    tmpdirs = ('tmp')
+    tmpdirs = [('tmp/')]
+    savefile = ('tmp/testsave.pot')
+    canonpot = ('data/complex.pot')
+    canonpo = ('data/complex.po')
     poentries = [{
         'msgid': 'Using Library', 
         'msgstr': 'Utiliser la bibliothèque',
@@ -51,7 +55,7 @@
         """
         import basel10n
         poload = basel10n.BaseL10N()
-        poload.loadpo('data/complex.po')
+        poload.loadpo(self.canonpo)
         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'
@@ -68,5 +72,22 @@
 
         self.assertEqual(str(poload), str(pogen))
 
+    def testsavepot(self):
+        """
+        Save a generated POT file and compate to a known good one
+        """
+        import basel10n
+        pogen = basel10n.BaseL10N()
+        pogen.pothead('Evergreen 1.4', '1999-12-31 23:59:59 -0400')
+        for msg in self.poentries:
+            poe = polib.POEntry()
+            for x in msg['occurences']:
+                poe.occurences.append((x['line'], x['name']))
+            poe.msgid = msg['msgid']
+            pogen.pot.append(poe)
+        pogen.savepot(self.savefile)
+
+        self.assertEqual(filecmp.cmp(self.savefile, self.canonpot), 1)
+
 if __name__ == '__main__':
     unittest.main()



More information about the open-ils-commits mailing list