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

« back to all changes in this revision

Viewing changes to MoinMoin/widget/_tests/test_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 Juergen Hermann <jh@web.de>
 
6
    @license: GNU GPL, see COPYING for details.
 
7
"""
 
8
 
 
9
import py
 
10
 
 
11
from MoinMoin.widget import html
 
12
 
 
13
class TestHTMLWidgets:
 
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
            assert result == expected
 
33
 
 
34
    def testInvalidAttributes(self):
 
35
        """widget.html: invalid attributes raises exception
 
36
 
 
37
        TO DO: add tests for all elements by HTML 4 spec.
 
38
        """
 
39
        py.test.raises(AttributeError, html.BR, name='foo')
 
40
 
 
41
 
 
42
    def testCompositeElements(self):
 
43
        """widget.html: append to and extend composite element"""
 
44
        html._SORT_ATTRS = 1
 
45
        element = html.P()
 
46
 
 
47
        actions = (
 
48
            # action, data, expected
 
49
            (element.append,
 
50
             html.Text('Text & '),
 
51
             '<p>Text &amp; </p>'),
 
52
            (element.append,
 
53
             html.Text('more text. '),
 
54
             '<p>Text &amp; more text. </p>'),
 
55
            (element.extend,
 
56
             (html.Text('And then '), html.Text('some.')),
 
57
             '<p>Text &amp; more text. And then some.</p>'),
 
58
            )
 
59
 
 
60
        for action, data, expected in actions:
 
61
            action(data)
 
62
            result = unicode(element)
 
63
            assert result == expected
 
64
 
 
65
coverage_modules = ['MoinMoin.widget.html']
 
66