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

« back to all changes in this revision

Viewing changes to MoinMoin/_tests/test_widget_html.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 - MoinMoin.widget.html Tests
4
 
 
5
 
    @copyright: 2003-2004 by J�rgen Hermann <jh@web.de>
6
 
    @license: GNU GPL, see COPYING for details.
7
 
"""
8
 
 
9
 
import unittest
10
 
from MoinMoin.widget import html
11
 
from MoinMoin import wikiutil
12
 
 
13
 
class HTMLWidgetsTestCase(unittest.TestCase):
14
 
    """widget.html: testing html widgets"""
15
 
 
16
 
    def testCreate(self):
17
 
        """widget.html: creating html widgets
18
 
 
19
 
        TO DO: add tests for all elements by HTML 4 spec.
20
 
        """
21
 
        tests = (
22
 
            # description, call, expected           
23
 
            ('Create text', html.Text('<br> &'), '&lt;br&gt; &amp;'),
24
 
            ('Create raw html', html.Raw('<br> &amp;'), '<br> &amp;'),
25
 
            ('Create br', html.BR(), '<br>'),
26
 
            ('Create hr', html.HR(), '<hr>'),
27
 
            ('Create p', html.P(), '<p></p>'),
28
 
            )
29
 
 
30
 
        for description, obj, expected in tests:
31
 
            result = unicode(obj)
32
 
            self.assertEqual(result, expected,
33
 
                             ('%(description)s: expected "%(expected)s" '
34
 
                              'but got "%(result)s"') % locals())
35
 
 
36
 
    def testInvalidAttributes(self):
37
 
        """widegt.html: invalid attributes raises exception
38
 
 
39
 
        TO DO: add tests for all elements by HTML 4 spec.
40
 
        """
41
 
        self.assertRaises(AttributeError, html.BR, name='foo')
42
 
 
43
 
 
44
 
    def testCompositeElements(self):
45
 
        """widget.html: append to and extend composite element"""
46
 
        html._SORT_ATTRS = 1
47
 
        element = html.P()
48
 
 
49
 
        actions = (
50
 
            # action, data, expected
51
 
            (element.append, 
52
 
             html.Text('Text & '),
53
 
             '<p>Text &amp; </p>'),
54
 
            (element.append, 
55
 
             html.Text('more text. '),
56
 
             '<p>Text &amp; more text. </p>'),
57
 
            (element.extend, 
58
 
             (html.Text('And then '), html.Text('some.')),
59
 
             '<p>Text &amp; more text. And then some.</p>'),
60
 
            )
61
 
 
62
 
        for action, data, expected in actions:
63
 
            action(data)
64
 
            result = unicode(element)
65
 
            self.assertEqual(result, expected,
66
 
                             'Expected "%(expected)s" but got "%(result)s"' % locals())
67
 
            
68