Completed
Push — master ( a208b6...2c60dc )
by Kolen
01:08
created

test_read_csv()   B

Complexity

Conditions 5

Size

Total Lines 38

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
cc 5
c 2
b 0
f 1
dl 0
loc 38
rs 8.0894
1
#!/usr/bin/env python3
2
"""
3
"""
4
from .context import read_csv
5
6
7
def test_read_csv():
8
    include = None
9
    # check type
10
    data = r"""1,2
11
3,4
12
"""
13
    assert read_csv(include, data) == [
14
        ['1', '2'],
15
        ['3', '4']
16
    ]
17
    # check complex cells
18
    data = r"""asdfdfdfguhfdhghfdgkla,"334
19
2",**la**,4
20
5,6,7,8"""
21
    assert read_csv(include, data) == [
22
        ['asdfdfdfguhfdhghfdgkla', '334\n2', '**la**', '4'],
23
        ['5', '6', '7', '8']
24
    ]
25
    # check include
26
    include = 'tests/csv_tables.csv'
27
    assert read_csv(include,
28
                    data) == [['**_Fruit_**',
29
                               '~~Price~~',
30
                               '_Number_',
31
                               '`Advantages`'],
32
                              ['*Bananas~1~*',
33
                               '$1.34',
34
                               '12~units~',
35
                               'Benefits of eating bananas \n(**Note the appropriately\nrendered block markdown**):    \n\n- _built-in wrapper_        \n- ~~**bright color**~~\n\n'],
36
                              ['*Oranges~2~*',
37
                               '$2.10',
38
                               '5^10^~units~',
39
                               'Benefits of eating oranges:\n\n- **cures** scurvy\n- `tasty`']]
40
    # check empty table
41
    include = None
42
    data = ''
43
    assert read_csv(include, data) == []
44
    return
45