Skip to content

Commit

Permalink
Test coverage for filestore module.
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Parkin & Matt Goodall <info@ish.io>
  • Loading branch information
Chris McDonough authored and ish committed Sep 15, 2009
1 parent ce6c1ef commit f73bb17
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions formish/tests/unittests/test_filestores.py
Expand Up @@ -27,6 +27,10 @@ def test_put(self):
finally:
f.close()

def test_put_headersdict(self):
self.store.put('foo', {'Cache-Tag':'1', 'Content-Type':'text/plain'}, StringIO("Yay!"))
assert file(os.path.join(self.dirname, 'foo'), 'rb').read() == 'Cache-Tag: 1\nContent-Type: text/plain\n\nYay!'

def test_get(self):
self.store.put('foo', [('Cache-Tag', '1'), ('Content-Type', 'text/plain')], StringIO("Yay!"))
headers, f = self.store.get('foo')
Expand All @@ -53,6 +57,11 @@ def test_delete(self):
self.store.delete('foo')
self.assertRaises(KeyError, self.store.get, 'foo')

def test_delete_glob(self):
self.store.put('foo', [], StringIO('foo'))
self.store.delete('fo', glob=True)
self.assertRaises(KeyError, self.store.get, 'foo')

def test_unicode(self):
gbp = '£'.decode('utf-8')
self.store.put('foo', [('a', gbp)], StringIO('foo'))
Expand All @@ -75,6 +84,11 @@ def test_put(self):
self.store.put('foo', StringIO('bar'), '1', [('Content-Type', 'text/plain')])
assert file(os.path.join(self.dirname, 'foo'), 'rb').read() == 'Cache-Tag: 1\nContent-Type: text/plain\n\nbar'

def test_put_noheaders(self):
self.store.put('foo', StringIO('bar'), '1')
self.assertEqual(open(os.path.join(self.dirname, 'foo'), 'rb').read(),
'Cache-Tag: 1\n\nbar')

def test_get(self):
self.store.put('foo', StringIO('bar'), '1', [('Content-Type', 'text/plain')])
(cache_tag, headers, f) = self.store.get('foo')
Expand Down Expand Up @@ -122,3 +136,6 @@ def test_none_cache_tag(self):
finally:
f.close()

def test_delete(self):
self.assertRaises(OSError, self.store.delete, 'not_found')

0 comments on commit f73bb17

Please sign in to comment.