[Checkins] SVN: Products.ZCatalog/trunk/ In the string representation of a catalog plan, round the times to at most two digits after the comma.

Hanno Schlichting hannosch at hannosch.eu
Fri Jul 29 05:39:58 EDT 2011


Log message for revision 122415:
  In the string representation of a catalog plan, round the times to at most two digits after the comma.
  

Changed:
  U   Products.ZCatalog/trunk/CHANGES.txt
  U   Products.ZCatalog/trunk/src/Products/ZCatalog/ZCatalog.py
  U   Products.ZCatalog/trunk/src/Products/ZCatalog/tests/test_plan.py

-=-
Modified: Products.ZCatalog/trunk/CHANGES.txt
===================================================================
--- Products.ZCatalog/trunk/CHANGES.txt	2011-07-29 08:54:03 UTC (rev 122414)
+++ Products.ZCatalog/trunk/CHANGES.txt	2011-07-29 09:39:57 UTC (rev 122415)
@@ -4,6 +4,8 @@
 2.13.18 (unreleased)
 --------------------
 
+- In the string representation of a catalog plan, round the times to at most
+  two digits after the comma.
 
 2.13.17 (2011-07-29)
 --------------------

Modified: Products.ZCatalog/trunk/src/Products/ZCatalog/ZCatalog.py
===================================================================
--- Products.ZCatalog/trunk/src/Products/ZCatalog/ZCatalog.py	2011-07-29 08:54:03 UTC (rev 122414)
+++ Products.ZCatalog/trunk/src/Products/ZCatalog/ZCatalog.py	2011-07-29 09:39:57 UTC (rev 122415)
@@ -901,8 +901,8 @@
             for querykey, details in sorted(plan.items()):
                 output.append('    %s: {' % repr(querykey))
                 for indexname, benchmark in sorted(details.items()):
-                    tuplebench = repr(tuple(benchmark))
-                    output.append('      %r:\n      %s,' % (indexname, tuplebench))
+                    tuplebench = (round(benchmark[0], 2), ) + benchmark[1:]
+                    output.append('      %r:\n      %r,' % (indexname, tuplebench))
                 output.append('    },')
             output.append('  },')
         output.append('}')

Modified: Products.ZCatalog/trunk/src/Products/ZCatalog/tests/test_plan.py
===================================================================
--- Products.ZCatalog/trunk/src/Products/ZCatalog/tests/test_plan.py	2011-07-29 08:54:03 UTC (rev 122414)
+++ Products.ZCatalog/trunk/src/Products/ZCatalog/tests/test_plan.py	2011-07-29 09:39:57 UTC (rev 122415)
@@ -214,6 +214,32 @@
         plan = self._makeOne(zcat._catalog)
         self.assertEquals(plan.get_id(), ('catalog',))
 
+    def test_getCatalogPlan_empty(self):
+        from Products.ZCatalog.ZCatalog import ZCatalog
+        zcat = ZCatalog('catalog')
+        self._makeOne(zcat._catalog)
+        plan_str = zcat.getCatalogPlan()
+        self.assertTrue('queryplan = {' in plan_str)
+
+    def test_getCatalogPlan_full(self):
+        from Products.ZCatalog.ZCatalog import ZCatalog
+        zcat = ZCatalog('catalog')
+        plan = self._makeOne(zcat._catalog, query={'index1': 1, 'index2': 2})
+        plan.start()
+        plan.start_split('index1')
+        time.sleep(0.1111)
+        plan.stop_split('index1')
+        plan.start_split('index2')
+        time.sleep(0.2222)
+        plan.stop_split('index2')
+        plan.stop()
+        plan_str = zcat.getCatalogPlan()
+        self.assertTrue('queryplan = {' in plan_str)
+        self.assertTrue('index1' in plan_str)
+        # test rounding worked
+        self.assertTrue('(0.11, 1, False),' in plan_str)
+        self.assertTrue('(0.22, 1, False),' in plan_str)
+
     def test_plan_empty(self):
         plan = self._makeOne()
         self.assertEquals(plan.plan(), None)



More information about the checkins mailing list