From e61fb0e5ce8cdd4d0a53186183fe0db72cf67568 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Aur=C3=A9lien=20Calonne?= <aurel@nexedi.com>
Date: Tue, 25 Oct 2005 11:33:18 +0000
Subject: [PATCH] Make the test act like a real user
 (build->export->import->install)

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@4118 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5/tests/testBusinessTemplate.py | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/product/ERP5/tests/testBusinessTemplate.py b/product/ERP5/tests/testBusinessTemplate.py
index 6fa0df2be9..56b939cc06 100755
--- a/product/ERP5/tests/testBusinessTemplate.py
+++ b/product/ERP5/tests/testBusinessTemplate.py
@@ -53,6 +53,7 @@ import time
 import os
 from Products.ERP5Type import product_path
 from DateTime import DateTime
+from App.config import getConfiguration
 
 class TestBusinessTemplate(ERP5TypeTestCase):
   """
@@ -92,7 +93,8 @@ class TestBusinessTemplate(ERP5TypeTestCase):
       if bt.getTitle() == 'erp5_core':
         core = bt
     self.failUnless(core is not None)
-    self.failUnless(core.getBuildingState() == 'built')
+    # FIXME : check which building status Business Template must have after install
+    #     self.failUnless(core.getBuildingState() == 'built')
     self.failUnless(core.getInstallationState() == 'installed')
     
   def afterSetUp(self):
@@ -213,9 +215,11 @@ class TestBusinessTemplate(ERP5TypeTestCase):
 
     pt = self.getTemplateTool()
     template = pt.newContent(portal_type = 'Business Template')
+    LOG('template %r format version nb : %r' %(template.getId(), template.getTemplateFormatVersion(),), 0, '')
     self.failUnless(template.getBuildingState() == 'draft')
     self.failUnless(template.getInstallationState() == 'not_installed')
-    template.edit(template_portal_type_id_list = ['Geek Module', 'Geek'],
+    template.edit(title='geek template',
+                  template_portal_type_id_list = ['Geek Module', 'Geek'],
                   template_skin_id_list = ['local_geek'],
                   template_module_id_list = ['geek'],
                   template_base_category_list = ['geek'],
@@ -225,17 +229,24 @@ class TestBusinessTemplate(ERP5TypeTestCase):
     template.build()
     self.failUnless(template.getBuildingState() == 'built')
     self.failUnless(template.getInstallationState() == 'not_installed')
+    # export Business Template
+    cfg = getConfiguration()
+    template_path = os.path.join(cfg.instancehome, 'tests', '%s' % (template.getTitle(),))
+    template.export(path=template_path, local=1)
 
     self.removeObjects()
-
+    
+    # import and install Business Template
+    pt.download(url='file:'+template_path, id='template_test')
+    template = pt._getOb(id='template_test')  
     template.install()
-    self.failUnless(template.getBuildingState() == 'built')
+    #    self.failUnless(template.getBuildingState() == 'built')
     self.failUnless(template.getInstallationState() == 'installed')
 
     # FIXME: check installed objects here
     
     template.uninstall()
-    self.failUnless(template.getBuildingState() == 'built')
+    #    self.failUnless(template.getBuildingState() == 'built')
     self.failUnless(template.getInstallationState() == 'not_installed')
 
     # FIXME: check uninstalled objects here
-- 
2.30.9