aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_csv_reader.py
blob: 81898422b91173ac10915c3d992a6a4c937f3e2a (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
# csv_reader.py - tests
# Author: Alex Schofield

from csv_reader import csv_reader

def test_empty_csv_should_return_no_content():
    content = ""
    result = csv_reader(content)
    expected = []
    assert result == expected

def test_csv_with_header_only_should_return_no_content():
    content = "student_id,name,course\n"
    result = csv_reader(content)
    expected = []
    assert result == expected

def test_csv_with_valid_data():
    content = (
        "student_id,name,course\n"
        "1234,Student 1,Course 1\n"
        "5678,Student 2,Course 2\n"
        )
    result = csv_reader(content)
    expected = [
        {"student_id": "1234", "name": "Student 1", "course": "Course 1"},
        {"student_id": "5678", "name": "Student 2", "course": "Course 2"},
        ]
    assert result == expected 

def test_csv_with_quoted_fields_should_be_sanitised():
    pass

def test_non_csv_file_should_return_no_content():
    pass

def test_csv_file_with_embedded_newline_should_be_sanitised():
    pass

def test_csv_file_with_embedded_comma_should_be_sanitised():
    pass

def test_csv_file_with_embedded_quote_should_be_sanitised():
    pass

def test_csv_file_with_null_values_should_be_transformed_to_empty_string():
    pass

def test_csv_file_with_non_string_data_should_be_transformed_to_empty_string():
    pass
git.ajschof.me — hosted by ajschofield — powered by cgit