annotate MoinMoin/macro/_tests/test_GetVal.py @ 2836:f5049c4cbf6e

wikidicts.dict: loads current dict. fixed and new tests
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Fri, 14 Sep 2007 12:53:23 +0200
parents 7d4a6e369a5a
children 5a3037bd131a
rev   line source
2786
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
2 """
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
3 MoinMoin - MoinMoin.macro GetVal tested
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
4
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
5 @copyright: 2007 MoinMoin:ReimarBauer
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
6
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
7 @license: GNU GPL, see COPYING for details.
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
8 """
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
9 import os, py
2834
7d4a6e369a5a test_GetVal fixed, Creation Delete test for test_PageEditor
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2816
diff changeset
10 from MoinMoin import macro, wikidicts, wikiutil
2786
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
11 from MoinMoin.logfile import eventlog
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
12 from MoinMoin.Page import Page
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
13 from MoinMoin.PageEditor import PageEditor
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
14 from MoinMoin.parser.text_moin_wiki import Parser
2834
7d4a6e369a5a test_GetVal fixed, Creation Delete test for test_PageEditor
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2816
diff changeset
15 from MoinMoin._tests.common import gain_superuser_rights
2786
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
16
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
17 class TestGetVal:
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
18 """GetVal: testing getVal macro """
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
19
2834
7d4a6e369a5a test_GetVal fixed, Creation Delete test for test_PageEditor
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2816
diff changeset
20 # injected for you into the test class by moin test framework.
7d4a6e369a5a test_GetVal fixed, Creation Delete test for test_PageEditor
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2816
diff changeset
21 def setup_method(self, method):
7d4a6e369a5a test_GetVal fixed, Creation Delete test for test_PageEditor
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2816
diff changeset
22 gain_superuser_rights(self.request)
2786
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
23 self.cfg = self.request.cfg
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
24 self.pagename = u'MyDict'
2834
7d4a6e369a5a test_GetVal fixed, Creation Delete test for test_PageEditor
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2816
diff changeset
25 self.page = PageEditor(self.request, self.pagename, do_editor_backup=0)
7d4a6e369a5a test_GetVal fixed, Creation Delete test for test_PageEditor
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2816
diff changeset
26 self.shouldDeleteTestPage = True
7d4a6e369a5a test_GetVal fixed, Creation Delete test for test_PageEditor
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2816
diff changeset
27
2786
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
28 # for that test eventlog needs to be empty
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
29 fpath = self.request.rootpage.getPagePath('event-log', isfile=1)
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
30 if os.path.exists(fpath):
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
31 os.remove(fpath)
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
32
2834
7d4a6e369a5a test_GetVal fixed, Creation Delete test for test_PageEditor
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2816
diff changeset
33
7d4a6e369a5a test_GetVal fixed, Creation Delete test for test_PageEditor
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2816
diff changeset
34 def teardown_method(self, method):
2786
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
35 if self.shouldDeleteTestPage:
2834
7d4a6e369a5a test_GetVal fixed, Creation Delete test for test_PageEditor
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2816
diff changeset
36 page = PageEditor(self.request, self.pagename, do_editor_backup=0)
7d4a6e369a5a test_GetVal fixed, Creation Delete test for test_PageEditor
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2816
diff changeset
37 success_i, msg = page.deletePage()
2786
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
38
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
39 fpath = self.request.rootpage.getPagePath('event-log', isfile=1)
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
40 if os.path.exists(fpath):
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
41 os.remove(fpath)
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
42
2834
7d4a6e369a5a test_GetVal fixed, Creation Delete test for test_PageEditor
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2816
diff changeset
43
2786
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
44 def _make_macro(self):
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
45 """Test helper"""
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
46 from MoinMoin.parser.text import Parser
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
47 from MoinMoin.formatter.text_html import Formatter
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
48 p = Parser("##\n", self.request)
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
49 p.formatter = Formatter(self.request)
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
50 p.formatter.page = self.page
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
51 self.request.formatter = p.formatter
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
52 p.form = self.request.form
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
53 m = macro.Macro(p)
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
54 return m
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
55
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
56 def _test_macro(self, name, args):
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
57 m = self._make_macro()
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
58 return m.execute(name, args)
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
59
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
60 def _createTestPage(self, body):
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
61 """ Create temporary page """
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
62 assert body is not None
2834
7d4a6e369a5a test_GetVal fixed, Creation Delete test for test_PageEditor
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2816
diff changeset
63
2786
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
64 self.request.reset()
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
65 self.page.saveText(body, 0)
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
66
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
67 def testGetValNoACLs(self):
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
68 """ macro GetVal test: 'reads VAR' """
2836
f5049c4cbf6e wikidicts.dict: loads current dict. fixed and new tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2834
diff changeset
69
2786
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
70 self.shouldDeleteTestPage = True
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
71 self._createTestPage(u' VAR:: This is an example')
2834
7d4a6e369a5a test_GetVal fixed, Creation Delete test for test_PageEditor
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2816
diff changeset
72
7d4a6e369a5a test_GetVal fixed, Creation Delete test for test_PageEditor
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2816
diff changeset
73 page = Page(self.request, self.pagename)
2786
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
74 args = "%s,%s" % (self.pagename, u'VAR')
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
75 result = self._test_macro(u'GetVal', args)
2834
7d4a6e369a5a test_GetVal fixed, Creation Delete test for test_PageEditor
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2816
diff changeset
76
2786
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
77 expected = "This is an example"
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
78 assert result == expected
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
79
2836
f5049c4cbf6e wikidicts.dict: loads current dict. fixed and new tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2834
diff changeset
80 def testGetValAfterADictPageIsDeleted(self):
f5049c4cbf6e wikidicts.dict: loads current dict. fixed and new tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2834
diff changeset
81 """ macro GetVal test: 'reads Dict var after another Dict is removed' """
f5049c4cbf6e wikidicts.dict: loads current dict. fixed and new tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2834
diff changeset
82
f5049c4cbf6e wikidicts.dict: loads current dict. fixed and new tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2834
diff changeset
83 self.shouldDeleteTestPage = True
f5049c4cbf6e wikidicts.dict: loads current dict. fixed and new tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2834
diff changeset
84
f5049c4cbf6e wikidicts.dict: loads current dict. fixed and new tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2834
diff changeset
85 pagename = u'SomeDict'
f5049c4cbf6e wikidicts.dict: loads current dict. fixed and new tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2834
diff changeset
86 page = PageEditor(self.request, pagename, do_editor_backup=0)
f5049c4cbf6e wikidicts.dict: loads current dict. fixed and new tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2834
diff changeset
87 body = u" EXAMPLE:: This is an example text"
f5049c4cbf6e wikidicts.dict: loads current dict. fixed and new tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2834
diff changeset
88 page.saveText(body, 0)
f5049c4cbf6e wikidicts.dict: loads current dict. fixed and new tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2834
diff changeset
89 success_i, result = page.deletePage()
f5049c4cbf6e wikidicts.dict: loads current dict. fixed and new tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2834
diff changeset
90
f5049c4cbf6e wikidicts.dict: loads current dict. fixed and new tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2834
diff changeset
91 self._createTestPage(u' VAR:: This is a brand new example')
f5049c4cbf6e wikidicts.dict: loads current dict. fixed and new tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2834
diff changeset
92 page = Page(self.request, self.pagename)
f5049c4cbf6e wikidicts.dict: loads current dict. fixed and new tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2834
diff changeset
93 args = "%s,%s" % (self.pagename, u'VAR')
f5049c4cbf6e wikidicts.dict: loads current dict. fixed and new tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2834
diff changeset
94 result = self._test_macro(u'GetVal', args)
f5049c4cbf6e wikidicts.dict: loads current dict. fixed and new tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2834
diff changeset
95
f5049c4cbf6e wikidicts.dict: loads current dict. fixed and new tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2834
diff changeset
96 expected = "This is a brand new example"
f5049c4cbf6e wikidicts.dict: loads current dict. fixed and new tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2834
diff changeset
97 assert result == expected
f5049c4cbf6e wikidicts.dict: loads current dict. fixed and new tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2834
diff changeset
98
2786
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
99 def testGetValACLs(self):
2816
50fcf4ba8374 skip broken test
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2786
diff changeset
100 """ macro GetVal test: 'cant read VAR on an ACL protected page' """
2786
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
101 py.test.skip("user has no rights to create acl pages")
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
102 self.shouldDeleteTestPage = True
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
103 self._createTestPage('#acl SomeUser:read,write All:delete\n VAR:: This is an example')
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
104 args = "%s,%s" % (self.pagename, u'VAR')
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
105 result = self._test_macro(u'GetVal', args)
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
106 expected = "&lt;&lt;GetVal: You don't have enough rights on this page&gt;&gt;"
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
107 assert result == expected
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
108
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
109 coverage_modules = ['MoinMoin.macro.GetVal']
a16ba90d1f7e macro.__init__.py:GetVal bug fixed of respecting acls and test added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
110