From 16c9ba90fadd7aaabb64f525185fdb3a97061149 Mon Sep 17 00:00:00 2001
From: Kazuhiko Shiozaki <kazuhiko@nexedi.com>
Date: Mon, 5 Jul 2010 11:44:06 +0000
Subject: [PATCH] fix test_06_FrenchTranslationOfMessageWithContext and check
 if translations for states are well distinguished per portal type.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@36860 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5/tests/testTranslation.py | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/product/ERP5/tests/testTranslation.py b/product/ERP5/tests/testTranslation.py
index 8b36164388..9ff7e966c5 100644
--- a/product/ERP5/tests/testTranslation.py
+++ b/product/ERP5/tests/testTranslation.py
@@ -206,6 +206,10 @@ class TestWorkflowStateTitleTranslation(ERP5TypeTestCase):
 
         self.fail(self.message)
 
+  def afterSetUp(self):
+    self.portal.Localizer._default_language = 'en'
+    self.portal.Localizer.set_languages(['en', 'fr'])
+
   def test_01_EnglishTranslation(self, quiet=0, run=run_all_test):
     """
     Test English translation
@@ -274,7 +278,7 @@ class TestWorkflowStateTitleTranslation(ERP5TypeTestCase):
 
     transaction.commit()
     self.tic()
-    self.portal.Localizer.get_selected_language = lambda: self.lang
+    self.portal.Localizer._default_language = 'fr'
 
     self.assertEquals(item.getTranslatedValidationStateTitle(), 'Draft')
     item.validate()
@@ -283,10 +287,17 @@ class TestWorkflowStateTitleTranslation(ERP5TypeTestCase):
                       'Valid茅')
     # Now run indexation of translations.
     self.portal.ERP5Site_updateTranslationTable()
+    transaction.commit()
+    self.tic()
     # Ckeck queries with translated workflow state title generated with
     # getMessageIdWithContext
-    self.assertTrue(len(self.portal.portal_catalog(
-                            translated_validation_state_title="En bon usage")))
+    self.assertEquals(1, len(self.portal.portal_catalog(
+      translated_validation_state_title="En bon usage")))
+    self.assertEquals(1, len(self.portal.portal_catalog(
+      translated_validation_state_title="En bon usage", portal_type='Item')))
+    self.assertEquals(0, len(self.portal.portal_catalog(
+      translated_validation_state_title="En bon usage",
+      portal_type='Organisation')))
 
   @expectedFailure
   def test_07_NegatedQueryForTranslation(self, quiet=0, run=run_all_test):
-- 
2.30.9