From b55cc850f89f172bdb814c7c10139526d07a1ef3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Aur=C3=A9lien=20Calonne?= <aurel@nexedi.com>
Date: Wed, 27 Feb 2013 16:47:23 +0100
Subject: [PATCH] SSL needs to be sorted on destination category & resource
 otherwise result can be random

---
 product/ERP5/tests/testResource.py | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/product/ERP5/tests/testResource.py b/product/ERP5/tests/testResource.py
index 7079462763..e838b73a07 100644
--- a/product/ERP5/tests/testResource.py
+++ b/product/ERP5/tests/testResource.py
@@ -874,8 +874,29 @@ class TestResource(ERP5TypeTestCase):
                         tab=1)
       if variation:
         categories.append(variation)
-      self.assertEqual(base_price, product.getPrice(categories=categories))
-  
+
+      def sortResult(a, b):
+        def _pricingSortMethod(a, b): # XXX copied from Resource.py
+          # Simple method : the one that defines a destination section wins
+          if a.getDestinationSection():
+            return -1 # a defines a destination section and wins
+          return 1 # a defines no destination section and loses
+        if _pricingSortMethod(a, b):
+          # now sort based on resource definition
+          if a.getResourceValue():
+            if b.getResourceValue():
+              return 1
+            else:
+              return -1
+          else:
+            return 1
+        else:
+          return -1
+
+
+      self.assertEqual(base_price, product.getPrice(categories=categories,
+                                                    sort_method=sortResult))
+
 
   # The following test tests Movement.getPrice, which is based on the movement
   # context.
-- 
2.30.9