From c1d6632ad2db5be8dec6d7e21045e2f3b67625da Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Thu, 12 Mar 2009 17:46:29 +0000
Subject: [PATCH] extends test to test what happens when we select a group that
 has no related organisation

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@26010 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5/tests/testTradeReports.py | 32 ++++++++++++++++++++++++--
 1 file changed, 30 insertions(+), 2 deletions(-)

diff --git a/product/ERP5/tests/testTradeReports.py b/product/ERP5/tests/testTradeReports.py
index 9c7aad1ac9..6bb94db5d1 100644
--- a/product/ERP5/tests/testTradeReports.py
+++ b/product/ERP5/tests/testTradeReports.py
@@ -88,14 +88,14 @@ class TestTradeReports(ERP5ReportTestCase):
                                   id=colour_id)
 
     # create group categories
-    for group_id in ('g1', 'g2',):
+    for group_id in ('g1', 'g2', 'g3'):
       if not self.portal_categories['group'].has_key(group_id):
         self.portal_categories.group.newContent(
                                   portal_type='Category',
                                   title=group_id,
                                   reference=group_id,
                                   id=group_id)
-    # create organisations
+    # create organisations (with no organisation member of g3)
     if not self.organisation_module.has_key('Organisation_1'): 
       org = self.portal.organisation_module.newContent(
                               portal_type='Organisation',
@@ -112,6 +112,7 @@ class TestTradeReports(ERP5ReportTestCase):
                               id='Organisation_2',
                               group='g2',
                               site='demo_site_B')
+
     # create unit categories
     for unit_id in ('kg', 'g',):
       if not self.portal_categories['quantity_unit'].has_key(unit_id): 
@@ -586,6 +587,33 @@ class TestTradeReports(ERP5ReportTestCase):
                  'total quantity': None}
     self.checkLineProperties(stat_line_list[0],**d)
   
+    # group set, with no matching organisations
+    request['simulation_state'] = ['draft',]
+    request['aggregation_level'] = "year"
+    request['group_by'] = "both"
+    request['group'] = 'g3'
+    report_section_list = self.getReportSectionList(self.sale_order_module,
+                                                    'OrderModule_viewOrderReport')
+    self.assertEquals(1, len(report_section_list))
+
+    line_list = self.getListBoxLineList(report_section_list[0])
+    data_line_list = [l for l in line_list if l.isDataLine()]
+    stat_line_list = [l for l in line_list if l.isStatLine()]
+    self.assertEquals(0, len(data_line_list))
+    self.assertEquals(1, len(stat_line_list))
+    # stat line
+    d = {'Amount 2006': None,
+                 'Amount 2007': None,
+                 'Quantity 2006': None,
+                 'Quantity 2007': None,
+                 'Quantity Unit 2006': None,
+                 'Quantity Unit 2007': None,
+                 'client': 'Total',
+                 'product': None,
+                 'total amount': None,
+                 'total quantity': None}
+    self.checkLineProperties(stat_line_list[0],**d)
+  
   def testStockReport(self):
     """
     Stock report.
-- 
2.30.9