Add a unit test for saving POT files
authordbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sun, 9 Dec 2007 17:53:43 +0000 (17:53 +0000)
committerdbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sun, 9 Dec 2007 17:53:43 +0000 (17:53 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@8184 dcc99617-32d9-48b4-a31d-7c20da2025e4

build/i18n/tests/data/complex.pot
build/i18n/tests/testbase.py

index cb4ddc7..661f9f9 100644 (file)
@@ -3,7 +3,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: Evergreen 1.4"
 "Report-Msgid-Bugs-To: open-ils-dev@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@ADDRESS>"
 "Language-Team: LANGUAGE <LL@li.org>"
index a0e8133..d79fa70 100644 (file)
@@ -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 @@ import unittest
 
 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 @@ class TestBaseL10N(unittest.TestCase):
         """
         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 @@ class TestBaseL10N(unittest.TestCase):
 
         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()