[CMF-checkins] CVS: CMF/CMFCore/tests - test_DirectoryView.py:1.1.2.1

Chris Withers chrisw@nipltd.com
Fri, 25 Jan 2002 07:20:10 -0500


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

Modified Files:
      Tag: ChrisW-DirectoryView_fix-branch
	test_DirectoryView.py 
Log Message:
These tests don't work since I can' t simulate switching into debug mode properly :-(

=== CMF/CMFCore/tests/test_DirectoryView.py 1.1 => 1.1.2.1 ===
 from unittest import TestCase, TestSuite, makeSuite, main
 from Products.CMFCore.DirectoryView import registerDirectory,addDirectoryViews,DirectoryViewSurrogate
-from Globals import package_home
+from Globals import package_home, DevelopmentMode
 from Acquisition import Implicit
-from os import remove
+from os import remove, mkdir, rmdir
 from os.path import join
 from shutil import copy2
 
@@ -63,6 +63,8 @@
 
 test1path = join(skin_path_name,'test1.py')
 test2path = join(skin_path_name,'test2.py')
+test3path = join(skin_path_name,'test3')
+
 
 class DebugModeTests( TestCase ):
 
@@ -80,6 +82,8 @@
         Products.CMFCore.DirectoryView.registerDirectory('fake_skins', globals())
         ob = self.ob = Dummy()
         Products.CMFCore.DirectoryView.addDirectoryViews(ob, 'fake_skins', globals())
+
+        print "in test"
         
         # add a method to the fake skin folder
         f = open(test2path,'w')
@@ -92,13 +96,26 @@
         f.write("return 'new test1'")
         f.close()
 
+        # add a new folder
+        mkdir(test3path)
+        
+
     def tearDown( self ):
         
         # undo FS changes
         remove(test1path)
         copy2(test1path+'.bak',test1path)
         remove(test1path+'.bak')
-        remove(test2path)
+        try:        
+            remove(test2path)
+        except (IOError,OSError):
+            # it might be gone already
+            pass
+        try:
+            rmdir(test3path)
+        except (IOError,OSError):
+            # it might be gone already
+            pass
         
         # take us out of debug mode, preserve the DirectoryRegistry
         Globals.DevelopmentMode=None
@@ -120,6 +137,37 @@
         """
         assert self.ob.fake_skin.test1()=='new test1'
 
+    def test_NewFolder( self ):
+        """
+        See if a new folder shows up
+        """
+        # This fails for some bizarre reason :-( - CW
+        # assert isinstance(self.ob.fake_skin.test3,DirectoryViewSurrogate)
+        self.ob.fake_skin.test3.objectIds()
+
+    def test_DeleteMethod( self ):
+        """
+        Make sure a deleted method goes away
+        """
+        remove(test2path)
+        try:
+            self.ob.fake_skin.test2
+        except AttributeError:
+            pass
+        else:
+            self.fail('test2 still exists')
+
+    def test_DeleteFolder( self ):
+        """
+        Make sure a deleted folder goes away
+        """
+        rmdir(test3path)
+        try:
+            self.ob.fake_skin.test3
+        except AttributeError:
+            pass
+        else:
+            self.fail('test3 still exists')
 
 def test_suite():
     return TestSuite((