summaryrefslogtreecommitdiffstats
path: root/tests/test_build/test_build_row.py
blob: 93aaf37f899d688595b72ee4c92019e41a1b9234 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
"""Test function in module."""

from terminaltables3.build import build_row


def test_one_line():
    """Test with one line cells."""
    row = [
        ["Left Cell"],
        ["Center Cell"],
        ["Right Cell"],
    ]
    actual = [tuple(i) for i in build_row(row, ">", "|", "<")]
    expected = [
        (">", "Left Cell", "|", "Center Cell", "|", "Right Cell", "<"),
    ]
    assert actual == expected


def test_two_line():
    """Test with two line cells."""
    row = [
        [
            "Left ",
            "Cell1",
        ],
        [
            "Center",
            "Cell2 ",
        ],
        [
            "Right",
            "Cell3",
        ],
    ]
    actual = [tuple(i) for i in build_row(row, ">", "|", "<")]
    expected = [
        (">", "Left ", "|", "Center", "|", "Right", "<"),
        (">", "Cell1", "|", "Cell2 ", "|", "Cell3", "<"),
    ]
    assert actual == expected


def test_three_line():
    """Test with three line cells."""
    row = [
        [
            "Left ",
            "Cell1",
            "     ",
        ],
        [
            "Center",
            "Cell2 ",
            "      ",
        ],
        [
            "Right",
            "Cell3",
            "     ",
        ],
    ]
    actual = [tuple(i) for i in build_row(row, ">", "|", "<")]
    expected = [
        (">", "Left ", "|", "Center", "|", "Right", "<"),
        (">", "Cell1", "|", "Cell2 ", "|", "Cell3", "<"),
        (">", "     ", "|", "      ", "|", "     ", "<"),
    ]
    assert actual == expected


def test_single():
    """Test with single cell."""
    actual = [tuple(i) for i in build_row([["Cell"]], ">", "|", "<")]
    expected = [
        (">", "Cell", "<"),
    ]
    assert actual == expected


def test_empty():
    """Test with empty cell."""
    actual = [tuple(i) for i in build_row([[""]], ">", "|", "<")]
    expected = [
        (">", "", "<"),
    ]
    assert actual == expected


def test_no_cells():
    """Test with no cells."""
    actual = [tuple(i) for i in build_row([[]], ">", "|", "<")]
    expected = [
        (">", "<"),
    ]
    assert actual == expected

    actual = [tuple(i) for i in build_row([], ">", "|", "<")]
    expected = [
        (">", "<"),
    ]
    assert actual == expected