~ubuntu-branches/ubuntu/natty/moin/natty-updates

« back to all changes in this revision

Viewing changes to MoinMoin/filter/_tests/test_filter.py

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Smedegaard
  • Date: 2008-06-22 21:17:13 UTC
  • mfrom: (0.9.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080622211713-fpo2zrq3s5dfecxg
Tags: 1.7.0-3
Simplify /etc/moin/wikilist format: "USER URL" (drop unneeded middle
CONFIG_DIR that was wrongly advertised as DATA_DIR).  Make
moin-mass-migrate handle both formats and warn about deprecation of
the old one.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: iso-8859-1 -*-
 
2
"""
 
3
    MoinMoin - tests for MoinMoin.filter module
 
4
 
 
5
    @copyright: 2007 by MoinMoin:ThomasWaldmann
 
6
    @license: GNU GPL, see COPYING for details.
 
7
"""
 
8
 
 
9
import py
 
10
from MoinMoin import filter
 
11
 
 
12
class TestFilters:
 
13
 
 
14
    def make_file(self, data):
 
15
        import tempfile
 
16
        fname = tempfile.mktemp()
 
17
        f = file(fname, 'wb')
 
18
        f.write(data)
 
19
        f.close()
 
20
        return fname
 
21
 
 
22
    def testBinaryGeneric(self):
 
23
        from MoinMoin.filter.application_octet_stream import execute as _filter
 
24
        tests = [('', ''),
 
25
                 ('this\x00is\x00a\x00test\x00', u'this test'), # throws away short stuff
 
26
                ]
 
27
        for data, expected in tests:
 
28
            fname = self.make_file(data)
 
29
            assert _filter(None, fname) == expected
 
30
 
 
31
    def testTextGeneric(self):
 
32
        from MoinMoin.filter.text import execute as _filter
 
33
        tests = [('', ''),
 
34
                 ('asdf\r\nghjk', u'asdf\r\nghjk'),
 
35
                 # add some tests with umlauts in diff. encodings
 
36
                ]
 
37
        for data, expected in tests:
 
38
            fname = self.make_file(data)
 
39
            assert _filter(None, fname) == expected
 
40
 
 
41
    def testTextHtml(self):
 
42
        from MoinMoin.filter.text_html import execute as _filter
 
43
        tests = [('', ''),
 
44
                 ('<html><body>Hello<br>World!</body></html>', u'Hello World!'),
 
45
                ]
 
46
        for data, expected in tests:
 
47
            fname = self.make_file(data)
 
48
            assert _filter(None, fname) == expected
 
49
 
 
50
    def testTextXml(self):
 
51
        from MoinMoin.filter.text_xml import execute as _filter
 
52
        tests = [('', ''),
 
53
                 ('<xml><para>Hello</para><para>World!</para></xml>', u'Hello World!'),
 
54
                ]
 
55
        for data, expected in tests:
 
56
            fname = self.make_file(data)
 
57
            assert _filter(None, fname) == expected
 
58
 
 
59
coverage_modules = ['MoinMoin.filter.text',
 
60
                    'MoinMoin.filter.text_html',
 
61
                    'MoinMoin.filter.text_xml',
 
62
                    'MoinMoin.filter.application_octet_stream',
 
63
                   ]
 
64