view MoinMoin/util/_tests/test_tree.py @ 2657:080673c3e60a

Now nameless items can also be downloaded and removed unnecessary blank spaces in items/content.py
author Saurabh Kathpalia <saurabh.kathpalia95@gmail.com>
date Sun, 06 Jul 2014 09:25:31 +0530
parents 181a556a0920
children
line wrap: on
line source
# Copyright: 2008 MoinMoin:BastianBlank
# License: GNU GPL v2 (or any later version), see LICENSE.txt for details.

"""
MoinMoin - Tests for MoinMoin.util.tree
"""


from MoinMoin.util.tree import *


def test_Name():
    uri = 'uri:a'

    name = Name('a', uri)
    assert isinstance(name, ET.QName)
    assert name.name == 'a'
    assert name.uri == uri
    assert name == '{uri:a}a'

    element = name()
    assert isinstance(element, ET.Element)
    assert element.tag == name


def test_Namespace():
    uri = 'uri:a'

    namespace = Namespace(uri)
    assert namespace == uri
    assert namespace is namespace.namespace

    name = namespace.a
    assert isinstance(name, Name)
    assert name.name == 'a'
    assert name.uri == uri

    name = namespace('a')
    assert isinstance(name, Name)
    assert name.name == 'a'
    assert name.uri == uri

    name = namespace.outline_level
    assert name.name == 'outline-level'
    assert name.uri == uri

    name = namespace('outline-level')
    assert name.name == 'outline-level'
    assert name.uri == uri

    name = namespace.class_
    assert name.name == 'class'
    assert name.uri == uri

    name = namespace('class')
    assert name.name == 'class'
    assert name.uri == uri

    name = namespace('class_')
    assert name.name == 'class_'
    assert name.uri == uri


def test_html():
    assert isinstance(html, Namespace)


def test_moin_page():
    assert isinstance(moin_page, Namespace)