Example #1
0
def test_render_div():
    assert render_layout(
        ['div', {},
         []]) == ['div', {
             'div_char': u' ',
             'top': 0,
             'bottom': 0,
         }]
Example #2
0
def test_text_tag(layout):
    el = render_layout(layout)
    assert el == [
        'text', {
            'markup': 'hello world',
            'align': 'left',
            'wrap': 'space',
        }
    ]
Example #3
0
def test_text_tag_with_self_ref(layout):
    layout[2] = '{ title }'
    el = render_layout(layout, {}, {'title': 'hello world'})
    assert el == [
        'text', {
            'markup': 'hello world',
            'align': 'left',
            'wrap': 'space',
        }
    ]
Example #4
0
def test_text_tag(layout):
    el = render_layout(layout)
    assert el == [
        'text',
        {
            'markup': 'hello world',
            'align': 'left',
            'wrap': 'space',
        }
    ]
Example #5
0
def test_padding_align_twenty_percentage():
    el = render_layout([
        'text',
        {
            'style': 'padding-align: 20%',
        },
        u'text',
    ])
    assert el
    assert el.render((10, )).text == ['  text    ']
Example #6
0
def test_padding_align_center():
    el = render_layout([
        'text',
        {
            'style': 'padding-align: center',
        },
        u'text',
    ])
    assert el
    assert el.render((10, )).text == ['   text   ']
Example #7
0
def test_padding_left():
    el = render_layout([
        'text',
        {
            'style': 'padding-left: 2',
        },
        u'text',
    ])
    assert el
    assert el.render((6, )).text == ['  text']
Example #8
0
def test_render_div_with_div_char():
    el = render_layout(['div', {
        'char': u'-',
        'top': 1,
        'bottom': 1
    }, []]) == ['div', {
        'div_char': u'-',
        'top': 1,
        'bottom': 1,
    }]
Example #9
0
def test_render_div():
    assert render_layout([
        'div', {}, []
    ]) == [
        'div',
        {
            'div_char': u' ',
            'top': 0,
            'bottom': 0,
        }
    ]
Example #10
0
def test_text_tag_with_opts_ref(layout):
    opts = {'title': 'hello world'}
    layout[2] = '{ opts.title }'
    el = render_layout(layout, opts)
    assert el == [
        'text', {
            'markup': 'hello world',
            'align': 'left',
            'wrap': 'space',
        }
    ]
Example #11
0
def test_text_tag_with_attr_ref(layout):
    layout[1]['title'] = 'hello world'
    layout[2] = '{ opts.title }'
    el = render_layout(layout)
    assert el == [
        'text', {
            'markup': 'hello world',
            'align': 'left',
            'wrap': 'space',
        }
    ]
Example #12
0
def test_text_tag_with_self_ref(layout):
    layout[2] = '{ title }'
    el = render_layout(layout, {}, {'title': 'hello world'})
    assert el == [
        'text',
        {
            'markup': 'hello world',
            'align': 'left',
            'wrap': 'space',
        }
    ]
Example #13
0
def test_text_tag_with_attr_ref(layout):
    layout[1]['title'] = 'hello world'
    layout[2] = '{ opts.title }'
    el = render_layout(layout)
    assert el == [
        'text',
        {
            'markup': 'hello world',
            'align': 'left',
            'wrap': 'space',
        }
    ]
Example #14
0
def test_text_tag_with_opts_ref(layout):
    opts = {'title': 'hello world'}
    layout[2] = '{ opts.title }'
    el = render_layout(layout, opts)
    assert el == [
        'text',
        {
            'markup': 'hello world',
            'align': 'left',
            'wrap': 'space',
        }
    ]
Example #15
0
def test_padding_width():
    el = render_layout([
        'text',
        {
            'style': 'padding-width: 2',
        },
        u'text',
    ])
    assert el
    assert el.render((3, )).text == [
        'te ',
        'xt ',
    ]
Example #16
0
def test_padding_width_relative():
    el = render_layout([
        'text',
        {
            'style': 'padding-width: 20%',
        },
        u'abc',
    ])
    assert el
    assert el.render((10, )).text == [
        'ab        ',
        'c         ',
    ]
Example #17
0
def test_padding_width_pack():
    el = render_layout([
        'text',
        {
            'style': 'padding-width: pack',
        },
        u'text\nlatex',
    ])
    assert el
    assert el.render((6, )).text == [
        ' text',
        'latex',
    ]
Example #18
0
def test_render_div_with_div_char():
    el = render_layout([
        'div', {
            'char': u'-',
            'top': 1,
            'bottom': 1
        }, []
    ]) == [
        'div',
        {
            'div_char': u'-',
            'top': 1,
            'bottom': 1,
        }
    ]
Example #19
0
def test_render_div_with_opts():
    assert render_layout([
        'div', {
            'char': '{ opts.custom_char }',
            'top': '{ opts.custom_top }',
            'bottom': '{ opts.custom_bottom }',
        }, []
    ], {
        'custom_char': u'x',
        'custom_top': '1',
        'custom_bottom': '1',
    }) == ['div', {
        'div_char': u'x',
        'top': 1,
        'bottom': 1,
    }]
Example #20
0
def test_render_div_with_opts():
    assert render_layout([
        'div', {
            'char': '{ opts.custom_char }',
            'top': '{ opts.custom_top }',
            'bottom': '{ opts.custom_bottom }',
        }, []
    ], {
        'custom_char': u'x',
        'custom_top': '1',
        'custom_bottom': '1',
    }) == [
        'div',
        {
            'div_char': u'x',
            'top': 1,
            'bottom': 1,
        }
    ]