[CMF-checkins] CVS: CMF/CMFCore/tests - test_ActionInformation.py:1.2.14.1

Chris Withers chrisw@nipltd.com
Fri, 15 Feb 2002 12:09:55 -0500


Update of /cvs-repository/CMF/CMFCore/tests
In directory cvs.zope.org:/tmp/cvs-serv4421

Modified Files:
      Tag: ChrisW-refactor_tests-branch
	test_ActionInformation.py 
Log Message:
Done ActionInformation

=== CMF/CMFCore/tests/test_ActionInformation.py 1.2 => 1.2.14.1 ===
-from Products.CMFDefault.MembershipTool import *
-from Products.CMFCore.PortalContent import PortalContent
-from Products.CMFCore.ActionInformation import ActionInformation
-from Products.CMFCore.Expression import Expression, createExprContext
+import Zope
+from unittest import TestSuite, makeSuite, main
 
-class DummyMembershipTool:
-    def isAnonymousUser(self):
-        return 1
-  
-class DummyContent(PortalContent, OFS.SimpleItem.Item):
-    """
-    """
-    meta_type = 'Dummy'
-    url = 'foo_url'
+from Products.CMFCore.tests.base.testcase import \
+     TransactionalTest
 
-    def __init__(self, id, url=None):
-       self.url = url
+from Products.CMFCore.tests.base.dummy import \
+     DummyContent, DummyTool as DummyMembershipTool
 
-    def absolute_url(self):
-       return self.url
+from Products.CMFCore.ActionInformation import ActionInformation
+from Products.CMFCore.Expression import Expression, createExprContext
 
-class ActionInformationTests(unittest.TestCase):
+class ActionInformationTests(TransactionalTest):
     
     def setUp( self ):
-        get_transaction().begin()
-        self.connection = Zope.DB.open()
-        root = self.root = self.connection.root()[ 'Application' ]
+
+        TransactionalTest.setUp( self )
+
+        root = self.root
         root._setObject('portal', DummyContent('portal', 'url_portal'))
-        portal = self.portal = self.root.portal
+        portal = self.portal = root.portal
         portal.portal_membership = DummyMembershipTool()
         self.folder = DummyContent('foo', 'url_foo')
         self.object = DummyContent('bar', 'url_bar')
@@ -77,18 +68,10 @@
         ec = createExprContext(folder, portal, object)
         self.failIf(ai.testCondition(ec))
         
-    def tearDown( self ):
-        get_transaction().abort()
-        self.connection.close()
-        
-
 def test_suite():
-    suite = unittest.TestSuite()
-    suite.addTest(unittest.makeSuite(ActionInformationTests))
-    return suite
-
-def run():
-    unittest.TextTestRunner().run(test_suite())
+    return TestSuite((
+        makeSuite(ActionInformationTests),
+        ))
 
 if __name__ == '__main__':
-    run()
+    main(defaultTest='test_suite')