Attachment 'packagetest.patch'

Download

   1 --- moin-1.6.orig/MoinMoin/_tests/test_packages.py	2007-12-01 02:09:09.000000000 +0200
   2 +++ /usr/local/lib/python2.5/site-packages/MoinMoin/_tests/test_packages.py	2007-12-09 14:25:03.000000000 +0200
   3 @@ -2,21 +2,26 @@
   4  """
   5      MoinMoin - MoinMoin.packages tests
   6  
   7 -    @copyright: 2005 MoinMoin:AlexanderSchremmer
   8 +    @copyright: 2005 MoinMoin:AlexanderSchremmer,
   9 +                2007 Federico Lorenzi
  10      @license: GNU GPL, see COPYING for details.
  11  """
  12  
  13 -
  14 +import tempfile
  15  import py
  16 +import zipfile
  17  
  18 +from MoinMoin import wikiutil
  19  from MoinMoin.Page import Page
  20  from MoinMoin.PageEditor import PageEditor
  21 +from MoinMoin.action.PackagePages import PackagePages
  22  from MoinMoin.packages import Package, ScriptEngine, MOIN_PACKAGE_FILE, packLine, unpackLine
  23  from MoinMoin._tests.common import gain_superuser_rights
  24  
  25  
  26  class DebugPackage(Package, ScriptEngine):
  27      """ Used for debugging, does not need a real .zip file. """
  28 +
  29      def __init__(self, request, filename, script=None):
  30          Package.__init__(self, request)
  31          ScriptEngine.__init__(self)
  32 @@ -52,20 +57,17 @@
  33      """ Tests various things in the packages package. Note that this package does
  34          not care to clean up and needs to run in a test wiki because of that. """
  35  
  36 -
  37      def setup_class(self):
  38          py.test.skip("Test broken")
  39          if not getattr(self.request.cfg, 'is_test_wiki', False):
  40              py.test.skip('This test needs to be run using the test wiki.')
  41  
  42 -
  43      def teardown_class(self):
  44          py.test.skip("Test broken")
  45          DebugPackage(self.request, u"""moinmoinpackage|1
  46  DeletePage|FooPage|Test ...
  47  """).installPackage()
  48  
  49 -
  50      def testBasicPackageThings(self):
  51          py.test.skip("Test broken")
  52          gain_superuser_rights(self.request)
  53 @@ -78,9 +80,40 @@
  54  
  55  
  56  class TestQuoting:
  57 +
  58      def testQuoting(self):
  59 -        for line in ([':foo', 'is\\', 'ja|', u't|ü', u'baAzß'], [], ['', '']):
  60 +        for line in ([':foo', 'is\\', 'ja|', u't|�', u'baAz�'], [], ['', '']):
  61              assert line == unpackLine(packLine(line))
  62  
  63 -coverage_modules = ['MoinMoin.packages']
  64  
  65 +class TestRealCreation:
  66 +
  67 +    def testSearchCreate(self):
  68 +        package = PackagePages(self.request.rootpage.page_name, self.request)
  69 +        temp = tempfile.NamedTemporaryFile(suffix='.zip')
  70 +        package.collectpackage(package.searchpackage(self.request, "Category"), temp)
  71 +        assert zipfile.is_zipfile(temp.name)
  72 +
  73 +    def testListCreate(self):
  74 +        package = PackagePages(self.request.rootpage.page_name, self.request)
  75 +        temp = tempfile.NamedTemporaryFile(suffix='.zip')
  76 +        package.collectpackage(['FrontPage'], temp)
  77 +        assert zipfile.is_zipfile(temp.name)
  78 +
  79 +    def testAllCreate(self):
  80 +        package = PackagePages(self.request.rootpage.page_name, self.request)
  81 +        temp = tempfile.NamedTemporaryFile(suffix='.zip')
  82 +        package.collectpackage(self.request.rootpage.getPageList(
  83 +                                include_underlay=False, 
  84 +                                filter=lambda name: not wikiutil.isSystemPage(self.request, name)), 
  85 +                                temp)
  86 +        if package:
  87 +            py.test.skip("No user created pages in wiki!")
  88 +        assert zipfile.is_zipfile(temp.name)
  89 +
  90 +    def testInvalidCreate(self):
  91 +        package = PackagePages(self.request.rootpage.page_name, self.request)
  92 +        temp = tempfile.NamedTemporaryFile(suffix='.zip')
  93 +        package.collectpackage(['___//THIS PAGE SHOULD NOT EXIST\\___'], temp)
  94 +        assert not zipfile.is_zipfile(temp.name)
  95 +coverage_modules = ['MoinMoin.packages']
  96 

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2007-12-04 21:39:37, 4.2 KB) [[attachment:cache.test1.6.patch]]
  • [get | view] (2007-12-04 21:38:47, 2.7 KB) [[attachment:cache1.6.patch]]
  • [get | view] (2007-12-04 21:38:57, 2.7 KB) [[attachment:cache1.7.patch]]
  • [get | view] (2007-12-30 21:22:29, 23.1 KB) [[attachment:documentation.patch]]
  • [get | view] (2007-12-11 21:27:01, 10.5 KB) [[attachment:package.patch]]
  • [get | view] (2007-12-11 21:26:48, 3.5 KB) [[attachment:packagetest.patch]]
  • [get | view] (2007-12-04 21:39:22, 3.1 KB) [[attachment:quicklink.patch]]
  • [get | view] (2008-01-29 16:42:22, 171.8 KB) [[attachment:screenschot.png]]
  • [get | view] (2007-12-04 21:42:03, 3.8 KB) [[attachment:subscribe.patch]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.