Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Zope: CVS
CVS: Products/ZopeVersionControl/tests - common.py:1.1
 

Index | Next | Previous | View Flat


tseaver at palladion

Feb 5, 2007, 8:16 AM


Views: 4098
Permalink
CVS: Products/ZopeVersionControl/tests - common.py:1.1

Update of /cvs-repository/Products/ZopeVersionControl/tests
In directory cvs.zope.org:/tmp/cvs-serv14512/tests

Added Files:
common.py
Log Message:
- Add omitted 'tests/common.py' module; tag 0.3.4.


=== Added File Products/ZopeVersionControl/tests/common.py ===
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
""" Unit testing utilities

$Id: common.py,v 1.1 2007/02/05 16:16:27 tseaver Exp $
"""
try:
import transaction
except ImportError: # Zope < 2.8
get_transaction = get_transaction
else:
def get_transaction():
return transaction

def common_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 cStringIO
from AccessControl.SecurityManagement import newSecurityManager
from OFS.Application import Application
from OFS.DTMLDocument import addDTMLDocument
from OFS.Folder import manage_addFolder
from Testing.makerequest import makerequest

import Products.ZopeVersionControl
Products.ZopeVersionControl.install_hack()

from Products.ZopeVersionControl.ZopeRepository import addRepository
from ZODB import DB
from ZODB.DemoStorage import DemoStorage
s = DemoStorage(quota=(1<<20))
self.connection = 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 common_tearDown(self):
from AccessControl.SecurityManagement import noSecurityManager
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

def common_commit(self):
if self.do_commits:
get_transaction().commit()


_______________________________________________
Zope-CVS maillist - Zope-CVS [at] zope
http://mail.zope.org/mailman/listinfo/zope-cvs

Zope CVS instructions: http://dev.zope.org/CVS

Subject User Time
CVS: Products/ZopeVersionControl/tests - common.py:1.1 tseaver at palladion Feb 5, 2007, 8:16 AM

  Index | Next | Previous | View Flat
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.