changeset 260:3d8df5b91504

Enhanced packages test to write to a page two times. imported from: moin--main--1.5--patch-263
author Alexander Schremmer <alex@alexanderweb.de.tla>
date Thu, 01 Dec 2005 22:22:29 +0000
parents 0c25ccdc8f37
children 5cece25f6406
files MoinMoin/_tests/test_packages.py
diffstat 1 files changed, 11 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/_tests/test_packages.py	Thu Dec 01 22:21:30 2005 +0000
+++ b/MoinMoin/_tests/test_packages.py	Thu Dec 01 22:22:29 2005 +0000
@@ -6,7 +6,7 @@
 @license: GNU GPL, see COPYING for details.
 """
 
-import unittest
+from unittest import TestCase
 from MoinMoin.Page import Page
 from MoinMoin._tests import TestConfig
 from MoinMoin._tests import TestSkiped as TestSkipped
@@ -14,14 +14,11 @@
 
 class DebugPackage(Package, ScriptEngine):
     """ Used for debugging, does not need a real .zip file. """
-    def __init__(self, request, filename):
+    def __init__(self, request, filename, script=None):
         Package.__init__(self, request)
         ScriptEngine.__init__(self)
         self.filename = filename
-
-    def extract_file(self, filename):
-        if filename == MOIN_PACKAGE_FILE:
-            return u"""moinmoinpackage|1
+        self.script = script or u"""moinmoinpackage|1
 print|foo
 ReplaceUnderlay|testdatei|TestSeite2
 DeletePage|TestSeite2|Test ...
@@ -29,11 +26,16 @@
 DeletePage|TestSeiteDoesNotExist|Test ...
 IgnoreExceptions|False
 AddRevision|foofile|FooPage
+AddRevision|foofile|FooPage
 DeletePage|FooPage|Test ...
 setthemename|foo
 #foobar
 installplugin|foo|local|parser|testy
-""".encode("utf-8")
+"""
+
+    def extract_file(self, filename):
+        if filename == MOIN_PACKAGE_FILE:
+            return self.script.encode("utf-8")
         else:
             return "Hello world, I am the file " + filename.encode("utf-8")
 
@@ -43,7 +45,7 @@
     def isPackage(self):
         return True
     
-class PackagesTests(unittest.TestCase):
+class UnsafePackageTestcase(TestCase):
     """ 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. """
 
@@ -60,7 +62,7 @@
         self.assert_(testseite2.isUnderlayPage())
         self.assert_(not Page(self.request, 'FooPage').exists())
 
-class QuotingTests(unittest.TestCase):
+class QuotingTestCase(TestCase):
     def testQuoting(self):
         for line in ([':foo', 'is\\', 'ja|', u't|', u'baAz'], [], ['', '']):
             self.assertEqual(line, unpackLine(packLine(line)))