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

« back to all changes in this revision

Viewing changes to MoinMoin/wikixml/_tests/test_marshal.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.wikixml.marshal Tests
 
4
 
 
5
    @copyright: 2002-2004 by Juergen Hermann <jh@web.de>,
 
6
                2007 by MoinMoin:ThomasWaldmann
 
7
    @license: GNU GPL, see COPYING for details.
 
8
"""
 
9
 
 
10
import array
 
11
from MoinMoin.wikixml import marshal
 
12
 
 
13
class TestMarshal(object):
 
14
    """Testing Marshal used for ...XXX"""
 
15
 
 
16
    class Data:
 
17
        cvar = 'Class Variable'
 
18
        def __init__(self, value):
 
19
            self.ivar = value
 
20
 
 
21
    prop = (
 
22
        # value, xml representation in a marshal object
 
23
        (None, '<data><prop><none/></prop></data>'),
 
24
        ("string", '<data><prop>string</prop></data>'),
 
25
        ([1, "abc"], '<data><prop><item>1</item><item>abc</item></prop></data>'),
 
26
        ((1, "abc"), '<data><prop><item>1</item><item>abc</item></prop></data>'),
 
27
        ({"abc": 1}, '<data><prop><abc>1</abc></prop></data>'),
 
28
        (1, '<data><prop>1</prop></data>'),
 
29
        (Data('value'), '<data><prop><data><ivar>value</ivar></data></prop></data>'),
 
30
        (array.array("i", [42]), "<data><prop>array('i', [42])</prop></data>"),
 
31
        (buffer("0123456789", 2, 3), "<data><prop>234</prop></data>"),
 
32
        )
 
33
 
 
34
    def setup_method(self, method):
 
35
        self.obj = marshal.Marshal()
 
36
 
 
37
    def testCreateMarshal(self):
 
38
        """wikixml.marshal: create new marshal"""
 
39
        self._checkData(self.obj, '<data></data>')
 
40
 
 
41
    def testSetMarshalProperty(self):
 
42
        """wikixml.marshal: setting marshal property"""
 
43
        for value, xml in self.prop:
 
44
            self.obj.prop = value
 
45
            self._checkData(self.obj, xml)
 
46
 
 
47
    def _canonize(self, xml):
 
48
        xml = xml.replace('\n', '')
 
49
        return xml
 
50
 
 
51
    def _checkData(self, obj, xml):
 
52
        objXML = self._canonize(obj.toXML())
 
53
        expected = self._canonize(xml)
 
54
        assert objXML == expected
 
55
 
 
56
 
 
57
coverage_modules = ['MoinMoin.wikixml.marshal']
 
58