From 0cd5ddf935f233ac743d6099b7fba44715333345 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Thu, 28 Aug 2014 11:55:43 +0000
Subject: [PATCH] test_result: Fix Result History tab

Now that we are counting test results, we have to make sure that the list
method returns as many lines as the count method, so add some "Not executed"
lines whenever test suite is ran this specific test was not run.
---
 .../TestResultLine_getResultHistoryList.xml           | 11 +++++++++++
 .../listbox_parent_reference.xml                      |  2 +-
 bt5/erp5_test_result/bt/revision                      |  2 +-
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/bt5/erp5_test_result/SkinTemplateItem/portal_skins/erp5_test_result/TestResultLine_getResultHistoryList.xml b/bt5/erp5_test_result/SkinTemplateItem/portal_skins/erp5_test_result/TestResultLine_getResultHistoryList.xml
index 8dccf80f83..ca5e3fbb28 100644
--- a/bt5/erp5_test_result/SkinTemplateItem/portal_skins/erp5_test_result/TestResultLine_getResultHistoryList.xml
+++ b/bt5/erp5_test_result/SkinTemplateItem/portal_skins/erp5_test_result/TestResultLine_getResultHistoryList.xml
@@ -71,22 +71,33 @@ query_params = {\'creation_date\' : dict(query=context.getCreationDate(), range=
 result_list = []\n
 expected_id = context.getId()\n
 expected_title = context.getTitle()\n
+\n
 for tr in context.portal_catalog(**query_params):\n
+  line_found = False\n
   tr = tr.getObject()\n
+  \n
   # Optimisation: the test result line probably have the same id in the previous\n
   # test result.\n
   line = getattr(tr, expected_id, None)\n
   if line is not None and line.getTitle() == expected_title \\\n
       and line.getSimulationState() in (\'stopped\', \'public_stopped\', \'failed\'):\n
     result_list.append(line)\n
+    line_found = True\n
   else:\n
     for line in tr.contentValues(portal_type=\'Test Result Line\'):\n
       if line.getTitle() == context.getTitle() \\\n
          and line.getSimulationState() in (\'stopped\', \'public_stopped\', \'failed\'):\n
         result_list.append(line)\n
+        line_found = True\n
         # next time, the test result line will likely have the same id as this one.\n
         expected_id = line.getId()\n
 \n
+  # This test result line was not executed in this test. We had a line "Not executed",\n
+  # mainly because we have a count method that counts test results, so we need to\n
+  # return as many test result line as the count method returns.\n
+  if not line_found:\n
+    result_list.append(tr.asContext(string_index=\'NOT_EXECUTED\'))\n
+    \n
 return result_list\n
 </string> </value>
         </item>
diff --git a/bt5/erp5_test_result/SkinTemplateItem/portal_skins/erp5_test_result/TestResultLine_viewResultHistory/listbox_parent_reference.xml b/bt5/erp5_test_result/SkinTemplateItem/portal_skins/erp5_test_result/TestResultLine_viewResultHistory/listbox_parent_reference.xml
index ce7d453b9f..025bdad4d0 100644
--- a/bt5/erp5_test_result/SkinTemplateItem/portal_skins/erp5_test_result/TestResultLine_viewResultHistory/listbox_parent_reference.xml
+++ b/bt5/erp5_test_result/SkinTemplateItem/portal_skins/erp5_test_result/TestResultLine_viewResultHistory/listbox_parent_reference.xml
@@ -267,7 +267,7 @@
       <dictionary>
         <item>
             <key> <string>_text</string> </key>
-            <value> <string>python: cell.getParentValue().getReference()</string> </value>
+            <value> <string>python: cell.portal_type == \'Test Result\' and cell.getReference() or cell.getParentValue().getReference()</string> </value>
         </item>
       </dictionary>
     </pickle>
diff --git a/bt5/erp5_test_result/bt/revision b/bt5/erp5_test_result/bt/revision
index d36f9fbea4..02225a563f 100644
--- a/bt5/erp5_test_result/bt/revision
+++ b/bt5/erp5_test_result/bt/revision
@@ -1 +1 @@
-267
\ No newline at end of file
+268
\ No newline at end of file
-- 
2.30.9