Test suite for fieldmapper IDL i18n (and a fix - yay, tests).
authordbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 10 Dec 2007 02:23:11 +0000 (02:23 +0000)
committerdbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 10 Dec 2007 02:23:11 +0000 (02:23 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@8187 dcc99617-32d9-48b4-a31d-7c20da2025e4

build/i18n/scripts/fieldmapper.py
build/i18n/tests/data/testidl.ent [new file with mode: 0644]
build/i18n/tests/data/testidl.po [new file with mode: 0644]
build/i18n/tests/data/testidl.pot [new file with mode: 0644]
build/i18n/tests/data/testidl.xml [new file with mode: 0644]
build/i18n/tests/data/testidlent.xml [new file with mode: 0644]
build/i18n/tests/testIDL.py [new file with mode: 0644]
build/i18n/tests/testbase.py

index 4f1874e..38888a9 100755 (executable)
@@ -101,10 +101,11 @@ class IDLHandler(xml.sax.handler.ContentHandler):
         xml.sax.handler.ContentHandler.__init__(self)
         self.entities = dict()
         self.classid = None
-        self.entityized = u"<?xml version=\"1.0\" encoding=\"utf-8\"?>" \
-            "<!DOCTYPE fieldmapper [" \
-            "<!--#include virtual=\"/opac/locale/${locale}/fm_IDL.dtd\"--> " \
-            "]>"
+        self.entityized = u"""<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE fieldmapper [
+    <!--#include virtual="/opac/locale/${locale}/fm_IDL.dtd"--> 
+]>
+"""
         self.locator = None
 
     def setDocumentLocator(self, locator):
@@ -130,9 +131,9 @@ class IDLHandler(xml.sax.handler.ContentHandler):
                     attributes['name'])
             label = attributes['reporter:label']
             if not self.entities.has_key(label):
-                self.entities[label] = [(lineno, str(entity))]
+                self.entities[label] = [(str(entity), lineno)]
             else:
-                self.entities[label].append((lineno, str(entity)))
+                self.entities[label].append((str(entity), lineno))
 
         # Now we'll render an entity-ized version of this element
         element = "<%s" % (name)
@@ -198,7 +199,7 @@ def main():
         if options.outfile:
             outfile = open(options.outfile, 'w')
             for entity in pot.definitions: 
-                outfile.write(entity)
+                outfile.write(entity + "\n")
         else:
             for entity in pot.definitions:
                 print(entity)
@@ -206,7 +207,7 @@ def main():
     elif options.convert:
         pot.get_strings(options.convert)
         if options.outfile:
-            outfile = open(options.outfile)
+            outfile = open(options.outfile, 'w')
             outfile.write(pot.idl)
         else:
             sys.stdout.write(pot.idl)
