changeset 2240:608bf77ca90f

Added a unit test for trash view.
author Ashutosh Singla <ashu1461@gmail.com>
date Sun, 18 Aug 2013 01:07:00 +0530
parents d5ad38a42754
children b013a1c4bddd
files MoinMoin/items/_tests/test_Item.py
diffstat 1 files changed, 33 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/items/_tests/test_Item.py	Sun Aug 18 01:06:00 2013 +0530
+++ b/MoinMoin/items/_tests/test_Item.py	Sun Aug 18 01:07:00 2013 +0530
@@ -372,4 +372,37 @@
         assert item.meta['new_test_key'] == update_meta['new_test_key']
         assert 'none_test_key' not in item.meta
 
+    def test_trash(self):
+        fqname = u'trash_item_test'
+        contenttype = u'text/plain;charset=utf-8'
+        data = 'test_data'
+        meta = {CONTENTTYPE: contenttype}
+        item = Item.create(fqname)
+        # save rev 0
+        item._save(meta, data)
+        item = Item.create(fqname)
+        assert not item.meta.get(TRASH)
+
+        meta = dict(item.meta)
+        meta[NAME] = []
+        # save new rev with no names.
+        item._save(meta, data)
+        new_fqname = u'@itemid/' + item.meta[ITEMID]
+        item = Item.create(new_fqname)
+        assert item.meta[TRASH]
+
+        new_meta = {NAME: [u'foobar', 'buz'], CONTENTTYPE: contenttype}
+        item._save(new_meta, data)
+        item = Item.create(u'foobar')
+
+        item.delete(u'Deleting foobar.')
+        item = Item.create(u'buz')
+        assert not item.meta.get(TRASH)
+
+        # Also delete the only name left.
+        item.delete(u'Moving item to trash.')
+        item = Item.create(new_fqname)
+        assert item.meta[TRASH]
+
+
 coverage_modules = ['MoinMoin.items']