Commits

Anonymous committed afe0afe

recursive rename

Comments (0)

Files changed (3)

MoinMoin/converter/_tests/test_include.py

 
         page1._render_data()
 
-    def test_IncludeOfSingleLinePage(self):
+    def test_InlineInclude(self):
         # issue #28
         update_item(u'page1', {CONTENTTYPE: u'text/x.moin.wiki'}, u'Content of page2 is "{{page2}}"')
 

MoinMoin/items/__init__.py

                               {moin_page.namespace: '',
                                xlink.namespace: 'xlink',
                                html.namespace: 'html',
-                              })
+                               })
 
     def _render_data_highlight(self):
         # override this in child classes
                                last_rev_id=rev_ids and rev_ids[-1],
                                meta_rendered='',
                                data_rendered='',
-                              )
+                               )
 
     def meta_filter(self, meta):
         """ kill metadata entries that we set automatically when saving """
         kill_keys = [# shall not get copied from old rev to new rev
-                     SYSITEM_VERSION,
-                     NAME_OLD,
-                     # are automatically implanted when saving
-                     NAME,
-                     ITEMID, REVID, DATAID,
-                     HASH_ALGORITHM,
-                     SIZE,
-                     COMMENT,
-                     MTIME,
-                     ACTION,
-                     ADDRESS, HOSTNAME, USERID,
-                    ]
+            SYSITEM_VERSION,
+            NAME_OLD,
+            # are automatically implanted when saving
+            NAME,
+            ITEMID, REVID, DATAID,
+            HASH_ALGORITHM,
+            SIZE,
+            COMMENT,
+            MTIME,
+            ACTION,
+            ADDRESS, HOSTNAME, USERID,
+            ]
         for key in kill_keys:
             meta.pop(key, None)
         return meta
 
     def _rename(self, name, comment, action):
         self._save(self.meta, self.data, name=name, action=action, comment=comment)
+        for child in self.get_index():
+            item = Item.create(child[0])
+            item._save(item.meta, item.data, name='/'.join((name, child[1])), action=action, comment=comment)
 
     def rename(self, name, comment=u''):
         """

MoinMoin/items/_tests/test_Item.py

 
 from flask import g as flaskg
 
-from MoinMoin._tests import become_trusted
+from MoinMoin._tests import become_trusted, update_item
 from MoinMoin.items import Item, ApplicationXTar, NonExistent, Binary, Text, Image, TransformableBitmapImage, MarkupItem
 from MoinMoin.config import CONTENTTYPE, ADDRESS, COMMENT, HOSTNAME, USERID, ACTION
 
         assert item.meta['comment'] == u'renamed'
         assert item.data == u'test_data'
 
+    def test_rename_recursion(self):
+        update_item(u'Page', {CONTENTTYPE: u'text/x.moin.wiki'}, u'Page 1')
+        update_item(u'Page/Child', {CONTENTTYPE: u'text/x.moin.wiki'}, u'this is child')
+        update_item(u'Page/Child/Another', {CONTENTTYPE: u'text/x.moin.wiki'}, u'another child')
+
+        item = Item.create(u'Page')
+        item.rename(u'Renamed_Page', comment=u'renamed')
+
+        # items at original name and its contents after renaming
+        item = Item.create(u'Page')
+        assert item.name == u'Page'
+        assert item.meta[CONTENTTYPE] == 'application/x-nonexistent'
+        item = Item.create(u'Page/Child')
+        assert item.name == u'Page/Child'
+        assert item.meta[CONTENTTYPE] == 'application/x-nonexistent'
+        item = Item.create(u'Page/Child/Another')
+        assert item.name == u'Page/Child/Another'
+        assert item.meta[CONTENTTYPE] == 'application/x-nonexistent'
+
+        # item at new name and its contents after renaming
+        item = Item.create(u'Renamed_Page')
+        assert item.name == u'Renamed_Page'
+        assert item.meta['name_old'] == u'Page'
+        assert item.meta['comment'] == u'renamed'
+        assert item.data == u'Page 1'
+
+        item = Item.create(u'Renamed_Page/Child')
+        assert item.name == u'Renamed_Page/Child'
+        assert item.meta['name_old'] == u'Page/Child'
+        assert item.meta['comment'] == u'renamed'
+        assert item.data == u'this is child'
+
+        item = Item.create(u'Renamed_Page/Child/Another')
+        assert item.name == u'Renamed_Page/Child/Another'
+        assert item.meta['name_old'] == u'Page/Child/Another'
+        assert item.meta['comment'] == u'renamed'
+        assert item.data == u'another child'
+
     def test_delete(self):
         name = u'Test_Item2'
         contenttype = u'text/plain;charset=utf-8'