From c0450cf96d713c93cddb89d187f7f8dc7d0e0bf1 Mon Sep 17 00:00:00 2001 From: Sebastien Robin <seb@nexedi.com> Date: Fri, 10 Dec 2004 14:55:04 +0000 Subject: [PATCH] first submission git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@1985 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5Catalog/tests/testCatalog.py | 135 +++++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100755 product/ERP5Catalog/tests/testCatalog.py diff --git a/product/ERP5Catalog/tests/testCatalog.py b/product/ERP5Catalog/tests/testCatalog.py new file mode 100755 index 0000000000..676a6dd337 --- /dev/null +++ b/product/ERP5Catalog/tests/testCatalog.py @@ -0,0 +1,135 @@ +############################################################################## +# +# Copyright (c) 2004 Nexedi SARL and Contributors. All Rights Reserved. +# Sebastien Robin <seb@nexedi.com> +# +# 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. +# +############################################################################## + + + +# +# 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 Testing import ZopeTestCase +from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase +from AccessControl.SecurityManagement import newSecurityManager, noSecurityManager +from DateTime import DateTime +from Acquisition import aq_base, aq_inner +from zLOG import LOG +from Products.ERP5Type.DateUtils import addToDate +import time +import os +from Products.ERP5Type import product_path +from DateTime import DateTime + +class Test(ERP5TypeTestCase): + """ + This is the list of test + + test setNextStartDate : + - every hour + - at 6, 10, 15, 21 every day + - every day at 10 + - every 3 days at 14 and 15 and 17 + - every monday and friday, at 6 and 15 + - every 1st and 15th every month, at 12 and 14 + - every 1st day of every 2 month, at 6 + """ + + # Different variables used for this test + run_all_test = 1 + source_company_id = 'Nexedi' + destination_company_id = 'Coramy' + component_id = 'brick' + sales_order_id = '1' + quantity = 10 + base_price = 0.7832 + + #def populate(self, quiet=1, run=1): + def afterSetUp(self, quiet=1, run=1): + self.login() + portal = self.getPortal() + catalog_tool = self.getCatalogTool() + # XXX This does not works + #catalog_tool.reindexObject(portal) + + # First reindex + #LOG('afterSetup',0,'portal.portal_categories.immediateReindexObject') + #portal.portal_categories.immediateReindexObject() + #LOG('afterSetup',0,'portal.portal_simulation.immediateReindexObject') + #portal.portal_simulation.immediateReindexObject() + + def login(self, quiet=0, run=run_all_test): + uf = self.getPortal().acl_users + uf._doAddUser('seb', '', ['Manager'], []) + user = uf.getUserById('seb').__of__(uf) + newSecurityManager(None, user) + + def test_01_HasEverything(self, quiet=0, run=run_all_test): + # Test if portal_synchronizations was created + if not run: return + if not quiet: + ZopeTestCase._print('\nTest Has Everything ') + LOG('Testing... ',0,'testHasEverything') + self.failUnless(self.getCategoryTool()!=None) + self.failUnless(self.getSimulationTool()!=None) + self.failUnless(self.getTypeTool()!=None) + self.failUnless(self.getSqlConnection()!=None) + self.failUnless(self.getCatalogTool()!=None) + + def test_02_BadCatalog(self, quiet=0, run=run_all_test): + """ + We should make sure that if a catalog method fails, + then we will have an error on the user interface. + """ + if not run: return + if not quiet: + message = 'Test Initialization' + ZopeTestCase._print('\n%s ' % message) + LOG('Testing... ',0,message) + + + + + +if __name__ == '__main__': + framework() +else: + import unittest + def test_suite(): + suite = unittest.TestSuite() + suite.addTest(unittest.makeSuite(Test)) + return suite + -- 2.30.9