changeset 2246:0893eaf60bbf

Added legacy warning to test_wikisync, fixed packages test by deleting the page, gaining enough permissions before trying so and checking for the output pagename in the messages (this was added by reimar in 10c60d1131dd.
author Alexander Schremmer <alex AT alexanderweb DOT de>
date Fri, 22 Jun 2007 13:06:50 +0200
parents 1b8b4e7bfba5
children 0131f0aabb18 e3de8187401f
files MoinMoin/_tests/test_packages.py MoinMoin/_tests/test_wikisync.py
diffstat 2 files changed, 27 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/_tests/test_packages.py	Fri Jun 22 00:46:29 2007 +0200
+++ b/MoinMoin/_tests/test_packages.py	Fri Jun 22 13:06:50 2007 +0200
@@ -6,7 +6,6 @@
     @license: GNU GPL, see COPYING for details.
 """
 
-from unittest import TestCase
 
 import py
 
@@ -15,6 +14,7 @@
 from MoinMoin.packages import Package, ScriptEngine, MOIN_PACKAGE_FILE, packLine, unpackLine
 
 
+
 class DebugPackage(Package, ScriptEngine):
     """ Used for debugging, does not need a real .zip file. """
     def __init__(self, request, filename, script=None):
@@ -26,6 +26,7 @@
 ReplaceUnderlay|testdatei|TestSeite2
 IgnoreExceptions|True
 DeletePage|TestSeiteDoesNotExist|Test ...
+DeletePage|FooPage|Test ...
 IgnoreExceptions|False
 AddRevision|foofile|FooPage
 AddRevision|foofile|FooPage
@@ -46,29 +47,40 @@
     def isPackage(self):
         return True
 
-class TestUnsafePackage(TestCase):
+
+class TestUnsafePackage:
     """ Tests various things in the packages package. Note that this package does
         not care to clean up and needs to run in a test wiki because of that. """
 
-    def setUp(self):
+    def setup_class(self):
         if not getattr(self.request.cfg, 'is_test_wiki', False):
             py.test.skip('This test needs to be run using the test wiki.')
 
-    def testBasicPackageThings(self):
-        myPackage = DebugPackage(self.request, 'test')
-        myPackage.installPackage()
-        self.assertEqual(myPackage.msg, "foo\n")
-        testseite2 = Page(self.request, 'TestSeite2')
-        self.assertEqual(testseite2.getPageText(), "Hello world, I am the file testdatei")
-        self.assert_(testseite2.isUnderlayPage())
 
-    def tearDown(self):
+    def teardown_class(self):
         DebugPackage(self.request, u"""moinmoinpackage|1
 DeletePage|FooPage|Test ...
 """).installPackage()
 
-class TestQuoting(TestCase):
+    def gain_superuser_rights(self):
+        self.request.user.name = "SuperUserName"
+        self.request.user.valid = 1
+        self.request.user.may.name = self.request.user.name
+        self.request.cfg.superuser.append(self.request.user.name)
+        self.request.user.auth_method = self.request.cfg.trusted_auth_methods[0]
+
+    def testBasicPackageThings(self):
+        self.gain_superuser_rights()
+        myPackage = DebugPackage(self.request, 'test')
+        myPackage.installPackage()
+        assert myPackage.msg == u'foo\nFooPage added \n'
+        testseite2 = Page(self.request, 'TestSeite2')
+        assert testseite2.getPageText() == "Hello world, I am the file testdatei"
+        assert testseite2.isUnderlayPage()
+
+
+class TestQuoting:
     def testQuoting(self):
         for line in ([':foo', 'is\\', 'ja|', u't|', u'baAz'], [], ['', '']):
-            self.assertEqual(line, unpackLine(packLine(line)))
+            assert line == unpackLine(packLine(line))
 
--- a/MoinMoin/_tests/test_wikisync.py	Fri Jun 22 00:46:29 2007 +0200
+++ b/MoinMoin/_tests/test_wikisync.py	Fri Jun 22 13:06:50 2007 +0200
@@ -6,7 +6,7 @@
     @license: GNU GPL, see COPYING for details.
 """
 
-from unittest import TestCase
+from unittest import TestCase # LEGACY UNITTEST, PLEASE DO NOT IMPORT unittest IN NEW TESTS, PLEASE CONSULT THE py.test DOCS
 
 import py
 
@@ -36,3 +36,4 @@
     def tearDown(self):
         tags = TagStore(self.page)
         tags.clear()
+