moin-2.0 / build / lib / MoinMoin / macro / _tests /

# Copyright: 2011 Prashant Kumar <contactprashantat AT gmail DOT com>
# License: GNU GPL v2 (or any later version), see LICENSE.txt for details.

Test for macro.GetVal

from flask import g as flaskg

from MoinMoin.macro.GetVal import *
from MoinMoin.config import SOMEDICT
from MoinMoin._tests import become_trusted, update_item
from MoinMoin.conftest import init_test_app, deinit_test_app
from MoinMoin._tests import wikiconfig
import pytest
DATA = "This is a dict item."

class TestMacro(object):
    """ Test: GetVal.Macro """

    def setup_method(self, method):
        # temporary hack till we apply test cleanup mechanism on tests., self.ctx = init_test_app(wikiconfig.Config)
        somedict = {u"One": u"1",
                    u"Two": u"2"}
        update_item(u'TestDict', {SOMEDICT: somedict}, DATA)

    def teardown_method(self, method):
        deinit_test_app(, self.ctx)

    def test_Macro(self):
        macro_obj = Macro()
        arguments = [u'TestDict']
        with pytest.raises(ValueError):
            macro_obj.macro('content', arguments, 'page_url', 'alternative')

        # add the second element to arguments

        if not[0]):
            with pytest.raises(ValueError):
                macro_obj.macro('content', arguments, 'page_url', 'alternative')

        result = macro_obj.macro('content', arguments, 'page_url', 'alternative')
        assert result == u'1'

        # change the value of second element
        arguments[1] = u'Two'
        result = macro_obj.macro('content', arguments, 'page_url', 'alternative')
        assert result == u'2'
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.