From 68b9a27279d1af96f1fffb159259d14b4402802b Mon Sep 17 00:00:00 2001
From: Jean-Paul Smets <jp@nexedi.com>
Date: Thu, 16 Dec 2004 16:03:31 +0000
Subject: [PATCH] removed bt list (as in CVS)

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@2021 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Type/tests/testERP5Type.py | 31 ++++++++++++++++++++++++--
 1 file changed, 29 insertions(+), 2 deletions(-)

diff --git a/product/ERP5Type/tests/testERP5Type.py b/product/ERP5Type/tests/testERP5Type.py
index 8b0d80bc55..1cc02e49b7 100755
--- a/product/ERP5Type/tests/testERP5Type.py
+++ b/product/ERP5Type/tests/testERP5Type.py
@@ -2,14 +2,18 @@
 # Skeleton ZopeTestCase
 #
 
-from random import randint
-
 import os, sys
 if __name__ == '__main__':
     execfile(os.path.join(sys.path[0], 'framework.py'))
 
+# Needed in order to have a log file inside the current folder
+os.environ['EVENT_LOG_FILE'] = os.path.join(os.getcwd(), 'zLOG.log')
+os.environ['EVENT_LOG_SEVERITY'] = '-300'
+
+from random import randint
 from Testing import ZopeTestCase
 from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
+from zLOG import LOG
 
 class TestERP5Type(ERP5TypeTestCase):
 
@@ -77,6 +81,29 @@ class TestERP5Type(ERP5TypeTestCase):
       test_string = self.getRandomString()
       business_template.setTitle(test_string)
       self.failUnless(business_template.getTitle()==test_string)
+    
+    # Test Dynamic Code Generation
+    def test_01_AqDynamic(self):
+      portal = self.getPortal()
+      #module = portal.person
+      from Products.ERP5Type.Base import initializeDynamicProperties, Base
+      from Products.ERP5Type import Document
+      initializeDynamicProperties(portal, Base)
+      # Base class should now have a state method
+      #self.failUnless(hasattr(Base, 'getFirstName'))
+    
+    
+    def test_02_AqDynamic(self):
+      portal = self.getPortal()
+      module = portal.person
+      person = module.newContent(id='1', portal_type='Person')
+      from Products.ERP5Type import Document
+      # Person class should have no method getFirstName
+      self.failUnless(not hasattr(Document.Person, 'getFirstName'))
+      # Calling getFirstName should produce dynamic methods
+      name = person.getFirstName()
+      # Person class should now have method getFirstName
+      self.failUnless(hasattr(Document.Person, 'getFirstName'))
 
 
 if __name__ == '__main__':
-- 
2.30.9