|
@@ -7,6 +7,9 @@ from cPickle import dumps
|
|
|
from cache import ADMINISTRATION_FILE, assert_file_exists, to_dir, Cache
|
|
from cache import ADMINISTRATION_FILE, assert_file_exists, to_dir, Cache
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+d = os.path.realpath('') + '/'
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
class TestCache(unittest.TestCase):
|
|
class TestCache(unittest.TestCase):
|
|
|
def setUp(self):
|
|
def setUp(self):
|
|
|
if os.path.exists('baz'):
|
|
if os.path.exists('baz'):
|
|
@@ -32,34 +35,35 @@ class TestCache(unittest.TestCase):
|
|
|
self.assertRaises(IOError, assert_file_exists, 'foobar')
|
|
self.assertRaises(IOError, assert_file_exists, 'foobar')
|
|
|
|
|
|
|
|
def test_to_dir(self):
|
|
def test_to_dir(self):
|
|
|
- self.assertEqual(to_dir(''), '')
|
|
|
|
|
- self.assertEqual(to_dir('foo'), 'foo/')
|
|
|
|
|
- self.assertEqual(to_dir('foo/'), 'foo/')
|
|
|
|
|
|
|
+ self.assertEqual(to_dir(''), d)
|
|
|
|
|
+ self.assertEqual(to_dir('foo'), d)
|
|
|
|
|
+ self.assertEqual(to_dir('foo/'), d + 'foo/')
|
|
|
|
|
+ self.assertEqual(to_dir('foo/bar.txt'), d + 'foo/')
|
|
|
|
|
|
|
|
def test___init__(self):
|
|
def test___init__(self):
|
|
|
self.assertTrue(hasattr(self.c, 'root'))
|
|
self.assertTrue(hasattr(self.c, 'root'))
|
|
|
- self.assertEqual(self.c.root, 'baz/')
|
|
|
|
|
|
|
+ self.assertEqual(self.c.root, d + 'baz/')
|
|
|
self.assertTrue(hasattr(self.c, 'files'))
|
|
self.assertTrue(hasattr(self.c, 'files'))
|
|
|
- self.assertEqual(self.c.files, ['baz/foo', 'baz/bar'])
|
|
|
|
|
|
|
+ self.assertEqual(self.c.files, [d + 'baz/foo', d + 'baz/bar'])
|
|
|
self.assertTrue(hasattr(self.c, 'cached'))
|
|
self.assertTrue(hasattr(self.c, 'cached'))
|
|
|
- self.assertEqual(self.c.cached, 'cached/')
|
|
|
|
|
|
|
+ self.assertEqual(self.c.cached, d + 'cached/')
|
|
|
|
|
|
|
|
def test___init___custom_root(self):
|
|
def test___init___custom_root(self):
|
|
|
c = Cache(root='foo')
|
|
c = Cache(root='foo')
|
|
|
self.assertTrue(hasattr(c, 'root'))
|
|
self.assertTrue(hasattr(c, 'root'))
|
|
|
- self.assertEqual(c.root, 'foo/')
|
|
|
|
|
|
|
+ self.assertEqual(c.root, d + 'foo/')
|
|
|
|
|
|
|
|
def test___init___custom_cached_dir(self):
|
|
def test___init___custom_cached_dir(self):
|
|
|
c = Cache(cached='foo')
|
|
c = Cache(cached='foo')
|
|
|
self.assertTrue(hasattr(c, 'cached'))
|
|
self.assertTrue(hasattr(c, 'cached'))
|
|
|
- self.assertEqual(c.cached, 'foo/')
|
|
|
|
|
|
|
+ self.assertEqual(c.cached, d + 'foo/')
|
|
|
|
|
|
|
|
def test___init___non_existant_file(self):
|
|
def test___init___non_existant_file(self):
|
|
|
self.assertRaises(IOError, Cache, files=['foo'])
|
|
self.assertRaises(IOError, Cache, files=['foo'])
|
|
|
|
|
|
|
|
def test_add(self):
|
|
def test_add(self):
|
|
|
self.c.add('baz')
|
|
self.c.add('baz')
|
|
|
- self.assertIn('baz/baz', self.c.files)
|
|
|
|
|
|
|
+ self.assertIn(d + 'baz/baz', self.c.files)
|
|
|
|
|
|
|
|
def test_add_non_relative(self):
|
|
def test_add_non_relative(self):
|
|
|
self.c.add('baz', absolute=True)
|
|
self.c.add('baz', absolute=True)
|
|
@@ -67,16 +71,16 @@ class TestCache(unittest.TestCase):
|
|
|
|
|
|
|
|
def test_remove(self):
|
|
def test_remove(self):
|
|
|
self.c.remove('foo')
|
|
self.c.remove('foo')
|
|
|
- self.assertNotIn('baz/foo', self.c.files)
|
|
|
|
|
|
|
+ self.assertNotIn(d + 'baz/foo', self.c.files)
|
|
|
|
|
|
|
|
def test_remove_non_relative(self):
|
|
def test_remove_non_relative(self):
|
|
|
- self.c.remove('baz/foo', absolute=True)
|
|
|
|
|
- self.assertNotIn('baz/foo', self.c.files)
|
|
|
|
|
|
|
+ self.c.remove(d + 'baz/foo', absolute=True)
|
|
|
|
|
+ self.assertNotIn(d + 'baz/foo', self.c.files)
|
|
|
|
|
|
|
|
def test_assert_modification_dates_exist(self):
|
|
def test_assert_modification_dates_exist(self):
|
|
|
self.c.assert_modification_dates_exist()
|
|
self.c.assert_modification_dates_exist()
|
|
|
- self.assertIn('baz/foo', self.c.modified)
|
|
|
|
|
- self.assertEqual(self.c.modified['baz/foo'],
|
|
|
|
|
|
|
+ self.assertIn(d + 'baz/foo', self.c.modified)
|
|
|
|
|
+ self.assertEqual(self.c.modified[d + 'baz/foo'],
|
|
|
os.path.getmtime('baz/foo'))
|
|
os.path.getmtime('baz/foo'))
|
|
|
modified = copy(self.c.modified)
|
|
modified = copy(self.c.modified)
|
|
|
|
|
|