--- a/server/test/unittest_storage.py Wed Oct 06 11:57:21 2010 +0200
+++ b/server/test/unittest_storage.py Wed Oct 06 14:04:26 2010 +0200
@@ -19,7 +19,7 @@
from __future__ import with_statement
-from logilab.common.testlib import unittest_main, tag
+from logilab.common.testlib import unittest_main, tag, Tags
from cubicweb.devtools.testlib import CubicWebTC
import os.path as osp
@@ -52,6 +52,8 @@
class StorageTC(CubicWebTC):
+ tags = CubicWebTC.tags | Tags('Storage', 'BFSS')
+
def setup_database(self):
self.tempdir = tempfile.mkdtemp()
bfs_storage = storages.BytesFileSystemStorage(self.tempdir)
@@ -184,7 +186,7 @@
self.assertEqual(f1.data.getvalue(), file(filepath).read(),
'files content differ')
- @tag('Storage', 'BFSS', 'update')
+ @tag('update')
def test_bfss_update_with_existing_data(self):
# use self.session to use server-side cache
f1 = self.session.create_entity('File', data=Binary('some data'),
@@ -198,7 +200,7 @@
f2 = self.execute('Any F WHERE F eid %(f)s, F is File', {'f': f1.eid}).get_entity(0, 0)
self.assertEqual(f2.data.getvalue(), 'some other data')
- @tag('Storage', 'BFSS', 'update', 'extension', 'commit')
+ @tag('update', 'extension', 'commit')
def test_bfss_update_with_different_extension_commited(self):
# use self.session to use server-side cache
f1 = self.session.create_entity('File', data=Binary('some data'),
@@ -220,7 +222,7 @@
self.failUnless(osp.isfile(new_path))
self.assertEqual(osp.splitext(new_path)[1], '.jpg')
- @tag('Storage', 'BFSS', 'update', 'extension', 'rollback')
+ @tag('update', 'extension', 'rollback')
def test_bfss_update_with_different_extension_rollbacked(self):
# use self.session to use server-side cache
f1 = self.session.create_entity('File', data=Binary('some data'),
@@ -245,6 +247,7 @@
self.assertEqual(old_path, new_path)
self.assertEqual(old_data, new_data)
+ @tag('fs_importing', 'update')
def test_bfss_update_with_fs_importing(self):
# use self.session to use server-side cache
f1 = self.session.create_entity('File', data=Binary('some data'),
@@ -260,6 +263,35 @@
self.assertEqual(self.fspath(f1), new_fspath)
self.failIf(osp.isfile(old_fspath))
+ @tag('fsimport')
+ def test_clean(self):
+ fsimport = storages.fsimport
+ td = self.session.transaction_data
+ self.assertNotIn('fs_importing', td)
+ with fsimport(self.session):
+ self.assertIn('fs_importing', td)
+ self.assertTrue(td['fs_importing'])
+ self.assertNotIn('fs_importing', td)
+
+ @tag('fsimport')
+ def test_true(self):
+ fsimport = storages.fsimport
+ td = self.session.transaction_data
+ td['fs_importing'] = True
+ with fsimport(self.session):
+ self.assertIn('fs_importing', td)
+ self.assertTrue(td['fs_importing'])
+ self.assertTrue(td['fs_importing'])
+
+ @tag('fsimport')
+ def test_False(self):
+ fsimport = storages.fsimport
+ td = self.session.transaction_data
+ td['fs_importing'] = False
+ with fsimport(self.session):
+ self.assertIn('fs_importing', td)
+ self.assertTrue(td['fs_importing'])
+ self.assertFalse(td['fs_importing'])
if __name__ == '__main__':
unittest_main()