Пример #1
0
def test_render_div():
    assert render_layout(
        ['div', {},
         []]) == ['div', {
             'div_char': u' ',
             'top': 0,
             'bottom': 0,
         }]
Пример #2
0
def test_text_tag(layout):
    el = render_layout(layout)
    assert el == [
        'text', {
            'markup': 'hello world',
            'align': 'left',
            'wrap': 'space',
        }
    ]
Пример #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',
        }
    ]
Пример #4
0
def test_text_tag(layout):
    el = render_layout(layout)
    assert el == [
        'text',
        {
            'markup': 'hello world',
            'align': 'left',
            'wrap': 'space',
        }
    ]
Пример #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    ']
Пример #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   ']
Пример #7
0
def test_padding_left():
    el = render_layout([
        'text',
        {
            'style': 'padding-left: 2',
        },
        u'text',
    ])
    assert el
    assert el.render((6, )).text == ['  text']
Пример #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,
    }]
Пример #9
0
def test_render_div():
    assert render_layout([
        'div', {}, []
    ]) == [
        'div',
        {
            'div_char': u' ',
            'top': 0,
            'bottom': 0,
        }
    ]
Пример #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',
        }
    ]
Пример #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',
        }
    ]
Пример #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',
        }
    ]
Пример #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',
        }
    ]
Пример #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',
        }
    ]
Пример #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 ',
    ]
Пример #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         ',
    ]
Пример #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',
    ]
Пример #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,
        }
    ]
Пример #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,
    }]
Пример #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,
        }
    ]