File: test_normalizer.py

package info (click to toggle)
python-tabledata 1.3.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 300 kB
  • sloc: python: 1,406; makefile: 69; sh: 5
file content (76 lines) | stat: -rw-r--r-- 2,635 bytes parent folder | download
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
import pytest

from tabledata import TableData
from tabledata.normalizer import TableDataNormalizer


class Test_TableDataNormalizer:
    @pytest.mark.parametrize(
        ["table_name", "headers", "rows", "expected"],
        [
            [
                "normal",
                ["a", "b_c"],
                [[1, 2], [3, 4]],
                TableData("normal", ["a", "b_c"], [[1, 2], [3, 4]]),
            ],
            [
                "underscore_char",
                ["data", "_data", "data_", "_data_"],
                [[1, 2, 3, 4], [11, 12, 13, 14]],
                TableData(
                    "underscore_char",
                    ["data", "_data", "data_", "_data_"],
                    [[1, 2, 3, 4], [11, 12, 13, 14]],
                ),
            ],
            [
                "multibyte csv",
                ["姓", "名", "生年月日", "郵便番号", "住所", "電話番号"],
                [
                    [
                        "山田",
                        "太郎",
                        "2001/1/1",
                        "100-0002",
                        "東京都千代田区皇居外苑",
                        "03-1234-5678",
                    ],
                    [
                        "山田",
                        "次郎",
                        "2001/1/2",
                        "251-0036",
                        "神奈川県藤沢市江の島1丁目",
                        "03-9999-9999",
                    ],
                ],
                TableData(
                    "multibyte csv",
                    ["姓", "名", "生年月日", "郵便番号", "住所", "電話番号"],
                    [
                        [
                            "山田",
                            "太郎",
                            "2001/1/1",
                            "100-0002",
                            "東京都千代田区皇居外苑",
                            "03-1234-5678",
                        ],
                        [
                            "山田",
                            "次郎",
                            "2001/1/2",
                            "251-0036",
                            "神奈川県藤沢市江の島1丁目",
                            "03-9999-9999",
                        ],
                    ],
                ),
            ],
        ],
    )
    def test_normal(self, table_name, headers, rows, expected):
        new_tabledata = TableDataNormalizer(TableData(table_name, headers, rows)).normalize()

        assert new_tabledata.equals(expected)