annotate MoinMoin/converter/_tests/test_include.py @ 1014:d966ee4fba91

test for issue #80 (circular transclusion)
author "Luis Henrique Fagundes <lhfagundes@gmail.com>"
date Fri, 28 Oct 2011 19:51:22 -0200
parents beabd93b3904
children dfbe65482a03
rev   line source
26
4cd8edde9e94 automatically transform module docstrings, moving legal stuff to comments
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 24
diff changeset
1 # Copyright: 2008 MoinMoin:BastianBlank
4cd8edde9e94 automatically transform module docstrings, moving legal stuff to comments
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 24
diff changeset
2 # License: GNU GPL v2 (or any later version), see LICENSE.txt for details.
4cd8edde9e94 automatically transform module docstrings, moving legal stuff to comments
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 24
diff changeset
3
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
4 """
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
5 MoinMoin - Tests for MoinMoin.converter.include
26
4cd8edde9e94 automatically transform module docstrings, moving legal stuff to comments
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 24
diff changeset
6 """
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
7
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
8
562
17931e46e2df py.test changed to pytest in conftest.py and all the tests of converter module.
pkumar <contactprashantat@gmail.com>
parents: 26
diff changeset
9 import pytest
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
10
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
11 from MoinMoin.converter.include import *
1014
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
12 from MoinMoin.items import MoinWiki
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
13 from MoinMoin.config import CONTENTTYPE
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
14 from MoinMoin._tests import wikiconfig, update_item
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
15
1014
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
16 class TestInclude(object):
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
17 class Config(wikiconfig.Config):
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
18 """
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
19 we just have this so the test framework creates a new app with empty backends for us.
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
20 """
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
21
1014
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
22 def test_XPointer(self):
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
23 x = XPointer('a')
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
24 assert len(x) == 1
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
25 e = x[0]
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
26 assert e.name == 'a'
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
27 assert e.data is None
644
beabd93b3904 removed extra whitespaces form codes, added my name to the tests I wrote
pkumar <contactprashantat@gmail.com>
parents: 624
diff changeset
28
1014
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
29 x = XPointer('a(b)')
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
30 assert len(x) == 1
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
31 e = x[0]
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
32 assert e.name == 'a'
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
33 assert e.data == 'b'
0
5568cf133caf create moin/2.0 repo, drop all history (see notes below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
34
1014
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
35 x = XPointer('a(^(b^)^^)')
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
36 assert len(x) == 1
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
37 e = x[0]
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
38 assert e.name == 'a'
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
39 assert e.data == '^(b^)^^'
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
40 assert e.data_unescape == '(b)^'
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
41
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
42 x = XPointer('a(b)c(d)')
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
43 assert len(x) == 2
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
44 e = x[0]
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
45 assert e.name == 'a'
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
46 assert e.data == 'b'
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
47 e = x[1]
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
48 assert e.name == 'c'
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
49 assert e.data == 'd'
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
50
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
51 x = XPointer('a(b) c(d)')
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
52 assert len(x) == 2
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
53 e = x[0]
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
54 assert e.name == 'a'
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
55 assert e.data == 'b'
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
56 e = x[1]
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
57 assert e.name == 'c'
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
58 assert e.data == 'd'
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
59
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
60 x = XPointer('a(a(b))')
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
61 assert len(x) == 1
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
62 e = x[0]
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
63 assert e.name == 'a'
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
64 assert e.data == 'a(b)'
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
65
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
66 def test_IncludeHandlesCircularRecursion(self):
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
67 # issue #80
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
68 # we choosed MoinWiki items so tests get simpler
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
69 update_item(u'page1', {CONTENTTYPE: u'text/x.moin.wiki'}, u'{{page2}}')
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
70 update_item(u'page2', {CONTENTTYPE: u'text/x.moin.wiki'}, u'{{page3}}')
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
71 update_item(u'page3', {CONTENTTYPE: u'text/x.moin.wiki'}, u'{{page1}}')
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
72
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
73 page1 = MoinWiki.create(u'page1')
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
74
d966ee4fba91 test for issue #80 (circular transclusion)
"Luis Henrique Fagundes <lhfagundes@gmail.com>"
parents: 644
diff changeset
75 page1._render_data()