Esempio n. 1
0
def test_parse_xml():
    """Testing our parse xml util"""
    result = parse_xml("<lol test=\"woot\">waaa<inside>heh</inside></lol>")
    expected = {u'lol': {'attribute': {u'test': u'woot'},
                      'meta': {'#text': u'waaa', u'inside': u'heh'}}}

    assert_equals(result, expected)

    parse_xml("<lol>testing invalid xml<lol>")
Esempio n. 2
0
def test_multiple_child_nodes():
    """testing multiple child nodes"""
    result = parse_xml(
        "<lol><first>text 1</first><second>text 2</second></lol>")
    expected = {u'lol': {u'first': u'text 1', u'second': u'text 2'}}

    assert_equals(result, expected)
Esempio n. 3
0
def test_parse_xml():
    """Testing our parse xml util"""
    result = parse_xml("<lol test=\"woot\">waaa<inside>heh</inside></lol>")
    expected = {
        u'lol': {
            'attribute': {
                u'test': u'woot'
            },
            'meta': {
                '#text': u'waaa',
                u'inside': u'heh'
            }
        }
    }

    assert_equals(result, expected)

    parse_xml("<lol>testing invalid xml<lol>")
Esempio n. 4
0
def test_append_to_root():
    """testing append to root entity"""
    result = parse_xml("<lol><first>text 1</first><first>text 2</first></lol>")
    expected = {u'lol': {u'first': [u'text 1', u'text 2']}}

    assert_equals(result, expected)
Esempio n. 5
0
def test_cdata_parse_xml():
    """testing when we pass cdata to the xml"""
    result = parse_xml("<lol><inside><![CDATA[???]]></inside></lol>")
    expected = {u'lol': {u'inside': u'???'}}

    assert_equals(result, expected)
Esempio n. 6
0
def test_append_to_root():
    """testing append to root entity"""
    result = parse_xml("<lol><first>text 1</first><first>text 2</first></lol>")
    expected = {u'lol': {u'first': [u'text 1', u'text 2']}}

    assert_equals(result, expected)
Esempio n. 7
0
def test_multiple_child_nodes():
    """testing multiple child nodes"""
    result = parse_xml("<lol><first>text 1</first><second>text 2</second></lol>")
    expected = {u'lol': {u'first': u'text 1', u'second': u'text 2'}}

    assert_equals(result, expected)
Esempio n. 8
0
def test_cdata_parse_xml():
    """testing when we pass cdata to the xml"""
    result = parse_xml("<lol><inside><![CDATA[???]]></inside></lol>")
    expected = {u'lol': {u'inside': u'???'}}

    assert_equals(result, expected)