[Zope-CVS] CVS: Products/ZopeVersionControl/tests -
testReferenceVersioning.py:1.4 testVersionControl.py:1.9
Tres Seaver
tseaver at palladion.com
Wed Sep 20 11:05:06 EDT 2006
Update of /cvs-repository/Products/ZopeVersionControl/tests
In directory cvs.zope.org:/tmp/cvs-serv30243/tests
Modified Files:
testReferenceVersioning.py testVersionControl.py
Log Message:
- Fixed compatibility with Zope 2.8 and new-style objects
o http://www.zope.org/Collectors/Zope/2137
=== Products/ZopeVersionControl/tests/testReferenceVersioning.py 1.3 => 1.4 ===
--- Products/ZopeVersionControl/tests/testReferenceVersioning.py:1.3 Mon May 3 11:25:03 2004
+++ Products/ZopeVersionControl/tests/testReferenceVersioning.py Wed Sep 20 11:05:05 2006
@@ -1,4 +1,4 @@
- ##############################################################################
+##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
@@ -14,18 +14,10 @@
$Id$
"""
-
-import Zope
-try:
- Zope.startup()
-except NameError: # pre Zope 2.6.1
- pass
-
import unittest
-from Products.ZopeVersionControl.tests.testVersionControl \
- import VersionControlTests
-from OFS.DTMLDocument import addDTMLDocument
+from common import common_setUp
+from common import common_tearDown
has_refs = 1
try:
@@ -35,13 +27,14 @@
class ReferenceVCTests(unittest.TestCase):
- setUp = VersionControlTests.setUp.im_func
- tearDown = VersionControlTests.tearDown.im_func
- commit = VersionControlTests.commit.im_func
+ setUp = common_setUp
+ tearDown = common_tearDown
def testContainerVersioning(self):
# Verify that containers and items are versioned independently,
# except in the case of references.
+ from OFS.DTMLDocument import addDTMLDocument
+
repository = self.repository
folder1 = self.app.folder1
folder2 = folder1.folder2
=== Products/ZopeVersionControl/tests/testVersionControl.py 1.8 => 1.9 ===
--- Products/ZopeVersionControl/tests/testVersionControl.py:1.8 Tue Feb 24 13:30:10 2004
+++ Products/ZopeVersionControl/tests/testVersionControl.py Wed Sep 20 11:05:05 2006
@@ -1,4 +1,4 @@
- ##############################################################################
+##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
@@ -10,88 +10,24 @@
# FOR A PARTICULAR PURPOSE
#
##############################################################################
+""" Test the ZVC machinery
-__version__='$Revision$'[11:-2]
-
-import Zope
-try:
- Zope.startup()
-except NameError: # pre Zope 2.6.1
- pass
-
-import os, sys, unittest, ZODB, Acquisition, cStringIO
-from AccessControl.SecurityManagement import newSecurityManager
-from AccessControl.SecurityManagement import noSecurityManager
-from Testing.makerequest import makerequest
-from AccessControl import SecurityManager
-from OFS.DTMLDocument import addDTMLDocument
-from OFS.Application import Application
-from OFS.Folder import manage_addFolder
-
+$Id$
+"""
+import unittest
+
+from common import get_transaction
+from common import common_setUp
+from common import common_tearDown
+from common import common_commit
class VersionControlTests(unittest.TestCase):
- def setUp(self):
- # Install a hack to make SimpleItem version aware, so that the
- # tests work. In normal development, you would mix in the
- # VersionSupport class on an as-needed basis.
- import Products.ZopeVersionControl
- Products.ZopeVersionControl.install_hack()
-
- from Products.ZopeVersionControl.ZopeRepository import addRepository
- from ZODB.DemoStorage import DemoStorage
- s = DemoStorage(quota=(1<<20))
- self.connection = ZODB.DB( s ).open()
- try:
- r = self.connection.root()
- a = Application()
- r['Application'] = a
- self.root = a
- responseOut = self.responseOut = cStringIO.StringIO()
- self.app = makerequest( self.root, stdout=responseOut )
- self.app.acl_users.userFolderAddUser('UnitTester', '123', (), ())
- manage_addFolder(self.app, 'folder1')
- self.folder1 = getattr(self.app, 'folder1')
- manage_addFolder(self.folder1, 'folder2')
- self.folder2 = getattr(self.folder1, 'folder2')
- addDTMLDocument(self.folder2, 'document1', file='some text')
- self.document1 = getattr(self.folder2, 'document1')
- addDTMLDocument(self.folder2, 'document2', file='some text')
- self.document2 = getattr(self.folder2, 'document2')
- addDTMLDocument(self.folder2, 'document_nonversion', file='some?')
- self.document_nonversion = getattr(self.folder2,
- 'document_nonversion')
- self.document_nonversion.__non_versionable__ = 1
- addRepository(self.folder1, 'repository')
- self.repository = getattr(self.folder1, 'repository')
- get_transaction().commit()
- except:
- self.connection.close()
- raise
- get_transaction().begin()
- user = self.app.acl_users.getUser('UnitTester')
- user = user.__of__(self.app.acl_users)
- newSecurityManager( None, user)
-
- def tearDown(self):
- noSecurityManager()
- del self.folder1
- del self.folder2
- del self.document1
- del self.document2
- get_transaction().abort()
- self.app._p_jar.sync()
- self.connection.close()
- del self.app
- del self.responseOut
- del self.root
- del self.connection
+ setUp = common_setUp
+ tearDown = common_tearDown
+ commit = common_commit
do_commits = 0
- def commit(self):
- if self.do_commits:
- get_transaction().commit()
-
def testIsVersionableResource(self):
# Test checking whether an object is a versionable resource.
@@ -733,6 +669,7 @@
def testContainerVersioning(self):
+ from OFS.DTMLDocument import addDTMLDocument
# Verify that containers and items are versioned independently.
repository = self.repository
folder1 = self.app.folder1
@@ -811,22 +748,33 @@
self.assertEqual(document.extra_attr, 'v1')
self.assertEqual(document.__ac_local_roles__, {})
+ def testNonVersionedAttributeWithAcquisition(self):
+ # Test a non-version-controlled attribute
+ # that is acquired does not cause an error
+ self.document1.__vc_ignore__ = ('dummy_attr',)
+ self.folder1.dummy_attr = 'dummy_attr'
+ self.assertEqual( self.folder1.dummy_attr, self.document1.dummy_attr )
+
+ repository = self.repository
+ document = repository.applyVersionControl(self.document1)
+ info = repository.getVersionInfo(document)
+ first_version = info.version_id
+ repository.checkoutResource(document)
+ self.document1.extra_attr = 'new'
+ repository.checkinResource(document)
+ repository.updateResource(document, first_version)
class VersionControlTestsWithCommits(VersionControlTests):
"""Version control test suite with transaction commits that mimic
the transaction commits that you would get with Web based usage."""
do_commits = 1
-
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(VersionControlTests))
suite.addTest(unittest.makeSuite(VersionControlTestsWithCommits))
return suite
-def main():
- unittest.main(defaultTest='test_suite')
-
if __name__ == '__main__':
- main()
+ unittest.main(defaultTest='test_suite')
More information about the Zope-CVS
mailing list