diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/test_csv_reader.py | 11 | ||||
| -rw-r--r-- | test/test_obfuscator.py | 13 |
2 files changed, 23 insertions, 1 deletions
diff --git a/test/test_csv_reader.py b/test/test_csv_reader.py index 1b3d071..af13cff 100644 --- a/test/test_csv_reader.py +++ b/test/test_csv_reader.py @@ -7,22 +7,30 @@ reader = CSVReader() # Check if the function can read a CSV string with no content and return # an empty list + + def test_empty_csv_should_return_no_content(): content = "" result = reader.read_string(content) expected = [] assert result == expected + # Check if the function can read a CSV string with only a header and return # an empty list + + def test_csv_with_header_only_should_return_no_content(): content = "student_id,name,course\n" result = reader.read_string(content) expected = [] assert result == expected + # Check if the function can read a CSV string with valid data and return # a list of dictionaries + + def test_csv_with_valid_data(): content = ( "student_id,name,course\n" @@ -36,8 +44,11 @@ def test_csv_with_valid_data(): ] assert result == expected + # Check if the function can read a CSV string with quoted fields and return # a list of dictionaries with the quoted fields intact + + def test_csv_with_quoted_fields_should_run_as_expected(): content = ( "student_id,name,course\n" diff --git a/test/test_obfuscator.py b/test/test_obfuscator.py index cc7d2c1..4f61b16 100644 --- a/test/test_obfuscator.py +++ b/test/test_obfuscator.py @@ -1,7 +1,9 @@ from obfuscator.obfuscate import obfuscate -# Check if the function does what its supposed to and can obfuscate +# Check if the function does what its supposed to and can obfuscate # valid PII fields in a list of dictionaries + + def test_obfuscate_data_with_valid_pii_fields(): data = [ { @@ -36,9 +38,12 @@ def test_obfuscate_data_with_valid_pii_fields(): result = obfuscate(data, pii_fields) assert result == expected + # Check if the function can obfuscate data even when some PII # fields are missing from some of the data, returning a list of dictionaries # but with the missing PII fields obfuscated and the rest of the data intact + + def test_obfuscate_data_with_missing_pii_field(): data = [ {"student_id": "1234", "name": "John Smith", "course": "Software"}, @@ -63,7 +68,10 @@ def test_obfuscate_data_with_missing_pii_field(): result = obfuscate(data, pii_fields) assert result == expected + # Check if the function can handle an empty list of data, returning an empty list + + def test_obfuscate_data_with_no_data(): data = [] pii_fields = ["name", "email_address"] @@ -72,8 +80,11 @@ def test_obfuscate_data_with_no_data(): result = obfuscate(data, pii_fields) assert result == expected + # Check if the function can handle an empty list of PII fields, returning the data as is # without mutating it + + def test_obfuscate_data_with_empty_pii_fields(): data = [ { |
