changeset 902:7b8c2d36a291 storage-ng

fix item delete and rename tests to fail in the same way
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Thu, 29 Sep 2011 18:38:05 +0200
parents 5377e1c6a10f
children 50aa61c9b952
files MoinMoin/items/__init__.py MoinMoin/items/_tests/test_Item.py
diffstat 2 files changed, 17 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/items/__init__.py	Wed Sep 28 23:37:29 2011 +0200
+++ b/MoinMoin/items/__init__.py	Thu Sep 29 18:38:05 2011 +0200
@@ -399,7 +399,7 @@
         """
         delete this item by moving it to the trashbin
         """
-        trash_prefix = u'Trash/' # XXX move to config
+        trash_prefix = u'XXTrash/' # XXX move to config
         now = time.strftime('%Y-%m-%d %H:%M:%S', time.gmtime())
         # make trash name unique by including timestamp:
         trashname = u'%s%s (%s UTC)' % (trash_prefix, self.name, now)
--- a/MoinMoin/items/_tests/test_Item.py	Wed Sep 28 23:37:29 2011 +0200
+++ b/MoinMoin/items/_tests/test_Item.py	Thu Sep 29 18:38:05 2011 +0200
@@ -147,35 +147,43 @@
         data = 'test_data'
         meta = {'test_key': 'test_value', CONTENTTYPE: contenttype}
         comment = u'saved it'
-        become_trusted()
         item = Item.create(name)
         item._save(meta, data, comment=comment)
+        # item and its contents before renaming
         item = Item.create(name)
-        # item and its contents before renaming
         assert item.name == u'Test_Item'
         assert item.meta['comment'] == u'saved it'
-        Item.rename(item, u'Test_new_Item', comment=u'renamed')
         new_name = u'Test_new_Item'
+        item.rename(new_name, comment=u'renamed')
+        # item at original name and its contents after renaming
+        item = Item.create(name)
+        assert item.name == u'Test_Item'
+        # this should be a fresh, new item, NOT the stuff we renamed:
+        assert item.meta[CONTENTTYPE] == 'application/x-nonexistent'
+        # item at new name and its contents after renaming
         item = Item.create(new_name)
-        # item and its contents after renaming
         assert item.name == u'Test_new_Item'
+        assert item.meta['name_old'] == u'Test_Item'
         assert item.meta['comment'] == u'renamed'
-        assert item.meta['name_old'] == u'Test_Item'
         assert item.data == u'test_data'
 
     def test_delete(self):
-        name = u'Test_Item'
+        name = u'Test_Item2'
         contenttype = u'text/plain;charset=utf-8'
         data = 'test_data'
         meta = {'test_key': 'test_value', CONTENTTYPE: contenttype}
         comment = u'saved it'
         item = Item.create(name)
         item._save(meta, data, comment=comment)
+        # item and its contents before deleting
         item = Item.create(name)
-        item.delete(u'item deleted')
+        assert item.name == u'Test_Item2'
+        assert item.meta['comment'] == u'saved it'
+        item.delete(u'deleted')
         # item and its contents after deletion
         item = Item.create(name)
-        assert item.name == u'Test_Item'
+        assert item.name == u'Test_Item2'
+        # this should be a fresh, new item, NOT the stuff we deleted:
         assert item.meta[CONTENTTYPE] == 'application/x-nonexistent'
 
     def test_revert(self):