[Zope-CVS] CVS: Products/FileCacheManager/tests - stresstest.py:1.1
Jens Vagelpohl
jens at dataflake.org
Mon Aug 16 06:03:09 EDT 2004
Update of /cvs-repository/Products/FileCacheManager/tests
In directory cvs.zope.org:/tmp/cvs-serv30740/tests
Added Files:
stresstest.py
Log Message:
- add a stresstesting script skeleton
=== Added File Products/FileCacheManager/tests/stresstest.py ===
##############################################################################
#
# Copyright (c) 2004 Chris McDonough, Paul Winkler, Jens Vagelpohl and
# Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (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.
#
##############################################################################
import os
import ZODB
from ZODB.MappingStorage import MappingStorage
from OFS.Folder import Folder
from Products.PythonScripts.PythonScript import manage_addPythonScript
from Products.FileCacheManager import FileCacheManager
FCM_ID = 'fcm1'
PYSCRIPT_ID = 'ps1'
ROOT = None
######################
# Tweakable items
FCM_DIR = '/tmp/foo'
FCM_NAMING_EXPRESSION = ''
PYSCRIPT_PARAMS = ''
PYSCRIPT_BODY = """
"""
# End tweakable items
######################
def setUp():
# First, create a ZODB for the ZODB-based objects
s = MappingStorage()
db = ZODB.DB(s)
jar = db.open()
app_root = jar.root()
folder = Folder('testing')
app_root['testing'] = folder
global ROOT
ROOT = app_root.get('testing')
# Now stick a FileCacheManager object into our testing root
factory = FileCacheManager.manage_addFileCacheManager
factory(ROOT, FCM_ID, path=FCM_DIR, title='Testing FCM')
fcm = getattr(ROOT, FCM_ID)
# Set up a naming expression from FCM_NAMING_EXPRESSION above
fcm.setNamingExpression(FCM_NAMING_EXPRESSION)
assert fcm.getNamingExpression() == FCM_NAMING_EXPRESSION
# Set up a Script(Python) to be used in the naming expression
manage_addPythonScript(ROOT, PYSCRIPT_ID)
pyscript = getattr(ROOT, PYSCRIPT_ID)
pyscript.ZPythonScript_edit(PYSCRIPT_PARAMS, PYSCRIPT_BODY)
assert pyscript.params() == PYSCRIPT_PARAMS
assert pyscript.body() == PYSCRIPT_BODY.strip()
def tearDown():
for root, dirs, files in os.walk(FCM_DIR, topdown=False):
for name in files:
os.unlink(os.path.join(root, name))
for name in dirs:
os.rmdir(os.path.join(root, name))
def stress():
print ROOT.objectIds()
def run():
# Set up the testing environment
setUp()
stress()
tearDown()
if __name__ == '__main__':
run()
More information about the Zope-CVS
mailing list