From 051cbd0309eb89b293b50cf8af7429a05e1a2fe7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Wed, 5 May 2010 15:45:16 +0000
Subject: [PATCH] test rendering with "broken" item and multi item fields (ie.
 where current value is not in the list of possible values)

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@35013 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5OOo/tests/testOOoStyle.py | 31 +++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/product/ERP5OOo/tests/testOOoStyle.py b/product/ERP5OOo/tests/testOOoStyle.py
index 3e51b5d502..ea2f078f46 100644
--- a/product/ERP5OOo/tests/testOOoStyle.py
+++ b/product/ERP5OOo/tests/testOOoStyle.py
@@ -51,6 +51,11 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
     if not self.skin:
       raise NotImplementedError('Subclasses must define skin')
     
+    gender = self.portal.portal_categories.gender
+    if 'male' not in gender.objectIds():
+      gender.newContent(id='male')
+      self.portal.portal_caches.clearAllCache()
+
     self.auth = 'ERP5TypeTestCase:'
     person_module = self.portal.person_module
     if person_module._getOb('pers', None) is None:
@@ -58,6 +63,9 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
       transaction.commit()
       self.tic()
     person_module.pers.setFirstName('Bob')
+    person_module.pers.setGender(None)
+    person_module.pers.setCareerRole(None)
+
     if person_module.pers._getOb('img', None) is None:
       person_module.pers.newContent(portal_type='Image', id='img')
 
@@ -223,6 +231,29 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
     self.assertEquals('inline', content_disposition.split(';')[0])
     self._validate(response.getBody())
 
+  def test_form_view_category(self):
+    self.portal.person_module.pers.setGender('male')
+    response = self.publish('/%s/person_module/pers/Person_view'
+                          % self.portal.getId(), basic=self.auth)
+    self.assertEquals(HTTP_OK, response.getStatus())
+    content_type = response.getHeader('content-type')
+    self.assertTrue(content_type.startswith(self.content_type), content_type)
+    content_disposition = response.getHeader('content-disposition')
+    self.assertEquals('inline', content_disposition.split(';')[0])
+    self._validate(response.getBody())
+
+  def test_form_view_broken_category(self):
+    self.portal.person_module.pers.setGender('not exist')
+    self.portal.person_module.pers.setCareerRole('not exist')
+    response = self.publish('/%s/person_module/pers/Person_view'
+                          % self.portal.getId(), basic=self.auth)
+    self.assertEquals(HTTP_OK, response.getStatus())
+    content_type = response.getHeader('content-type')
+    self.assertTrue(content_type.startswith(self.content_type), content_type)
+    content_disposition = response.getHeader('content-disposition')
+    self.assertEquals('inline', content_disposition.split(';')[0])
+    self._validate(response.getBody())
+
   def test_form_view_embedded_image(self):
     # with image
     response = self.publish('/%s/person_module/pers/Person_viewDetails'
-- 
2.30.9