Example #1
0
def test_xml_utilities():
    x = _parse_xml(b'''<?xml version="1.0" encoding="UTF-8" ?>
        <D:multistatus xmlns:D="DAV:">
            <D:response>
                <D:propstat>
                    <D:status>HTTP/1.1 404 Not Found</D:status>
                    <D:prop>
                        <D:getcontenttype/>
                    </D:prop>
                </D:propstat>
                <D:propstat>
                    <D:prop>
                        <D:resourcetype>
                            <D:collection/>
                        </D:resourcetype>
                    </D:prop>
                </D:propstat>
            </D:response>
        </D:multistatus>
    ''')

    response = x.find('{DAV:}response')
    props = _merge_xml(response.findall('{DAV:}propstat/{DAV:}prop'))
    assert props.find('{DAV:}resourcetype/{DAV:}collection') is not None
    assert props.find('{DAV:}getcontenttype') is not None
Example #2
0
def test_xml_specialchars(char):
    x = _parse_xml('<?xml version="1.0" encoding="UTF-8" ?>'
                   '<foo>ye{}s\r\n'
                   'hello</foo>'.format(chr(char)).encode('ascii'))

    if char in _BAD_XML_CHARS:
        assert x.text == 'yes\nhello'
Example #3
0
def test_xml_utilities():
    x = _parse_xml('''<?xml version="1.0" encoding="UTF-8" ?>
        <D:multistatus xmlns:D="DAV:">
            <D:response>
                <D:propstat>
                    <D:status>HTTP/1.1 404 Not Found</D:status>
                    <D:prop>
                        <D:getcontenttype/>
                    </D:prop>
                </D:propstat>
                <D:propstat>
                    <D:prop>
                        <D:resourcetype>
                            <D:collection/>
                        </D:resourcetype>
                    </D:prop>
                </D:propstat>
            </D:response>
        </D:multistatus>
    ''')

    response = x.find('{DAV:}response')
    props = _merge_xml(response.findall('{DAV:}propstat/{DAV:}prop'))
    assert props.find('{DAV:}resourcetype/{DAV:}collection') is not None
    assert props.find('{DAV:}getcontenttype') is not None
Example #4
0
def test_xml_utilities():
    x = _parse_xml(b"""<?xml version="1.0" encoding="UTF-8" ?>
        <multistatus xmlns="DAV:">
            <response>
                <propstat>
                    <status>HTTP/1.1 404 Not Found</status>
                    <prop>
                        <getcontenttype/>
                    </prop>
                </propstat>
                <propstat>
                    <prop>
                        <resourcetype>
                            <collection/>
                        </resourcetype>
                    </prop>
                </propstat>
            </response>
        </multistatus>
    """)

    response = x.find("{DAV:}response")
    props = _merge_xml(response.findall("{DAV:}propstat/{DAV:}prop"))
    assert props.find("{DAV:}resourcetype/{DAV:}collection") is not None
    assert props.find("{DAV:}getcontenttype") is not None
Example #5
0
def test_xml_specialchars(char):
    x = _parse_xml('<?xml version="1.0" encoding="UTF-8" ?>'
                   "<foo>ye{}s\r\n"
                   "hello</foo>".format(chr(char)).encode("ascii"))

    if char in _BAD_XML_CHARS:
        assert x.text == "yes\nhello"
Example #6
0
def test_broken_xml(capsys):
    rv = _parse_xml(b'<h1>\x10haha</h1>')
    assert rv.text == 'haha'
    warnings = capsys.readouterr()[1]
    assert 'partially invalid xml' in warnings.lower()