Back to index

moin  1.9.0~rc2
test_GetVal.py
Go to the documentation of this file.
00001 # -*- coding: iso-8859-1 -*-
00002 """
00003     MoinMoin - MoinMoin.macro GetVal tested
00004 
00005     @copyright: 2007 MoinMoin:ReimarBauer
00006     @license: GNU GPL, see COPYING for details.
00007 """
00008 import os, py
00009 
00010 from MoinMoin import macro
00011 from MoinMoin.Page import Page
00012 from MoinMoin.PageEditor import PageEditor
00013 from MoinMoin._tests import become_trusted, create_page, make_macro, nuke_page
00014 
00015 class TestGetVal:
00016     """GetVal: testing getVal macro """
00017     pagename = u'MyDict'
00018 
00019     def setup_class(self):
00020         become_trusted(self.request)
00021         self.cfg = self.request.cfg
00022 
00023     def teardown_class(self):
00024         nuke_page(self.request, self.pagename)
00025 
00026     def _test_macro(self, name, args, page):
00027         m = make_macro(self.request, page)
00028         return m.execute(name, args)
00029 
00030     def testGetValNoACLs(self):
00031         """ macro GetVal test: 'reads VAR' """
00032         page = create_page(self.request, self.pagename, u' VAR:: This is an example')
00033         result = self._test_macro(u'GetVal', "%s,%s" % (self.pagename, u'VAR'), page)
00034         assert result == "This is an example"
00035 
00036     def testGetValAfterADictPageIsDeleted(self):
00037         """ macro GetVal test: 'reads Dict var after another Dict is removed' """
00038         request = self.request
00039         become_trusted(request)
00040         page = create_page(request, u'SomeDict', u" EXAMPLE:: This is an example text")
00041         page.deletePage()
00042         page = create_page(request, self.pagename, u' VAR:: This is a brand new example')
00043         result = self._test_macro(u'GetVal', "%s,%s" % (self.pagename, u'VAR'), page)
00044         nuke_page(request, u'SomeDict')
00045         assert result == "This is a brand new example"
00046 
00047     def testGetValACLs(self):
00048         """ macro GetVal test: 'cant read VAR on an ACL protected page' """
00049         py.test.skip("user has no rights to create acl pages")
00050         page = create_page(self.request, self.pagename,
00051                            '#acl SomeUser:read,write All:delete\n VAR:: This is an example')
00052         result = self._test_macro(u'GetVal', "%s,%s" % (self.pagename, u'VAR'), page)
00053         assert result == "<<GetVal: You don't have enough rights on this page>>"
00054 
00055 coverage_modules = ['MoinMoin.macro.GetVal']
00056