"""
open/DurusWorks/qp/fill/test/utest_html.py
"""
from sancho.utest import UTest
from qp.fill.html import href, div, ol, ul, dl, nl2br, url_with_query, htmltag
from qp.fill.html import nlnl2brbr
from qpy import xml
class HTMLTest(UTest):
def a(self):
result = href('a', 'b', name="c")
assert isinstance(result, xml)
assert result == 'b', repr(result)
def b(self):
result = div('a', 'b', c="d")
assert isinstance(result, xml)
assert result == '
ab
'
def c(self):
result = ol(['a', 'b'], c="d")
assert isinstance(result, xml)
assert result == '- a
- b
'
def d(self):
result = ul(['a', 'b'], c="d")
assert isinstance(result, xml)
assert result == ''
def e(self):
result = dl([('a', 'b'), ('e', None)], c="d")
assert isinstance(result, xml)
assert result == '- a
- b
- e
'
def f(self):
result = nl2br('')
assert isinstance(result, xml)
result = nl2br('a\nb\n')
assert isinstance(result, xml)
assert result == 'a
b
', result
def test_nlnl2brbr(self):
result = nlnl2brbr('')
assert isinstance(result, xml)
result = nlnl2brbr('a\nb\n')
assert isinstance(result, xml)
assert result == 'a\nb\n'
result = nlnl2brbr('a\n\nb\n\nc\n')
assert result == 'a
b
c\n', result
def test_url_with_query(self):
result = url_with_query('/foo', x=1, y='A<')
assert isinstance(result, xml)
assert result == '/foo?x=1&y=A%3C', result
def g(self):
result = htmltag('a', name="\xe1\x88\xb4")
if __name__ == '__main__':
HTMLTest()