Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes
test_filesys.TestFuid Class Reference

List of all members.

Public Member Functions

def setup_method
def teardown_method
def testNoFile
def makefile
def testNewFile
def testUpdateFileInPlace
def testUpdateFileMovingFromTemp
def testStale

Public Attributes

 test_dir
 fname
 tmpname

Detailed Description

test filesys.fuid (a better mtime() alternative for up-to-date checking) 

Definition at line 15 of file test_filesys.py.


Member Function Documentation

def test_filesys.TestFuid.makefile (   self,
  fname,
  content 
)

Definition at line 32 of file test_filesys.py.

00032 
00033     def makefile(self, fname, content):
00034         f = open(fname, "w")
00035         f.write(content)
00036         f.close()

Here is the caller graph for this function:

def test_filesys.TestFuid.setup_method (   self,
  method 
)

Definition at line 18 of file test_filesys.py.

00018 
00019     def setup_method(self, method):
00020         self.test_dir = tempfile.mkdtemp('', 'fuid_')
00021         self.fname = os.path.join(self.test_dir, "fuid-test")
00022         self.tmpname = os.path.join(self.test_dir, "fuid-temp")

def test_filesys.TestFuid.teardown_method (   self,
  method 
)

Definition at line 23 of file test_filesys.py.

00023 
00024     def teardown_method(self, method):
00025         shutil.rmtree(self.test_dir)

Definition at line 37 of file test_filesys.py.

00037 
00038     def testNewFile(self):
00039         # freshly created file
00040         self.makefile(self.fname, "foo")
00041         uid1 = filesys.fuid(self.fname)
00042 
00043         assert uid1 is not None  # None would mean some failure in fuid()

Here is the call graph for this function:

Definition at line 26 of file test_filesys.py.

00026 
00027     def testNoFile(self):
00028         # no file created
00029         uid = filesys.fuid(self.fname)
00030 
00031         assert uid is None  # there is no file yet, fuid will fail internally and return None

Definition at line 69 of file test_filesys.py.

00069 
00070     def testStale(self):
00071         # is a file with mtime older than max_staleness considered stale?
00072         if sys.platform != 'win32':
00073             py.test.skip("max_staleness check only done on win32 because it doesn't support inode change detection")
00074 
00075         self.makefile(self.fname, "foo")
00076         uid1 = filesys.fuid(self.fname)
00077 
00078         time.sleep(2) # thanks for waiting :)
00079         uid2 = filesys.fuid(self.fname, max_staleness=1)
00080         assert uid2 != uid1  # should be considered stale if platform has no inode support
00081 

Here is the call graph for this function:

Definition at line 44 of file test_filesys.py.

00044 
00045     def testUpdateFileInPlace(self):
00046         # update file in place, changing size and maybe mtime
00047         self.makefile(self.fname, "foo")
00048         uid1 = filesys.fuid(self.fname)
00049 
00050         self.makefile(self.fname, "foofoo")
00051         uid2 = filesys.fuid(self.fname)
00052 
00053         assert uid2 != uid1 # we changed size and maybe mtime

Here is the call graph for this function:

Definition at line 54 of file test_filesys.py.

00054 
00055     def testUpdateFileMovingFromTemp(self):
00056         # update file by moving another file over it (see caching.update)
00057         # changing inode, maybe mtime, but not size
00058         if sys.platform == 'win32':
00059             py.test.skip("Inode change detection not supported on win32")
00060 
00061         self.makefile(self.fname, "foo")
00062         uid1 = filesys.fuid(self.fname)
00063 
00064         self.makefile(self.tmpname, "bar")
00065         os.rename(self.tmpname, self.fname)
00066         uid2 = filesys.fuid(self.fname)
00067 
00068         assert uid2 != uid1 # we didn't change size, but inode and maybe mtime

Here is the call graph for this function:


Member Data Documentation

Definition at line 20 of file test_filesys.py.

Definition at line 19 of file test_filesys.py.

Definition at line 21 of file test_filesys.py.


The documentation for this class was generated from the following file: