[CMF-checkins] CVS: CMF/CMFCore/tests/base - testcase.py:1.3.16.1
Chris Withers
chrisw@nipltd.com
Mon, 19 Aug 2002 08:41:04 -0400
Update of /cvs-repository/CMF/CMFCore/tests/base
In directory cvs.zope.org:/tmp/cvs-serv13298/CMFCore/tests/base
Modified Files:
Tag: chrisw-dirview-branch
testcase.py
Log Message:
Restructrue tests involving FSDV to work on a copy in the tempfile space. Also comment out tests for FSDV paths for now.
=== CMF/CMFCore/tests/base/testcase.py 1.3 => 1.3.16.1 ===
--- CMF/CMFCore/tests/base/testcase.py:1.3 Mon Mar 11 07:48:08 2002
+++ CMF/CMFCore/tests/base/testcase.py Mon Aug 19 08:41:04 2002
@@ -5,6 +5,11 @@
from AccessControl.SecurityManager import setSecurityPolicy
from Testing.makerequest import makerequest
from security import PermissiveSecurityPolicy, AnonymousUser
+from dummy import DummyFolder
+from os.path import join, abspath, dirname
+from os import curdir, mkdir, stat, remove
+from shutil import copytree,rmtree
+from tempfile import mktemp
class TransactionalTest( TestCase ):
@@ -46,3 +51,66 @@
def setUp(self):
SecurityTest.setUp(self)
self.root = makerequest(self.root)
+
+try:
+ __file__
+except NameError:
+ # Test was called directly, so no __file__ global exists.
+ _prefix = abspath(curdir)
+else:
+ # Test was called by another test.
+ _prefix = abspath(dirname(__file__))
+
+_prefix = abspath(join(_prefix,'..'))
+
+class FSDVTest( TestCase ):
+ # Base class for FSDV test, creates a fake skin
+ # copy that can be edited.
+
+ _sourceprefix = _prefix
+ _skinname = 'fake_skins'
+ _layername = 'fake_skin'
+
+ def _registerDirectory(self,object=None):
+ from Products.CMFCore.DirectoryView import registerDirectory
+ from Products.CMFCore.DirectoryView import addDirectoryViews
+ registerDirectory(self._skinname, self.tempname)
+ if object is not None:
+ ob = self.ob = DummyFolder()
+ addDirectoryViews(ob, self._skinname, self.tempname)
+
+ def _writeFile(self, filename, stuff):
+ # write some stuff to a file on disk
+ # make sure the file's modification time has changed
+ thePath = join(self.skin_path_name,filename)
+ try:
+ mtime1 = stat(thePath)[8]
+ except:
+ mtime1 = 0
+ mtime2 = mtime1
+ while mtime2==mtime1:
+ f = open(thePath,'w')
+ f.write(stuff)
+ f.close()
+ mtime2 = stat(thePath)[8]
+
+ def _deleteFile(self,filename):
+ remove(join(self.skin_path_name,filename))
+
+ def setUp(self):
+ # store the place where the skin copy will be created
+ self.tempname = mktemp()
+ # create the temporary folder
+ mkdir(self.tempname)
+ # copy the source fake skin to the new location
+ copytree(join(self._sourceprefix,
+ self._skinname),
+ join(self.tempname,
+ self._skinname))
+ # store the skin path name
+ self.skin_path_name = join(self.tempname,self._skinname,self._layername)
+
+ def tearDown(self):
+ # kill the copy
+ rmtree(self.tempname)
+