[Erp5-report] r29541 - /erp5/trunk/products/ERP5Form/tests/testFieldValueCache.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Fri Oct 9 16:54:24 CEST 2009
Author: jp
Date: Fri Oct 9 16:54:23 2009
New Revision: 29541
URL: http://svn.erp5.org?rev=29541&view=rev
Log:
first test of interactors
Added:
erp5/trunk/products/ERP5Form/tests/testFieldValueCache.py
Added: erp5/trunk/products/ERP5Form/tests/testFieldValueCache.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Form/tests/testFieldValueCache.py?rev=29541&view=auto
==============================================================================
--- erp5/trunk/products/ERP5Form/tests/testFieldValueCache.py (added)
+++ erp5/trunk/products/ERP5Form/tests/testFieldValueCache.py [utf8] Fri Oct 9 16:54:23 2009
@@ -1,0 +1,93 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Copyright (c) 2002-2009 Nexedi SA and Contributors. All Rights Reserved.
+#
+# WARNING: This program as such is intended to be used by professional
+# programmers who take the whole responsability of assessing all potential
+# consequences resulting from its eventual inadequacies and bugs
+# End users who are looking for a ready-to-use solution with commercial
+# garantees and support are strongly adviced to contract a Free Software
+# Service Company
+#
+# This program is Free Software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+##############################################################################
+
+from Testing.ZopeTestCase.PortalTestCase import PortalTestCase
+from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
+from Products.ERP5Type.tests.SecurityTestCase import SecurityTestCase
+import transaction
+import unittest
+
+class TestFieldValueCache(ERP5TypeTestCase):
+ """
+ A Sample Test Class
+ """
+
+ def getTitle(self):
+ return "TestDiscussionThread"
+
+ def getBusinessTemplateList(self):
+ """
+ Tuple of Business Templates we need to install
+ """
+ return (
+ 'erp5_base',
+ )
+
+ def setUpOnce(self):
+ """
+ Do nothing
+ """
+
+ def afterSetUp(self):
+ """
+ This is ran before each and every test, used to set up the environment
+ """
+ self.person_module = self.portal.getDefaultModule(portal_type='Person')
+
+ def testEditZMIFieldPurgesValueCache(self):
+ """
+ This test makes sure that if manage_edit is called on a ZMI
+ field then its ValueCache is purged.
+ """
+ person = self.person_module.newContent()
+ form = person.Person_view
+ # Render
+ form()
+ # Get form value
+ field = form.my_first_name
+ id = 'title'
+ from Products.ERP5Form.ProxyField import _field_value_cache
+ cache_id = ('ProxyField.get_value',
+ field._p_oid,
+ field._p_oid,
+ id)
+ # Make sure cache has field
+ self.assertTrue(_field_value_cache.has_key(cache_id))
+ # Make sure cache and field are equal
+ self.assertEquals(field.get_value(id), _field_value_cache[cache_id])
+ # Call manage_renameObject
+ form.manage_renameObject('my_first_name', 'my_first_name2')
+ form.manage_renameObject('my_first_name2', 'my_first_name')
+ # Make sure cache has no field
+ self.assertFalse(_field_value_cache.has_key(cache_id))
+ # Render
+ form()
+ # Make sure cache has field
+ self.assertTrue(_field_value_cache.has_key(cache_id))
+ # Make sure cache and field are equal
+ self.assertEquals(field.get_value(id), _field_value_cache[cache_id])
More information about the Erp5-report
mailing list