Back to index

moin  1.9.0~rc2
Public Member Functions
MoinMoin._tests.test_caching.TestCaching Class Reference

List of all members.

Public Member Functions

def test_persistence_simple
def test_persistence_pickle
def test_persistence_encode
def test_mtime
def test_remove
def test_update_needed
def test_filelike_readwrite

Detailed Description

Tests the caching module 

Definition at line 17 of file test_caching.py.


Member Function Documentation

Definition at line 79 of file test_caching.py.

00079 
00080     def test_filelike_readwrite(self):
00081         request = self.request
00082         key = 'nooneknowsit'
00083         arena = 'somethingfunny'
00084         data = "dontcare"
00085         cacheentry = caching.CacheEntry(request, arena, key, scope='wiki', do_locking=True,
00086                  use_pickle=False, use_encode=True)
00087         cacheentry.open(mode='w')
00088         cacheentry.write(data)
00089         cacheentry.close()
00090 
00091         assert cacheentry.exists()
00092 
00093         cacheentry.open(mode='r')
00094         rdata = cacheentry.read()
00095         cacheentry.close()
00096 
00097         assert data == rdata

Here is the call graph for this function:

test if cache mtime yields correct values 

Definition at line 49 of file test_caching.py.

00049 
00050     def test_mtime(self):
00051         """ test if cache mtime yields correct values """
00052         test_data = '12345abcde'
00053         now = time.time()
00054         cache = caching.CacheEntry(self.request, 'test_arena', 'test_key', 'wiki')
00055         cache.update(test_data)
00056         assert now - 2 <= cache.mtime() <= now + 2

Here is the call graph for this function:

test if cache persists (on disk), use encoded string 

Definition at line 38 of file test_caching.py.

00038 
00039     def test_persistence_encode(self):
00040         """ test if cache persists (on disk), use encoded string """
00041         test_data = u"üöäÜÖÄß"
00042         cache = caching.CacheEntry(self.request, 'test_arena', 'test_key', 'wiki', use_encode=True)
00043         cache.update(test_data)
00044         del cache
00045         cache = caching.CacheEntry(self.request, 'test_arena', 'test_key', 'wiki', use_encode=True)
00046         cache_data = cache.content()
00047         assert type(cache_data) == type(test_data)
00048         assert cache_data == test_data

Here is the call graph for this function:

test if cache persists (on disk), use pickle 

Definition at line 29 of file test_caching.py.

00029 
00030     def test_persistence_pickle(self):
00031         """ test if cache persists (on disk), use pickle """
00032         test_data = {1: 2, 2: 3, 3: [4, 5, ], }
00033         cache = caching.CacheEntry(self.request, 'test_arena', 'test_key', 'wiki', use_pickle=True)
00034         cache.update(test_data)
00035         del cache
00036         cache = caching.CacheEntry(self.request, 'test_arena', 'test_key', 'wiki', use_pickle=True)
00037         assert test_data == cache.content()

Here is the call graph for this function:

test if cache persists (on disk) 

Definition at line 20 of file test_caching.py.

00020 
00021     def test_persistence_simple(self):
00022         """ test if cache persists (on disk) """
00023         test_data = '12345abcde'
00024         cache = caching.CacheEntry(self.request, 'test_arena', 'test_key', 'wiki')
00025         cache.update(test_data)
00026         del cache
00027         cache = caching.CacheEntry(self.request, 'test_arena', 'test_key', 'wiki')
00028         assert test_data == cache.content()

Here is the call graph for this function:

test if cache file removal works 

Definition at line 57 of file test_caching.py.

00057 
00058     def test_remove(self):
00059         """ test if cache file removal works """
00060         cache = caching.CacheEntry(self.request, 'test_arena', 'test_key', 'wiki')
00061         assert cache.exists()
00062         cache.remove()
00063         assert not cache.exists()

Here is the call graph for this function:

test update check) 

Definition at line 64 of file test_caching.py.

00064 
00065     def test_update_needed(self):
00066         """ test update check) """
00067         test_data1 = u'does not matter'
00068         test_data2 = u'something else'
00069         page_name = u'Caching_TestPage'
00070         page = PageEditor(self.request, page_name)
00071         page._write_file(test_data1)
00072         cache = caching.CacheEntry(self.request, page, 'test_key', 'item')
00073         cache.update(test_data1)
00074         assert not cache.needsUpdate(page._text_filename())
00075         time.sleep(3) # XXX fails without, due to mtime granularity
00076         page = PageEditor(self.request, page_name)
00077         page._write_file(test_data2)
00078         assert cache.needsUpdate(page._text_filename())

Here is the call graph for this function:


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