changeset 2834:7d4a6e369a5a

test_GetVal fixed, Creation Delete test for test_PageEditor
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Tue, 11 Sep 2007 23:18:45 +0200
parents ea9a38d2ec09
children 9c4c20145a1f
files MoinMoin/_tests/test_PageEditor.py MoinMoin/macro/_tests/test_GetVal.py
diffstat 2 files changed, 48 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/_tests/test_PageEditor.py	Tue Sep 11 21:30:35 2007 +0200
+++ b/MoinMoin/_tests/test_PageEditor.py	Tue Sep 11 23:18:45 2007 +0200
@@ -9,13 +9,13 @@
 
 import py
 
+from MoinMoin import wikiutil
 from MoinMoin.Page import Page
 from MoinMoin.PageEditor import PageEditor
 from MoinMoin._tests.common import gain_superuser_rights
 
 class TestExpandVars(object):
     """PageEditor: testing page editor"""
-
     pagename = u'AutoCreatedMoinMoinTemporaryTestPage'
 
     _tests = (
@@ -202,5 +202,22 @@
         assert page.body != testtext
 
 
+class TestPageDeletion:
+
+    def testCreateAndDeletePage(self):
+        """
+        simple test if it is possible to delete a page after creation
+        """
+        pagename = u'SomeDict'
+        page = PageEditor(self.request, pagename, do_editor_backup=0)
+        body = u"This is an example text"
+        page.saveText(body, 0)
+
+        success_i, result = page.deletePage()
+
+        expected = u'Page "SomeDict" was successfully deleted!'
+
+        assert result == expected
+
 coverage_modules = ['MoinMoin.PageEditor']
 
--- a/MoinMoin/macro/_tests/test_GetVal.py	Tue Sep 11 21:30:35 2007 +0200
+++ b/MoinMoin/macro/_tests/test_GetVal.py	Tue Sep 11 23:18:45 2007 +0200
@@ -7,41 +7,40 @@
     @license: GNU GPL, see COPYING for details.
 """
 import os, py
-from MoinMoin import macro
+from MoinMoin import macro, wikidicts, wikiutil
 from MoinMoin.logfile import eventlog
 from MoinMoin.Page import Page
 from MoinMoin.PageEditor import PageEditor
 from MoinMoin.parser.text_moin_wiki import Parser
+from MoinMoin._tests.common import gain_superuser_rights
 
 class TestGetVal:
     """GetVal: testing getVal macro """
 
-    def setup_class(self):
+        # injected for you into the test class by moin test framework.
+    def setup_method(self, method):
+        gain_superuser_rights(self.request)
         self.cfg = self.request.cfg
         self.pagename = u'MyDict'
-        self.page = PageEditor(self.request, self.pagename)
-        self.shouldDeleteTestPage = False
+        self.page = PageEditor(self.request, self.pagename, do_editor_backup=0)
+        self.shouldDeleteTestPage = True
+
         # for that test eventlog needs to be empty
         fpath = self.request.rootpage.getPagePath('event-log', isfile=1)
         if os.path.exists(fpath):
             os.remove(fpath)
-        # remove old pages
-        import shutil
-        page = Page(self.request, self.pagename)
-        fpath = page.getPagePath(use_underlay=0, check_create=0)
-        shutil.rmtree(fpath, True)
 
-    def teardown_class(self):
+
+    def teardown_method(self, method):
         if self.shouldDeleteTestPage:
-            import shutil
-            page = Page(self.request, self.pagename)
-            fpath = page.getPagePath(use_underlay=0, check_create=0)
-            shutil.rmtree(fpath, True)
+            page = PageEditor(self.request, self.pagename, do_editor_backup=0)
+            success_i, msg = page.deletePage()
 
             fpath = self.request.rootpage.getPagePath('event-log', isfile=1)
             if os.path.exists(fpath):
                 os.remove(fpath)
 
+
     def _make_macro(self):
         """Test helper"""
         from MoinMoin.parser.text import Parser
@@ -61,16 +60,32 @@
     def _createTestPage(self, body):
         """ Create temporary page """
         assert body is not None
+
         self.request.reset()
         self.page.saveText(body, 0)
 
     def testGetValNoACLs(self):
         """ macro GetVal test: 'reads VAR' """
-        py.test.skip("test broken")
+        # py.test.skip("broken test")
+        # seems not to go well after test_PageEditor and test_events
+        # are both excluded it works e.g.
+        '''
+         py.test MoinMoin/_tests/test_Page.py MoinMoin/_tests/test_error.py
+         MoinMoin/_tests/test_packages.py MoinMoin/_tests/test_user.py
+         MoinMoin/_tests/test_wikidicts.py MoinMoin/_tests/test_wikisync.py
+         MoinMoin/_tests/test_wikiutil.py MoinMoin/action/_tests/test_attachfile.py
+         MoinMoin/config/_tests/test_multiconfig.py
+         MoinMoin/converter/_tests/test_text_html_text_moin_wiki.py
+         MoinMoin/filter/_tests/test_filter.py MoinMoin/macro/_tests/test_Action.py
+         MoinMoin/formatter/_tests/test_formatter.py MoinMoin/macro/_tests/test_GetVal.py
+        '''
         self.shouldDeleteTestPage = True
         self._createTestPage(u' VAR:: This is an example')
+
+        page = Page(self.request, self.pagename)
         args = "%s,%s" % (self.pagename, u'VAR')
         result = self._test_macro(u'GetVal', args)
+
         expected = "This is an example"
         assert result == expected