diff --git a/build/i18n/tests/data/testidl.ent b/build/i18n/tests/data/testidl.ent
new file mode 100644 (file)
index 0000000..6094c58
--- /dev/null
@@ -0,0 +1,42 @@
+<!ENTITY field.auoi.org_unit.label "Lorem ipsum">
+<!ENTITY field.rodcirc.checkin_staff.label "dolor sit amet">
+<!ENTITY class.rodcirc.label "consectetuer adipiscing elit">
+<!ENTITY field.rodcirc.stop_fines_time.label "Quisque suscipit">
+<!ENTITY field.rodcirc.checkin_lib.label "magna non dui">
+<!ENTITY field.rodcirc.circ_type.label "Integer urna">
+<!ENTITY field.rodcirc.fine_interval.label "Ut √©lementum">
+<!ENTITY field.rodcirc.billing_total.label "ante sed velit">
+<!ENTITY field.rodcirc.duration.label "Quisque pharetra">
+<!ENTITY field.aws.name.label "lectus vitae aliquam">
+<!ENTITY class.auoi.label "venenatis, mi nisl">
+<!ENTITY field.rodcirc.recuring_fine_rule.label "suscipit sapien, eu sollicitudin">
+<!ENTITY field.rodcirc.duration_rule.label "neque dolor a nulla">
+<!ENTITY field.auoi.id.label "Phasellus aliquam vulputate justo">
+<!ENTITY field.rodcirc.payment_total.label "Proin augue libero">
+<!ENTITY field.rodcirc.phone_renewal.label "hendrerit pretium">
+<!ENTITY field.rodcirc.circ_lib.label "rutrum pretium">
+<!ENTITY field.rodcirc.max_fine.label "commodo nec, neque">
+<!ENTITY field.rodcirc.xact_finish.label "Vestibulum ante ipsum">
+<!ENTITY field.auoi.usr.label "primis">
+<!ENTITY field.auoi.opt_in_ws.label "in faucibus orci luctus">
+<!ENTITY class.aws.label "in faucibus orci luctus">
+<!ENTITY field.rodcirc.stop_fines.label "ultrices posuere cubilia Curae">
+<!ENTITY field.rodcirc.opac_renewal.label "Sed vel lectus">
+<!ENTITY field.rodcirc.circ_staff.label "Ut dictum mollis turpis">
+<!ENTITY field.rodcirc.payments.label "Proin et orci">
+<!ENTITY field.rodcirc.checkin_time.label "Phasellus vel justo">
+<!ENTITY field.rodcirc.max_fine_rule.label "ultricies quam">
+<!ENTITY field.rodcirc.xact_start.label "lacinia accumsan">
+<!ENTITY field.rodcirc.billable_transaction.label "Nullam imperdiet">
+<!ENTITY field.rodcirc.recuring_fine.label "tincidunt mauris">
+<!ENTITY field.auoi.staff.label "Staff Member">
+<!ENTITY field.aws.id.label "Workstation ID">
+<!ENTITY field.rodcirc.usr.label "Mauris ac diam">
+<!ENTITY field.rodcirc.due_date.label "Nam egestas bibendum lectus">
+<!ENTITY field.rodcirc.billings.label "Praesent hendrerit">
+<!ENTITY field.auoi.opt_in_ts.label "sapien id velit nonummy">
+<!ENTITY field.rodcirc.desk_renewal.label "congue, neque">
+<!ENTITY field.rodcirc.target_copy.label "ut ullamcorper faucibus">
+<!ENTITY field.rodcirc.renewal_remaining.label "diam felis">
+<!ENTITY field.aws.owning_lib.label "Owning Library">
+<!ENTITY field.rodcirc.id.label "pulvinar augue">
diff --git a/build/i18n/tests/data/testidl.po b/build/i18n/tests/data/testidl.po
new file mode 100644 (file)
index 0000000..886c18b
--- /dev/null
@@ -0,0 +1,176 @@
+# 
+msgid ""
+msgstr ""
+"Project-Id-Version: Evergreen 1.4"
+"Report-Msgid-Bugs-To: open-ils-dev@list.georgialibraries.org"
+"POT-Creation-Date: 
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>"
+"Language-Team: LANGUAGE <LL@li.org>"
+"MIME-Version: 1.0"
+"Content-Type: text/plain; charset=utf-8"
+"Content-Transfer-Encoding: 8-bit"
+
+#: field.auoi.org_unit.label:29
+msgid "Allowed Org Unit"
+msgstr "Lorem ipsum"
+
+#: field.rodcirc.checkin_staff.label:58
+msgid "Check In Staff"
+msgstr "dolor sit amet"
+
+#: class.rodcirc.label:52
+msgid "Overdue Circulation"
+msgstr "consectetuer adipiscing elit"
+
+#: field.rodcirc.stop_fines_time.label:76
+msgid "Fine Stop Date/Time"
+msgstr "Quisque suscipit"
+
+#: field.rodcirc.checkin_lib.label:57
+msgid "Check In Library"
+msgstr "magna non dui"
+
+#: field.rodcirc.circ_type.label:84
+msgid "Circulation Type"
+msgstr "Integer urna"
+
+#: field.rodcirc.fine_interval.label:66
+msgid "Fine Interval"
+msgstr "Ut √©lementum"
+
+#: field.rodcirc.billing_total.label:85
+msgid "Billing Totals"
+msgstr "ante sed velit"
+
+#: field.rodcirc.duration.label:64
+msgid "Circulation Duration"
+msgstr "Quisque pharetra"
+
+#: field.aws.name.label:45
+msgid "Workstation Name"
+msgstr "lectus vitae aliquam"
+
+#: class.auoi.label:20
+msgid "User Sharing Opt-in"
+msgstr "venenatis, mi nisl"
+
+#: field.rodcirc.recuring_fine_rule.label:73
+msgid "Recurring Fine Rule"
+msgstr "suscipit sapien, eu sollicitudin"
+
+#: field.rodcirc.duration_rule.label:65
+msgid "Circ Duration Rule"
+msgstr "neque dolor a nulla"
+
+#: field.auoi.id.label:25
+msgid "Opt-in ID"
+msgstr "Phasellus aliquam vulputate justo"
+
+#: field.rodcirc.payment_total.label:86
+msgid "Payment Totals"
+msgstr "Proin augue libero"
+
+#: field.rodcirc.phone_renewal.label:71
+msgid "Phone Renewal"
+msgstr "hendrerit pretium"
+
+#: field.rodcirc.circ_lib.label:60
+msgid "Circulating Library"
+msgstr "rutrum pretium"
+
+#: field.rodcirc.max_fine.label:68
+msgid "Max Fine Amount"
+msgstr "commodo nec, neque"
+
+#: field.rodcirc.xact_finish.label:79
+msgid "Transaction Finish Date/Time"
+msgstr "Vestibulum ante ipsum"
+
+#: field.auoi.usr.label:28
+msgid "User"
+msgstr "primis"
+
+#: field.auoi.opt_in_ws.label:39 class.aws.label:26
+msgid "Workstation"
+msgstr "in faucibus orci luctus"
+
+#: field.rodcirc.stop_fines.label:75
+msgid "Fine Stop Reason"
+msgstr "ultrices posuere cubilia Curae"
+
+#: field.rodcirc.opac_renewal.label:70
+msgid "OPAC Renewal"
+msgstr "Sed vel lectus"
+
+#: field.rodcirc.circ_staff.label:61
+msgid "Circulating Staff"
+msgstr "Ut dictum mollis turpis"
+
+#: field.rodcirc.payments.label:82
+msgid "Transaction Payments"
+msgstr "Proin et orci"
+
+#: field.rodcirc.checkin_time.label:59
+msgid "Check In Date/Time"
+msgstr "Phasellus vel justo"
+
+#: field.rodcirc.max_fine_rule.label:69
+msgid "Max Fine Rule"
+msgstr "ultricies quam"
+
+#: field.rodcirc.xact_start.label:80
+msgid "Check Out Date/Time"
+msgstr "lacinia accumsan"
+
+#: field.rodcirc.billable_transaction.label:83
+msgid "Base Transaction"
+msgstr "Nullam imperdiet"
+
+#: field.rodcirc.recuring_fine.label:72
+msgid "Recurring Fine Amount"
+msgstr "tincidunt mauris"
+
+#: field.auoi.staff.label:27
+msgid "Staff Member"
+msgstr ""
+
+#: field.aws.id.label:44
+msgid "Workstation ID"
+msgstr ""
+
+#: field.rodcirc.usr.label:78
+msgid "Patron"
+msgstr "Mauris ac diam"
+
+#: field.rodcirc.due_date.label:63
+msgid "Due Date/Time"
+msgstr "Nam egestas bibendum lectus"
+
+#: field.rodcirc.billings.label:81
+msgid "Transaction Billings"
+msgstr "Praesent hendrerit"
+
+#: field.auoi.opt_in_ts.label:30
+msgid "Opt-in Date/Time"
+msgstr "sapien id velit nonummy"
+
+#: field.rodcirc.desk_renewal.label:62
+msgid "Desk Renewal"
+msgstr "congue, neque"
+
+#: field.rodcirc.target_copy.label:77
+msgid "Circulating Item"
+msgstr "ut ullamcorper faucibus"
+
+#: field.rodcirc.renewal_remaining.label:74
+msgid "Remaining Renewals"
+msgstr "diam felis"
+
+#: field.aws.owning_lib.label:46
+msgid "Owning Library"
+msgstr ""
+
+#: field.rodcirc.id.label:67
+msgid "Circ ID"
+msgstr "pulvinar augue"
diff --git a/build/i18n/tests/data/testidl.pot b/build/i18n/tests/data/testidl.pot
new file mode 100644 (file)
index 0000000..efb2adb
--- /dev/null
@@ -0,0 +1,176 @@
+# 
+msgid ""
+msgstr ""
+"Project-Id-Version: Evergreen 1.4"
+"Report-Msgid-Bugs-To: open-ils-dev@list.georgialibraries.org"
+"POT-Creation-Date: 
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>"
+"Language-Team: LANGUAGE <LL@li.org>"
+"MIME-Version: 1.0"
+"Content-Type: text/plain; charset=utf-8"
+"Content-Transfer-Encoding: 8-bit"
+
+#: 29:field.auoi.org_unit.label
+msgid "Allowed Org Unit"
+msgstr ""
+
+#: 58:field.rodcirc.checkin_staff.label
+msgid "Check In Staff"
+msgstr ""
+
+#: 52:class.rodcirc.label
+msgid "Overdue Circulation"
+msgstr ""
+
+#: 76:field.rodcirc.stop_fines_time.label
+msgid "Fine Stop Date/Time"
+msgstr ""
+
+#: 57:field.rodcirc.checkin_lib.label
+msgid "Check In Library"
+msgstr ""
+
+#: 84:field.rodcirc.circ_type.label
+msgid "Circulation Type"
+msgstr ""
+
+#: 66:field.rodcirc.fine_interval.label
+msgid "Fine Interval"
+msgstr ""
+
+#: 85:field.rodcirc.billing_total.label
+msgid "Billing Totals"
+msgstr ""
+
+#: 64:field.rodcirc.duration.label
+msgid "Circulation Duration"
+msgstr ""
+
+#: 45:field.aws.name.label
+msgid "Workstation Name"
+msgstr ""
+
+#: 20:class.auoi.label
+msgid "User Sharing Opt-in"
+msgstr ""
+
+#: 73:field.rodcirc.recuring_fine_rule.label
+msgid "Recurring Fine Rule"
+msgstr ""
+
+#: 65:field.rodcirc.duration_rule.label
+msgid "Circ Duration Rule"
+msgstr ""
+
+#: 25:field.auoi.id.label
+msgid "Opt-in ID"
+msgstr ""
+
+#: 86:field.rodcirc.payment_total.label
+msgid "Payment Totals"
+msgstr ""
+
+#: 71:field.rodcirc.phone_renewal.label
+msgid "Phone Renewal"
+msgstr ""
+
+#: 60:field.rodcirc.circ_lib.label
+msgid "Circulating Library"
+msgstr ""
+
+#: 68:field.rodcirc.max_fine.label
+msgid "Max Fine Amount"
+msgstr ""
+
+#: 79:field.rodcirc.xact_finish.label
+msgid "Transaction Finish Date/Time"
+msgstr ""
+
+#: 28:field.auoi.usr.label
+msgid "User"
+msgstr ""
+
+#: 26:field.auoi.opt_in_ws.label 39:class.aws.label
+msgid "Workstation"
+msgstr ""
+
+#: 75:field.rodcirc.stop_fines.label
+msgid "Fine Stop Reason"
+msgstr ""
+
+#: 70:field.rodcirc.opac_renewal.label
+msgid "OPAC Renewal"
+msgstr ""
+
+#: 61:field.rodcirc.circ_staff.label
+msgid "Circulating Staff"
+msgstr ""
+
+#: 82:field.rodcirc.payments.label
+msgid "Transaction Payments"
+msgstr ""
+
+#: 59:field.rodcirc.checkin_time.label
+msgid "Check In Date/Time"
+msgstr ""
+
+#: 69:field.rodcirc.max_fine_rule.label
+msgid "Max Fine Rule"
+msgstr ""
+
+#: 80:field.rodcirc.xact_start.label
+msgid "Check Out Date/Time"
+msgstr ""
+
+#: 83:field.rodcirc.billable_transaction.label
+msgid "Base Transaction"
+msgstr ""
+
+#: 72:field.rodcirc.recuring_fine.label
+msgid "Recurring Fine Amount"
+msgstr ""
+
+#: 27:field.auoi.staff.label
+msgid "Staff Member"
+msgstr ""
+
+#: 44:field.aws.id.label
+msgid "Workstation ID"
+msgstr ""
+
+#: 78:field.rodcirc.usr.label
+msgid "Patron"
+msgstr ""
+
+#: 63:field.rodcirc.due_date.label
+msgid "Due Date/Time"
+msgstr ""
+
+#: 81:field.rodcirc.billings.label
+msgid "Transaction Billings"
+msgstr ""
+
+#: 30:field.auoi.opt_in_ts.label
+msgid "Opt-in Date/Time"
+msgstr ""
+
+#: 62:field.rodcirc.desk_renewal.label
+msgid "Desk Renewal"
+msgstr ""
+
+#: 77:field.rodcirc.target_copy.label
+msgid "Circulating Item"
+msgstr ""
+
+#: 74:field.rodcirc.renewal_remaining.label
+msgid "Remaining Renewals"
+msgstr ""
+
+#: 46:field.aws.owning_lib.label
+msgid "Owning Library"
+msgstr ""
+
+#: 67:field.rodcirc.id.label
+msgid "Circ ID"
+msgstr ""
diff --git a/build/i18n/tests/data/testidl.xml b/build/i18n/tests/data/testidl.xml
new file mode 100644 (file)
index 0000000..b8c9c83
--- /dev/null
@@ -0,0 +1,106 @@
+<IDL xmlns="http://opensrf.org/spec/IDL/base/v1" xmlns:oils_persist="http://open-ils.org/spec/opensrf/IDL/persistence/v1" xmlns:oils_obj="http://open-ils.org/spec/opensrf/IDL/objects/v1" xmlns:reporter="http://open-ils.org/spec/opensrf/IDL/reporter/v1">
+
+       <!-- Virtual classes -->
+       <class id="mups" controller="open-ils.cstore" oils_obj:fieldmapper="money::user_payment_summary" oils_persist:virtual="true">
+               <fields>
+                       <field name="isnew" oils_obj:array_position="0" oils_persist:virtual="true" />
+                       <field name="ischanged" oils_obj:array_position="1" oils_persist:virtual="true" />
+                       <field name="isdeleted" oils_obj:array_position="2" oils_persist:virtual="true" />
+                       <field name="usr" oils_obj:array_position="3" oils_persist:virtual="true" />
+                       <field name="forgive_payment" oils_obj:array_position="4" oils_persist:virtual="true" />
+                       <field name="work_payment" oils_obj:array_position="5" oils_persist:virtual="true" />
+                       <field name="credit_payment" oils_obj:array_position="6" oils_persist:virtual="true" />
+                       <field name="goods_payment" oils_obj:array_position="7" oils_persist:virtual="true" />
+               </fields>
+               <links>
+                       <link field="usr" reltype="has_a" key="id" map="" class="au"/>
+               </links>
+       </class>
+       <!-- Actually in the DB -->
+       <class id="auoi" controller="open-ils.cstore" oils_obj:fieldmapper="actor::usr_org_unit_opt_in" oils_persist:tablename="actor.usr_org_unit_opt_in" reporter:label="User Sharing Opt-in">
+               <fields oils_persist:primary="id" oils_persist:sequence="actor.usr_org_unit_opt_in_id_seq">
+                       <field name="isnew" oils_obj:array_position="0" oils_persist:virtual="true" />
+                       <field name="ischanged" oils_obj:array_position="1" oils_persist:virtual="true" />
+                       <field name="isdeleted" oils_obj:array_position="2" oils_persist:virtual="true" />
+                       <field reporter:label="Opt-in ID" name="id" oils_obj:array_position="3" oils_persist:virtual="false" reporter:datatype="id"/>
+                       <field reporter:label="Workstation" name="opt_in_ws" oils_obj:array_position="4" oils_persist:virtual="false" reporter:datatype="link"/>
+                       <field reporter:label="Staff Member" name="staff" oils_obj:array_position="5" oils_persist:virtual="false" reporter:datatype="link"/>
+                       <field reporter:label="User" name="usr" oils_obj:array_position="6" oils_persist:virtual="false" reporter:datatype="link"/>
+                       <field reporter:label="Allowed Org Unit" name="org_unit" oils_obj:array_position="7" oils_persist:virtual="false" reporter:datatype="link"/>
+                       <field reporter:label="Opt-in Date/Time" name="opt_in_ts" oils_obj:array_position="8" oils_persist:virtual="false" reporter:datatype="timestamp"/>
+               </fields>
+               <links>
+                       <link field="org_unit" reltype="has_a" key="id" map="" class="aou"/>
+                       <link field="usr" reltype="has_a" key="id" map="" class="au"/>
+                       <link field="staff" reltype="has_a" key="id" map="" class="au"/>
+                       <link field="opt_in_ws" reltype="has_a" key="id" map="" class="aws"/>
+               </links>
+       </class>
+       <class id="aws" controller="open-ils.cstore" oils_obj:fieldmapper="actor::workstation" oils_persist:tablename="actor.workstation" reporter:label="Workstation">
+               <fields oils_persist:primary="id" oils_persist:sequence="actor.workstation_id_seq">
+                       <field name="isnew" oils_obj:array_position="0" oils_persist:virtual="true" />
+                       <field name="ischanged" oils_obj:array_position="1" oils_persist:virtual="true" />
+                       <field name="isdeleted" oils_obj:array_position="2" oils_persist:virtual="true" />
+                       <field reporter:label="Workstation ID" name="id" oils_obj:array_position="3" oils_persist:virtual="false" reporter:datatype="id"/>
+                       <field reporter:label="Workstation Name" name="name" oils_obj:array_position="4" oils_persist:virtual="false" reporter:datatype="text"/>
+                       <field reporter:label="Owning Library" name="owning_lib" oils_obj:array_position="5" oils_persist:virtual="false"  reporter:datatype="org_unit"/>
+               </fields>
+               <links>
+                       <link field="owning_lib" reltype="has_a" key="id" map="" class="aou"/>
+               </links>
+       </class>
+       <class id="rodcirc" controller="open-ils.reporter-store" oils_obj:fieldmapper="reporter::overdue_circs" oils_persist:tablename="reporter.overdue_circs" reporter:core="true" reporter:label="Overdue Circulation">
+               <fields oils_persist:primary="id" oils_persist:sequence="money.billable_xact_id_seq">
+                       <field name="isnew" oils_obj:array_position="0" oils_persist:virtual="true" />
+                       <field name="ischanged" oils_obj:array_position="1" oils_persist:virtual="true" />
+                       <field name="isdeleted" oils_obj:array_position="2" oils_persist:virtual="true" />
+                       <field reporter:label="Check In Library" name="checkin_lib" oils_obj:array_position="3" oils_persist:virtual="false" reporter:datatype="org_unit"/>
+                       <field reporter:label="Check In Staff" name="checkin_staff" oils_obj:array_position="4" oils_persist:virtual="false" reporter:datatype="link"/>
+                       <field reporter:label="Check In Date/Time" name="checkin_time" oils_obj:array_position="5" oils_persist:virtual="false" reporter:datatype="timestamp"/>
+                       <field reporter:label="Circulating Library" name="circ_lib" oils_obj:array_position="6" oils_persist:virtual="false"  reporter:datatype="org_unit"/>
+                       <field reporter:label="Circulating Staff" name="circ_staff" oils_obj:array_position="7" oils_persist:virtual="false" reporter:datatype="link"/>
+                       <field reporter:label="Desk Renewal" name="desk_renewal" oils_obj:array_position="8" oils_persist:virtual="false" reporter:datatype="bool"/>
+                       <field reporter:label="Due Date/Time" name="due_date" oils_obj:array_position="9" oils_persist:virtual="false" reporter:datatype="timestamp"/>
+                       <field reporter:label="Circulation Duration" name="duration" oils_obj:array_position="10" oils_persist:virtual="false" reporter:datatype="interval"/>
+                       <field reporter:label="Circ Duration Rule" name="duration_rule" oils_obj:array_position="11" oils_persist:virtual="false" reporter:datatype="link"/>
+                       <field reporter:label="Fine Interval" name="fine_interval" oils_obj:array_position="12" oils_persist:virtual="false" reporter:datatype="interval"/>
+                       <field reporter:label="Circ ID" name="id" oils_obj:array_position="13" oils_persist:virtual="false" reporter:datatype="id" />
+                       <field reporter:label="Max Fine Amount" name="max_fine" oils_obj:array_position="14" oils_persist:virtual="false" reporter:datatype="money" />
+                       <field reporter:label="Max Fine Rule" name="max_fine_rule" oils_obj:array_position="15" oils_persist:virtual="false" reporter:datatype="link"/>
+                       <field reporter:label="OPAC Renewal" name="opac_renewal" oils_obj:array_position="16" oils_persist:virtual="false" reporter:datatype="bool"/>
+                       <field reporter:label="Phone Renewal" name="phone_renewal" oils_obj:array_position="17" oils_persist:virtual="false" reporter:datatype="bool"/>
+                       <field reporter:label="Recurring Fine Amount" name="recuring_fine" oils_obj:array_position="18" oils_persist:virtual="false" reporter:datatype="money" />
+                       <field reporter:label="Recurring Fine Rule" name="recuring_fine_rule" oils_obj:array_position="19" oils_persist:virtual="false" reporter:datatype="link"/>
+                       <field reporter:label="Remaining Renewals" name="renewal_remaining" oils_obj:array_position="20" oils_persist:virtual="false" reporter:datatype="int" />
+                       <field reporter:label="Fine Stop Reason" name="stop_fines" oils_obj:array_position="21" oils_persist:virtual="false" reporter:datatype="text"/>
+                       <field reporter:label="Fine Stop Date/Time" name="stop_fines_time" oils_obj:array_position="22" oils_persist:virtual="false" reporter:datatype="timestamp"/>
+                       <field reporter:label="Circulating Item" name="target_copy" oils_obj:array_position="23" oils_persist:virtual="false" reporter:datatype="link"/>
+                       <field reporter:label="Patron" name="usr" oils_obj:array_position="24" oils_persist:virtual="false" reporter:datatype="link"/>
+                       <field reporter:label="Transaction Finish Date/Time" name="xact_finish" oils_obj:array_position="25" oils_persist:virtual="false" reporter:datatype="timestamp" />
+                       <field reporter:label="Check Out Date/Time" name="xact_start" oils_obj:array_position="26" oils_persist:virtual="false" reporter:datatype="timestamp" />
+                       <field reporter:label="Transaction Billings" name="billings" oils_obj:array_position="27" oils_persist:virtual="true" reporter:datatype="link"/>
+                       <field reporter:label="Transaction Payments" name="payments" oils_obj:array_position="28" oils_persist:virtual="true" reporter:datatype="link"/>
+                       <field reporter:label="Base Transaction" name="billable_transaction" oils_obj:array_position="29" oils_persist:virtual="true" reporter:datatype="link"/>
+                       <field reporter:label="Circulation Type" name="circ_type" oils_obj:array_position="30" oils_persist:virtual="true" reporter:datatype="text"/>
+                       <field reporter:label="Billing Totals" name="billing_total" oils_obj:array_position="31" oils_persist:virtual="true" reporter:datatype="money"/>
+                       <field reporter:label="Payment Totals" name="payment_total" oils_obj:array_position="32" oils_persist:virtual="true" reporter:datatype="money"/>
+               </fields>
+               <links>
+                       <link field="billable_transaction" reltype="might_have" key="id" map="" class="mbt"/>
+                       <link field="circ_staff" reltype="has_a" key="id" map="" class="au"/>
+                       <link field="checkin_lib" reltype="has_a" key="id" map="" class="aou"/>
+                       <link field="target_copy" reltype="has_a" key="id" map="" class="acp"/>
+                       <link field="checkin_staff" reltype="has_a" key="id" map="" class="au"/>
+                       <link field="usr" reltype="has_a" key="id" map="" class="au"/>
+                       <link field="circ_lib" reltype="has_a" key="id" map="" class="aou"/>
+                       <link field="payments" reltype="has_many" key="xact" map="" class="mp"/>
+                       <link field="billings" reltype="has_many" key="xact" map="" class="mb"/>
+                       <link field="duration_rule" reltype="has_a" key="name" map="" class="crcd"/>
+                       <link field="max_fine_rule" reltype="has_a" key="name" map="" class="crmf"/>
+                       <link field="recuring_fine_rule" reltype="has_a" key="name" map="" class="crrf"/>
+                       <link field="circ_type" reltype="might_have" key="id" map="" class="rcirct"/>
+                       <link field="billing_total" reltype="might_have" key="xact" map="" class="rxbt"/>
+                       <link field="payment_total" reltype="might_have" key="xact" map="" class="rxpt"/>
+               </links>
+       </class>
+</IDL>
diff --git a/build/i18n/tests/data/testidlent.xml b/build/i18n/tests/data/testidlent.xml
new file mode 100644 (file)
index 0000000..edc6764
--- /dev/null
@@ -0,0 +1,110 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE fieldmapper [
+    <!--#include virtual="/opac/locale/${locale}/fm_IDL.dtd"--> 
+]>
+<IDL xmlns:reporter='http://open-ils.org/spec/opensrf/IDL/reporter/v1' xmlns:oils_obj='http://open-ils.org/spec/opensrf/IDL/objects/v1' xmlns='http://opensrf.org/spec/IDL/base/v1' xmlns:oils_persist='http://open-ils.org/spec/opensrf/IDL/persistence/v1'>
+
+       
+       <class oils_obj:fieldmapper='money::user_payment_summary' controller='open-ils.cstore' id='mups' oils_persist:virtual='true'>
+               <fields>
+                       <field oils_persist:virtual='true' name='isnew' oils_obj:array_position='0' />
+                       <field oils_persist:virtual='true' name='ischanged' oils_obj:array_position='1' />
+                       <field oils_persist:virtual='true' name='isdeleted' oils_obj:array_position='2' />
+                       <field oils_persist:virtual='true' name='usr' oils_obj:array_position='3' />
+                       <field oils_persist:virtual='true' name='forgive_payment' oils_obj:array_position='4' />
+                       <field oils_persist:virtual='true' name='work_payment' oils_obj:array_position='5' />
+                       <field oils_persist:virtual='true' name='credit_payment' oils_obj:array_position='6' />
+                       <field oils_persist:virtual='true' name='goods_payment' oils_obj:array_position='7' />
+               </fields>
+               <links>
+                       <link field='usr' reltype='has_a' class='au' key='id' map='' />
+               </links>
+       </class>
+       
+       <class oils_obj:fieldmapper='actor::usr_org_unit_opt_in' reporter:label='&class.auoi.label;' controller='open-ils.cstore' oils_persist:tablename='actor.usr_org_unit_opt_in' id='auoi'>
+               <fields oils_persist:sequence='actor.usr_org_unit_opt_in_id_seq' oils_persist:primary='id'>
+                       <field oils_persist:virtual='true' name='isnew' oils_obj:array_position='0' />
+                       <field oils_persist:virtual='true' name='ischanged' oils_obj:array_position='1' />
+                       <field oils_persist:virtual='true' name='isdeleted' oils_obj:array_position='2' />
+                       <field reporter:label='&field.auoi.id.label;' oils_persist:virtual='false' name='id' reporter:datatype='id' oils_obj:array_position='3' />
+                       <field reporter:label='&field.auoi.opt_in_ws.label;' oils_persist:virtual='false' name='opt_in_ws' reporter:datatype='link' oils_obj:array_position='4' />
+                       <field reporter:label='&field.auoi.staff.label;' oils_persist:virtual='false' name='staff' reporter:datatype='link' oils_obj:array_position='5' />
+                       <field reporter:label='&field.auoi.usr.label;' oils_persist:virtual='false' name='usr' reporter:datatype='link' oils_obj:array_position='6' />
+                       <field reporter:label='&field.auoi.org_unit.label;' oils_persist:virtual='false' name='org_unit' reporter:datatype='link' oils_obj:array_position='7' />
+                       <field reporter:label='&field.auoi.opt_in_ts.label;' oils_persist:virtual='false' name='opt_in_ts' reporter:datatype='timestamp' oils_obj:array_position='8' />
+               </fields>
+               <links>
+                       <link field='org_unit' reltype='has_a' class='aou' key='id' map='' />
+                       <link field='usr' reltype='has_a' class='au' key='id' map='' />
+                       <link field='staff' reltype='has_a' class='au' key='id' map='' />
+                       <link field='opt_in_ws' reltype='has_a' class='aws' key='id' map='' />
+               </links>
+       </class>
+       <class oils_obj:fieldmapper='actor::workstation' reporter:label='&class.aws.label;' controller='open-ils.cstore' oils_persist:tablename='actor.workstation' id='aws'>
+               <fields oils_persist:sequence='actor.workstation_id_seq' oils_persist:primary='id'>
+                       <field oils_persist:virtual='true' name='isnew' oils_obj:array_position='0' />
+                       <field oils_persist:virtual='true' name='ischanged' oils_obj:array_position='1' />
+                       <field oils_persist:virtual='true' name='isdeleted' oils_obj:array_position='2' />
+                       <field reporter:label='&field.aws.id.label;' oils_persist:virtual='false' name='id' reporter:datatype='id' oils_obj:array_position='3' />
+                       <field reporter:label='&field.aws.name.label;' oils_persist:virtual='false' name='name' reporter:datatype='text' oils_obj:array_position='4' />
+                       <field reporter:label='&field.aws.owning_lib.label;' oils_persist:virtual='false' name='owning_lib' reporter:datatype='org_unit' oils_obj:array_position='5' />
+               </fields>
+               <links>
+                       <link field='owning_lib' reltype='has_a' class='aou' key='id' map='' />
+               </links>
+       </class>
+       <class reporter:label='&class.rodcirc.label;' oils_persist:tablename='reporter.overdue_circs' reporter:core='true' oils_obj:fieldmapper='reporter::overdue_circs' controller='open-ils.reporter-store' id='rodcirc'>
+               <fields oils_persist:sequence='money.billable_xact_id_seq' oils_persist:primary='id'>
+                       <field oils_persist:virtual='true' name='isnew' oils_obj:array_position='0' />
+                       <field oils_persist:virtual='true' name='ischanged' oils_obj:array_position='1' />
+                       <field oils_persist:virtual='true' name='isdeleted' oils_obj:array_position='2' />
+                       <field reporter:label='&field.rodcirc.checkin_lib.label;' oils_persist:virtual='false' name='checkin_lib' reporter:datatype='org_unit' oils_obj:array_position='3' />
+                       <field reporter:label='&field.rodcirc.checkin_staff.label;' oils_persist:virtual='false' name='checkin_staff' reporter:datatype='link' oils_obj:array_position='4' />
+                       <field reporter:label='&field.rodcirc.checkin_time.label;' oils_persist:virtual='false' name='checkin_time' reporter:datatype='timestamp' oils_obj:array_position='5' />
+                       <field reporter:label='&field.rodcirc.circ_lib.label;' oils_persist:virtual='false' name='circ_lib' reporter:datatype='org_unit' oils_obj:array_position='6' />
+                       <field reporter:label='&field.rodcirc.circ_staff.label;' oils_persist:virtual='false' name='circ_staff' reporter:datatype='link' oils_obj:array_position='7' />
+                       <field reporter:label='&field.rodcirc.desk_renewal.label;' oils_persist:virtual='false' name='desk_renewal' reporter:datatype='bool' oils_obj:array_position='8' />
+                       <field reporter:label='&field.rodcirc.due_date.label;' oils_persist:virtual='false' name='due_date' reporter:datatype='timestamp' oils_obj:array_position='9' />
+                       <field reporter:label='&field.rodcirc.duration.label;' oils_persist:virtual='false' name='duration' reporter:datatype='interval' oils_obj:array_position='10' />
+                       <field reporter:label='&field.rodcirc.duration_rule.label;' oils_persist:virtual='false' name='duration_rule' reporter:datatype='link' oils_obj:array_position='11' />
+                       <field reporter:label='&field.rodcirc.fine_interval.label;' oils_persist:virtual='false' name='fine_interval' reporter:datatype='interval' oils_obj:array_position='12' />
+                       <field reporter:label='&field.rodcirc.id.label;' oils_persist:virtual='false' name='id' reporter:datatype='id' oils_obj:array_position='13' />
+                       <field reporter:label='&field.rodcirc.max_fine.label;' oils_persist:virtual='false' name='max_fine' reporter:datatype='money' oils_obj:array_position='14' />
+                       <field reporter:label='&field.rodcirc.max_fine_rule.label;' oils_persist:virtual='false' name='max_fine_rule' reporter:datatype='link' oils_obj:array_position='15' />
+                       <field reporter:label='&field.rodcirc.opac_renewal.label;' oils_persist:virtual='false' name='opac_renewal' reporter:datatype='bool' oils_obj:array_position='16' />
+                       <field reporter:label='&field.rodcirc.phone_renewal.label;' oils_persist:virtual='false' name='phone_renewal' reporter:datatype='bool' oils_obj:array_position='17' />
+                       <field reporter:label='&field.rodcirc.recuring_fine.label;' oils_persist:virtual='false' name='recuring_fine' reporter:datatype='money' oils_obj:array_position='18' />
+                       <field reporter:label='&field.rodcirc.recuring_fine_rule.label;' oils_persist:virtual='false' name='recuring_fine_rule' reporter:datatype='link' oils_obj:array_position='19' />
+                       <field reporter:label='&field.rodcirc.renewal_remaining.label;' oils_persist:virtual='false' name='renewal_remaining' reporter:datatype='int' oils_obj:array_position='20' />
+                       <field reporter:label='&field.rodcirc.stop_fines.label;' oils_persist:virtual='false' name='stop_fines' reporter:datatype='text' oils_obj:array_position='21' />
+                       <field reporter:label='&field.rodcirc.stop_fines_time.label;' oils_persist:virtual='false' name='stop_fines_time' reporter:datatype='timestamp' oils_obj:array_position='22' />
+                       <field reporter:label='&field.rodcirc.target_copy.label;' oils_persist:virtual='false' name='target_copy' reporter:datatype='link' oils_obj:array_position='23' />
+                       <field reporter:label='&field.rodcirc.usr.label;' oils_persist:virtual='false' name='usr' reporter:datatype='link' oils_obj:array_position='24' />
+                       <field reporter:label='&field.rodcirc.xact_finish.label;' oils_persist:virtual='false' name='xact_finish' reporter:datatype='timestamp' oils_obj:array_position='25' />
+                       <field reporter:label='&field.rodcirc.xact_start.label;' oils_persist:virtual='false' name='xact_start' reporter:datatype='timestamp' oils_obj:array_position='26' />
+                       <field reporter:label='&field.rodcirc.billings.label;' oils_persist:virtual='true' name='billings' reporter:datatype='link' oils_obj:array_position='27' />
+                       <field reporter:label='&field.rodcirc.payments.label;' oils_persist:virtual='true' name='payments' reporter:datatype='link' oils_obj:array_position='28' />
+                       <field reporter:label='&field.rodcirc.billable_transaction.label;' oils_persist:virtual='true' name='billable_transaction' reporter:datatype='link' oils_obj:array_position='29' />
+                       <field reporter:label='&field.rodcirc.circ_type.label;' oils_persist:virtual='true' name='circ_type' reporter:datatype='text' oils_obj:array_position='30' />
+                       <field reporter:label='&field.rodcirc.billing_total.label;' oils_persist:virtual='true' name='billing_total' reporter:datatype='money' oils_obj:array_position='31' />
+                       <field reporter:label='&field.rodcirc.payment_total.label;' oils_persist:virtual='true' name='payment_total' reporter:datatype='money' oils_obj:array_position='32' />
+               </fields>
+               <links>
+                       <link field='billable_transaction' reltype='might_have' class='mbt' key='id' map='' />
+                       <link field='circ_staff' reltype='has_a' class='au' key='id' map='' />
+                       <link field='checkin_lib' reltype='has_a' class='aou' key='id' map='' />
+                       <link field='target_copy' reltype='has_a' class='acp' key='id' map='' />
+                       <link field='checkin_staff' reltype='has_a' class='au' key='id' map='' />
+                       <link field='usr' reltype='has_a' class='au' key='id' map='' />
+                       <link field='circ_lib' reltype='has_a' class='aou' key='id' map='' />
+                       <link field='payments' reltype='has_many' class='mp' key='xact' map='' />
+                       <link field='billings' reltype='has_many' class='mb' key='xact' map='' />
+                       <link field='duration_rule' reltype='has_a' class='crcd' key='name' map='' />
+                       <link field='max_fine_rule' reltype='has_a' class='crmf' key='name' map='' />
+                       <link field='recuring_fine_rule' reltype='has_a' class='crrf' key='name' map='' />
+                       <link field='circ_type' reltype='might_have' class='rcirct' key='id' map='' />
+                       <link field='billing_total' reltype='might_have' class='rxbt' key='xact' map='' />
+                       <link field='payment_total' reltype='might_have' class='rxpt' key='xact' map='' />
+               </links>
+       </class>
+</IDL>
\ No newline at end of file
diff --git a/build/i18n/tests/testIDL.py b/build/i18n/tests/testIDL.py
new file mode 100644 (file)
index 0000000..3dfaf4f
--- /dev/null
@@ -0,0 +1,100 @@
+#!/usr/bin/env python
+# vim: set fileencoding=utf-8 :
+"""
+ Perform the following tests:
+  1. Generate an entityized version of an abbreviated version of fm_IDL.xml 
+  2. Generate a POT file from fm_IDL.xml
+  3. Generate an entity definition file from a PO file
+"""
+
+import filecmp
+import os
+import polib
+import re
+import subprocess
+import sys
+import unittest
+
+class TestIDLL10N(unittest.TestCase):
+
+    tmpdirs = [('tmp/')]
+    savepot = 'tmp/testsave.pot'
+    saveidlent = 'tmp/testidlent.xml'
+    saveentities = 'tmp/testentity.ent'
+    idlfile = 'data/testidl.xml'
+    idlentfile = 'data/testidlent.xml'
+    idlentities = 'data/testidl.ent'
+    testpot = 'data/testidl.pot'
+    testpo = 'data/testidl.po'
+
+    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 testentityize(self):
+        """
+        Convert an en-US IDL file to an entityized version
+        """
+        devnull = open('/dev/null', 'w')
+        proc = subprocess.Popen(
+            ('python', '../scripts/fieldmapper.py', '--convert', self.idlfile,
+            '--output', self.saveidlent),
+            0, None, None, devnull, devnull).wait()
+
+        self.assertEqual(filecmp.cmp(self.saveidlent, self.idlentfile), 1)
+
+    def testsavepot(self):
+        """
+        Create a POT file from a fieldmapper IDL file
+        """
+        devnull = open('/dev/null', 'w')
+        proc = subprocess.Popen(
+            ('python', '../scripts/fieldmapper.py', '--pot', self.idlfile,
+            '--output', self.savepot),
+            0, None, None, devnull, devnull).wait()
+
+        mungepothead(self.savepot)
+        mungepothead(self.testpot)
+
+        self.assertEqual(filecmp.cmp(self.savepot, self.testpot), 1)
+
+    def testgenent(self):
+        """
+        Generate an entity definition file from a PO file
+        """
+        devnull = open('/dev/null', 'w')
+        proc = subprocess.Popen(
+            ('python', '../scripts/fieldmapper.py', '--entity', self.testpo,
+            '--output', self.saveentities),
+            0, None, None, devnull, devnull).wait()
+        self.assertEqual(filecmp.cmp(self.saveentities, self.idlentities), 1)
+
+
+def mungepothead(file):
+    """
+    Change POT header to avoid annoying timestamp mismatch
+    """
+    lines = [] 
+    mungefile = open(file)
+    for line in mungefile:
+        line = re.sub(r'^("POT-Creation-Date: ).+"$', r'\1', line)
+        lines.append(line)
+    mungefile.close()
+
+    # Write the changed lines back out
+    mungefile = open(file, 'w')
+    for line in lines:
+        mungefile.write(line)
+    mungefile.close()
+
+if __name__ == '__main__':
+    unittest.main()
index d79fa70..56aeee2 100644 (file)
@@ -74,7 +74,7 @@ class TestBaseL10N(unittest.TestCase):
 
     def testsavepot(self):
         """
-        Save a generated POT file and compate to a known good one
+        Save a generated POT file and compare to a known good one
         """
         import basel10n
         pogen = basel10n.BaseL10N()