[Zope-Checkins] CVS: Zope3/lib/python/Zope/Server/VFS/tests - testOSFileSystem.py:1.1.2.2

Stephan Richter srichter@cbu.edu
Tue, 2 Apr 2002 18:25:00 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/Server/VFS/tests
In directory cvs.zope.org:/tmp/cvs-serv4703/tests

Modified Files:
      Tag: Zope3-Server-Branch
	testOSFileSystem.py 
Log Message:
IReadFileSystem tests written and passing



=== Zope3/lib/python/Zope/Server/VFS/tests/testOSFileSystem.py 1.1.2.1 => 1.1.2.2 ===
 import unittest
 import os
+import stat
 import tempfile
 
 from Interface.Verify import verifyClass
@@ -33,12 +34,14 @@
     """
 
     filesystem_class = OSFileSystem
+    root = None
     
     def setUp(self):
-        tempdir = tempfile.gettempdir()
-        self.root = os.path.join(tempdir, 'Test')
+        if self.root is None:
+            self.root = tempfile.mktemp()
+            self.filesystem = self.filesystem_class(self.root)
+
         os.mkdir(self.root)
-        self.filesystem = self.filesystem_class(self.root)
 
 
     def tearDown(self):
@@ -78,8 +81,58 @@
         self.assertEqual(self.filesystem.translate('foo/bar'),
                          self.filesystem.path_module.join(self.root,
                                                           'foo', 'bar'))
+
+    def testExists(self):
+        path = os.path.join(self.root, 'foo')
+        open(path, 'w').write('test')
+        self.failUnless(self.filesystem.exists('foo'))
+        os.remove(path)
+
+
+    def testIsDir(self):
+        path = os.path.join(self.root, 'foo')
+        os.mkdir(path)
+        self.failUnless(self.filesystem.isdir('foo'))
+        os.rmdir(path)
+
+
+    def testIsFile(self):
+        path = os.path.join(self.root, 'foo')
+        open(path, 'w').write('test')
+        self.failUnless(self.filesystem.isfile('foo'))
+        os.remove(path)
+
+
+    def testListDir(self):
+        path = os.path.join(self.root, 'foo')
+        open(path, 'w').write('test')
+        self.assertEqual(self.filesystem.listdir('/', 0).more(),
+                         'foo\r\n')
+        os.remove(path)        
+
+
+    def testLongify(self):
+        path = os.path.join(self.root, 'foo')
+        open(path, 'w').write('test')
+        stat_info = os.stat(path)
+        result = self.filesystem.longify(('foo', stat_info))
+        self.failUnless(result.endswith('foo'))
+        os.remove(path)
         
-        
+
+    def testOpen(self):
+        path = os.path.join(self.root, 'foo')
+        open(path, 'w').write('writing test')
+        self.assertEqual(self.filesystem.open('foo', 'r').read(), 'writing test')
+        os.remove(path)
+
+
+    def testStat(self):
+        path = os.path.join(self.root, 'foo')
+        open(path, 'w').write('writing test')
+        self.assertEqual(self.filesystem.stat('foo'), os.stat(path))
+        os.remove(path)
+
 
     def testInterface(self):
         self.failUnless(
@@ -89,7 +142,6 @@
         self.failUnless(
             IWriteFileSystem.isImplementedByInstancesOf(self.filesystem_class))
         self.failUnless(verifyClass(IWriteFileSystem, self.filesystem_class))
-        
 
 
 def test_suite():