[Erp5-report] r13929 - /erp5/trunk/products/ERP5Catalog/tests/testERP5Catalog.py

nobody at svn.erp5.org nobody at svn.erp5.org
Wed Apr 4 14:57:41 CEST 2007


Author: seb
Date: Wed Apr  4 14:57:40 2007
New Revision: 13929

URL: http://svn.erp5.org?rev=13929&view=rev
Log:
added test for the format of dates

Modified:
    erp5/trunk/products/ERP5Catalog/tests/testERP5Catalog.py

Modified: erp5/trunk/products/ERP5Catalog/tests/testERP5Catalog.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Catalog/tests/testERP5Catalog.py?rev=13929&r1=13928&r2=13929&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Catalog/tests/testERP5Catalog.py (original)
+++ erp5/trunk/products/ERP5Catalog/tests/testERP5Catalog.py Wed Apr  4 14:57:40 2007
@@ -1695,6 +1695,58 @@
                              ("parent","catalog"),
                              ("grand_parent","catalog")),
                              table_alias_list)
+    
+  def test_53_DateFormat(self, quiet=quiet, run=run_all_test):
+    if not run: return
+    if not quiet:
+      message = 'Date Format'
+      ZopeTestCase._print('\n%s ' % message)
+      LOG('Testing... ',0,message)
+    org_a = self._makeOrganisation(title='org_a')
+    org_b = self._makeOrganisation(title='org_b')
+    sql_connection = self.getSQLConnection()
+    # Add a method in order to directly put values we want into
+    # the catalog.
+    def updateDate(organisation,date):
+      uid = organisation.getUid()
+      sql = "UPDATE catalog SET modification_date='%s' '\
+          'WHERE uid=%s" %\
+          (date,uid)
+      result = sql_connection.manage_test(sql)
+    updateDate(org_a,'2007-01-12 01:02:03')
+    updateDate(org_b,'2006-02-24 15:09:06')
+
+    catalog_kw = {'modification_date':{'query':'24/02/2006',
+                               'format':'%d/%m/%Y',
+                               'type':'date'}}
+    self.failIfDifferentSet([org_b.getPath()],
+        [x.path for x in self.getCatalogTool()(
+                portal_type='Organisation',**catalog_kw)])
+    catalog_kw = {'modification_date':{'query':'2007-01-12',
+                               'format':'%Y-%m-%d',
+                               'type':'date'}}
+    self.failIfDifferentSet([org_a.getPath()],
+        [x.path for x in self.getCatalogTool()(
+                portal_type='Organisation',**catalog_kw)])
+    catalog_kw = {'modification_date':{'query':'>31/12/2006',
+                               'format':'%d/%m/%Y',
+                               'type':'date'}}
+    self.failIfDifferentSet([org_a.getPath()],
+        [x.path for x in self.getCatalogTool()(
+                portal_type='Organisation',**catalog_kw)])
+    catalog_kw = {'modification_date':{'query':'2006',
+                               'format':'%Y',
+                               'type':'date'}}
+    self.failIfDifferentSet([org_b.getPath()],
+        [x.path for x in self.getCatalogTool()(
+                portal_type='Organisation',**catalog_kw)])
+    catalog_kw = {'modification_date':{'query':'>2006',
+                               'format':'%Y',
+                               'type':'date'}}
+    self.failIfDifferentSet([org_a.getPath()],
+        [x.path for x in self.getCatalogTool()(
+                portal_type='Organisation',**catalog_kw)])
+
 
 if __name__ == '__main__':
     framework()




More information about the Erp5-report mailing list