From: Kevin C. <ke...@us...> - 2006-02-28 11:58:22
|
Update of /cvsroot/mailmanager/MailManager/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12024/tests Modified Files: testRulesetEngine.py Log Message: Cleaned this up considerably. Test now runs useful code and passes Index: testRulesetEngine.py =================================================================== RCS file: /cvsroot/mailmanager/MailManager/tests/testRulesetEngine.py,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- testRulesetEngine.py 30 Jan 2006 15:37:42 -0000 1.8 +++ testRulesetEngine.py 28 Feb 2006 11:58:18 -0000 1.9 @@ -52,7 +52,7 @@ from Products.MailManager.ruleset.zope import ZopeRulesetEngine, manage_addRulesetEngine from Products.MailManager.ruleset.processticket import processtest, processtestMem - +from Products.MailManager.tests.classes import testStructures # @@ -67,17 +67,9 @@ ##################### -class RulesetTest(testGetMail.getMailTest, testDatabase.databaseTest): - """ - - - """ - def setupMailManager(self, dbplatform, debugmode): - testGetMail.getMailTest.setupMailManager(self, dbplatform = dbplatform, debugmode=debugmode) - manage_addRulesetEngine(self.mmobj, id = 'rulesetEngine', title = 'Ruleset Engine') - #engine = InMemoryRulesetEngine('mailmanager20') +class RulesetTest(testStructures.mailManagerTestCase): def rulesetEngineTests(self): """ Check that the ruleset processes various messages/combinations @@ -87,7 +79,6 @@ self.populateTicketsTest() self.processTest() - def generateRulesetTest(self): """ Generate the ruleset @@ -104,7 +95,6 @@ #self.mmobj.engine.generateFromConfig() #self.mmobj.engine.initialiseCache() - def populateTicketsTest(self): """ Load in the queuetests tickets and see if they are set into the correct queued state. @@ -112,6 +102,7 @@ self.mmobj.populateTickets('rulesettests') for ticket in self.mmobj.sql.listTickets(): print ticket.state + engine = self.mmobj.engine def processTest(self): """ Run the ruleset engine processing test @@ -121,98 +112,34 @@ """ engine = self.mmobj.engine - #processtestMem(engine) tickets = {} for ticket in self.mmobj.sql.listTickets(): print self.mmobj.ticket(id=ticket.id)[0] tickets[ticket.id] = self.mmobj.ticket(id=ticket.id)[0] - #print ticket.id, ticket.state def getTicket(id): return self.mmobj.ticket(id=id)[0] - #print tickets + processtest(engine, lambda: getTicket(1), lambda: getTicket(2), lambda: getTicket(3), ) - - - - -# # Load in the ruleset -# ticketpool = [] -# -# ticket = ticketState(1) -# ticket.state = 'Received' -# ticket.attributes = ['form'] -# ticket.assigned = 'kev' -# ticket.siblings = [2,3] -# ticket._ticketpool = ticketpool -# ticketpool.append(ticket) -# mainticket = ticket -# -# ticket = ticketState(2) -# ticket.state = 'Received' -# ticket.attributes = ['form'] -# ticket.assigned = 'kev' -# ticket.siblings = [1] -# ticket.parent = 1 -# ticket._ticketpool = ticketpool -# ticketpool.append(ticket) -# opensibling = ticket -# -# ticket = ticketState(3) -# ticket.state = 'Received' -# ticket.attributes = ['form'] -# ticket.assigned = 'kev' -# ticket._ticketpool = ticketpool -# ticketpool.append(ticket) -# secondticket = ticket -# -# engine.ticketpool = ticketpool -# -# processtest(engine, mainticket, opensibling, secondticket) -# - - ########################################################################### class TestRuleset(RulesetTest): -# def testMySQL(self): -# return -# if 'mysql' in self.config['databases']['supported_databases']: -# self.dbplatform = 'mysql' -# self.sqlmethods = {} -# for sqlmethod in testDatabase.sqlmethods: -# self.sqlmethods[sqlmethod] = testDatabase.ZSQLFileMethod('%s.zsql' % sqlmethod, dbplatform=self.dbplatform) -# self.sqlmethods[sqlmethod].schema = '' -# self.setupMailManager(dbplatform = self.dbplatform, debugmode=True) -# self.mmobj.wipeDataset('acmestatic') -# self.mmobj.populateDataset('acmestatic') -# # self.mmobj.sql.populateRuleset('acmestatic') -# self.rulesetEngineTests() -# self.removeMailManager() - def testPostgres(self): - if 'postgres' in self.config['databases']['supported_databases']: - self.dbplatform = 'postgres' - self.sqlmethods = {} - for sqlmethod in testDatabase.sqlmethods: - self.sqlmethods[sqlmethod] = testDatabase.ZSQLFileMethod('%s.zsql' % sqlmethod, dbplatform=self.dbplatform) - self.sqlmethods[sqlmethod].schema = self.config['database_postgres']['schema'] - self.setupMailManager(dbplatform = self.dbplatform, debugmode=True) - self.mmobj.wipeDataset('rulesettests') - self.mmobj.populateDataset('rulesettests') - #self.mmobj.wipeDataset('queuetests') - #self.mmobj.populateAccounts('queuetests') - # self.mmobj.sql.populateRuleset('acmestatic') - self.rulesetEngineTests() - self.removeMailManager() + self.dbplatform = self.config['databases']['primary_database'] + self.setupMailManager(dbplatform = self.dbplatform, debugmode=True) + self.mmobj.wipeDataset('rulesettests') + self.mmobj.populateDataset('rulesettests') + # self.mmobj.sql.populateRuleset('acmestatic') + self.rulesetEngineTests() + self.removeMailManager() ########################################################################### |