Esempio n. 1
0
def test_unordered_list():
    assert str(lists.UnorderedList(['foo', 'bar',
                                    'baz'])) == remove_whitespace("""
        <ul>
            <li>foo</li>
            <li>bar</li>
            <li>baz</li>
        </ul>
        """)
Esempio n. 2
0
def test_ordered_list(starting_number):
    assert str(
        lists.OrderedList(
            ['foo', 'bar', 'baz'],
            starting_number=starting_number)) == remove_whitespace(f"""
        {'<ol>' if starting_number == 1 else '<ol start="' + str(starting_number) + '">'}
            <li>foo</li>
            <li>bar</li>
            <li>baz</li>
        </ol>
        """)
def test_table_with_alignment(alignment):
    assert table.table([['col1', 'col2'], ['hello', 'world']],
                       [alignment, alignment]) == remove_whitespace(f"""
        <table>
            <thead>
                <tr>
                    <th align="{alignment.value}">col1</th>
                    <th align="{alignment.value}">col2</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td align="{alignment.value}">hello</td>
                    <td align="{alignment.value}">world</td>
                </tr>
            </tbody>
        </table>
        """)
def test_table_with_only_one_aligned_column():
    assert table.table(
        [['col1', 'col2'], ['hello', 'world']],
        [table.TableAlignment.CENTER, None]) == remove_whitespace("""
        <table>
            <thead>
                <tr>
                    <th align="center">col1</th>
                    <th>col2</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td align="center">hello</td>
                    <td>world</td>
                </tr>
            </tbody>
        </table>
        """)
Esempio n. 5
0
def test_nested_lists(outer_list_tags, inner_list_tags):
    if inner_list_tags[0] == '<ul>':
        inner_list = lists.UnorderedList(['hello', 'world'])
    else:
        inner_list = lists.OrderedList(['hello', 'world'])

    if outer_list_tags[0] == '<ul>':
        html_list = lists.UnorderedList(['foo', 'bar', inner_list, 'baz'])
    else:
        html_list = lists.OrderedList(['foo', 'bar', inner_list, 'baz'])

    assert str(html_list) == remove_whitespace(f"""
        {outer_list_tags[0]}
            <li>foo</li>
            <li>bar</li>
            {inner_list_tags[0]}
                <li>hello</li>
                <li>world</li>
            {inner_list_tags[1]}
            <li>baz</li>
        {outer_list_tags[1]}
        """)
def test_table():
    assert table.table([['col1', 'col2'], ['hello', 'world'],
                        ['foo', 'bar']]) == remove_whitespace("""
        <table>
            <thead>
                <tr>
                    <th>col1</th>
                    <th>col2</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>hello</td>
                    <td>world</td>
                </tr>
                <tr>
                    <td>foo</td>
                    <td>bar</td>
                </tr>
            </tbody>
        </table>
        """)