2 new revisions:

Revision: 455223ca554c
Author:   Robot Framework Developers ([email protected])
Date:     Wed Nov 30 04:43:40 2011
Log:      stats: handle id/idx inconsistency
http://code.google.com/p/robotframework/source/detail?r=455223ca554c

Revision: 6508abcdc1e3
Author:   Robot Framework Developers ([email protected])
Date:     Wed Nov 30 04:48:02 2011
Log:      jsoning: handle also Statistics with proper _Handler
http://code.google.com/p/robotframework/source/detail?r=6508abcdc1e3

==============================================================================
Revision: 455223ca554c
Author:   Robot Framework Developers ([email protected])
Date:     Wed Nov 30 04:43:40 2011
Log:      stats: handle id/idx inconsistency
http://code.google.com/p/robotframework/source/detail?r=455223ca554c

Modified:
 /src/robot/model/stats.py
 /utest/result/test_jsoning.py

=======================================
--- /src/robot/model/stats.py   Wed Nov 30 03:11:56 2011
+++ /src/robot/model/stats.py   Wed Nov 30 04:43:40 2011
@@ -28,6 +28,8 @@
     def attrs(self):
         attrs = {'pass': str(self.passed), 'fail': str(self.failed)}
         attrs.update(self._get_custom_attrs())
+        if 'id' in attrs:
+            attrs['idx'] = attrs.pop('id') # TODO: Rename idx -> id
         return attrs

     @property
@@ -76,7 +78,7 @@
         self._name = suite.name

     def _get_custom_attrs(self):
-        return {'idx': self.id, 'name': self._name}  # TODO: isx -> id
+        return {'id': self.id, 'name': self._name}


 class TagStat(Stat):
=======================================
--- /utest/result/test_jsoning.py       Wed Nov 30 01:39:11 2011
+++ /utest/result/test_jsoning.py       Wed Nov 30 04:43:40 2011
@@ -271,7 +271,7 @@
         assert_equals(self.datamodel['stats'],
             [[{'fail': 1, 'label': 'Critical Tests', 'pass': 0},
               {'fail': 1, 'label': 'All Tests', 'pass': 0}],
-             [{'fail': 1, 'label': 'tagi', 'pass': 0}],
+ [{'info': '', 'combined': '', 'links': '', 'pass': 0, 'fail': 1, 'doc': '', 'label': 'tagi'}], [{'fail': 1, 'label': 'Kekkonen', 'id': 's1', 'name': 'Kekkonen', 'pass': 0}, {'fail': 1, 'label': 'Kekkonen.Urho', 'id': 's1-s1', 'name': 'Urho', 'pass': 0}]])


==============================================================================
Revision: 6508abcdc1e3
Author:   Robot Framework Developers ([email protected])
Date:     Wed Nov 30 04:48:02 2011
Log:      jsoning: handle also Statistics with proper _Handler
http://code.google.com/p/robotframework/source/detail?r=6508abcdc1e3

Modified:
 /src/robot/result/datamodel.py
 /src/robot/result/jsondatamodelhandlers.py

=======================================
--- /src/robot/result/datamodel.py      Wed Nov 30 01:40:01 2011
+++ /src/robot/result/datamodel.py      Wed Nov 30 04:48:02 2011
@@ -79,5 +79,20 @@
         model = self._build(errors)
         self._top.add_errors(model)

-    def visit_statistics(self, stats):
-        self._top.visit_statistics(stats)
+    def start_total_statistics(self, stats):
+        self._push(self._top.statistics_handler())
+
+    def end_total_statistics(self, stats):
+        model = self._build(stats)
+        self._top.add_statistics(model)
+
+    start_tag_statistics = start_suite_statistics = start_total_statistics
+    end_tag_statistics = end_suite_statistics = end_total_statistics
+
+    def start_stat(self, stat):
+        self._push(self._top.stat_handler())
+
+    def end_stat(self, stat):
+        model = self._build(stat)
+        self._top.add_stat(model)
+
=======================================
--- /src/robot/result/jsondatamodelhandlers.py  Wed Nov 30 03:12:50 2011
+++ /src/robot/result/jsondatamodelhandlers.py  Wed Nov 30 04:48:02 2011
@@ -25,6 +25,8 @@
         self._keywords = []
         self._messages = []
         self._errors = []
+        self._statistics = []
+        self._stats = []

     def build(self, item):
         return None
@@ -44,6 +46,12 @@
     def errors_handler(self):
         return ErrorsHandler(self._context)

+    def statistics_handler(self):
+        return StatisticsHandler(self._context)
+
+    def stat_handler(self):
+        return StatHandler(self._context)
+
     def add_suite(self, data):
         self._suites.append(data)

@@ -59,6 +67,12 @@
     def add_errors(self, data):
         self._errors = data

+    def add_statistics(self, data):
+        self._statistics.append(data)
+
+    def add_stat(self, data):
+        self._stats.append(data)
+
     def _status(self, item):
         return StatusHandler(self._context).build(item)

@@ -74,13 +88,9 @@

 class ExecutionResultHandler(_Handler):

-    def visit_statistics(self, stats):
-        self._stats = []
-        return StatisticsHandler(self._stats, stats)
-
     def build(self, _):
         return {'suite': self._suites[0],
-                'stats': self._stats,
+                'stats': self._statistics,
                 'errors': self._errors,
                 'baseMillis': self._context.basemillis,
                 'strings': self._context.dump_texts()}
@@ -92,16 +102,16 @@
         return self._messages


-    # TODO: This should also be Handler
-class StatisticsHandler(object):
-
-    def __init__(self, result, stats):
-        result.append(self._get_stats(stats.total))
-        result.append(self._get_stats(stats.tags))
-        result.append(self._get_stats(stats.suite))
-
-    def _get_stats(self, stats):
-        return [stat.js_attrs for stat in stats]
+class StatisticsHandler(_Handler):
+
+    def build(self, stats):
+        return self._stats
+
+
+class StatHandler(_Handler):
+
+    def build(self, stat):
+        return stat.js_attrs


 class SuiteHandler(_Handler):
@@ -118,20 +128,20 @@
                 self._id(suite.source),
                 self._id(self._context.get_rel_log_path(suite.source)),
                 self._id_html(suite.doc),
-                self._metadata(suite),
+                self._get_metadata(suite),
                 self._status(suite),
                 self._suites,
                 self._tests,
                 self._keywords,
-                self._stats(suite)]
-
-    def _metadata(self, suite):
+                self._get_stats(suite)]
+
+    def _get_metadata(self, suite):
         metadata = []
         for name, value in suite.metadata.items():
metadata.extend([self._id(name), self._id(utils.html_format(value))])
         return metadata

-    def _stats(self, suite):
+    def _get_stats(self, suite):
         stats = suite.statistics  # Access property only once
         return [stats.all.total, stats.all.passed,
                 stats.critical.total, stats.critical.passed]

Reply via email to