From 4069a46dfb70ca98d8b2dfb671673c41b0f7c2e5 Mon Sep 17 00:00:00 2001 From: Alex Schofield Date: Mon, 17 Feb 2025 15:58:14 +0000 Subject: add comments for description of obfuscator.py tests --- test/test_obfuscator.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/test_obfuscator.py b/test/test_obfuscator.py index c77b6b4..0245a26 100644 --- a/test/test_obfuscator.py +++ b/test/test_obfuscator.py @@ -1,6 +1,7 @@ from obfuscator.obfuscate import obfuscate - +# Check if the function can obfuscate valid PII fields in a list +# of dictionaries def test_obfuscate_data_with_valid_pii_fields(): data = [ { @@ -35,7 +36,8 @@ 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 def test_obfuscate_data_with_missing_pii_field(): data = [ {"student_id": "1234", "name": "John Smith", "course": "Software"}, @@ -60,7 +62,7 @@ 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 def test_obfuscate_data_with_no_data(): data = [] pii_fields = ["name", "email_address"] @@ -69,7 +71,7 @@ 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 def test_obfuscate_data_with_empty_pii_fields(): data = [ { -- cgit v1.2.3 From 7a4057196cb9282355b1eff6f06ee5a3c33e4e67 Mon Sep 17 00:00:00 2001 From: Alex Schofield Date: Mon, 17 Feb 2025 15:58:58 +0000 Subject: remove unused import in test_csv_reader.py --- test/test_csv_reader.py | 1 - 1 file changed, 1 deletion(-) (limited to 'test') diff --git a/test/test_csv_reader.py b/test/test_csv_reader.py index e62c093..7f54c25 100644 --- a/test/test_csv_reader.py +++ b/test/test_csv_reader.py @@ -2,7 +2,6 @@ # Author: Alex Schofield from obfuscator.csv_reader import CSVReader -import pytest reader = CSVReader() -- cgit v1.2.3 From 227b6a86d3658845441d13779d147d8892216618 Mon Sep 17 00:00:00 2001 From: Alex Schofield Date: Mon, 17 Feb 2025 16:01:46 +0000 Subject: add expected outputs and more detail to test descriptions in test_obfuscator --- test/test_obfuscator.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'test') diff --git a/test/test_obfuscator.py b/test/test_obfuscator.py index 0245a26..cc7d2c1 100644 --- a/test/test_obfuscator.py +++ b/test/test_obfuscator.py @@ -1,7 +1,7 @@ from obfuscator.obfuscate import obfuscate -# Check if the function can obfuscate valid PII fields in a list -# of dictionaries +# 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 = [ { @@ -37,7 +37,8 @@ def test_obfuscate_data_with_valid_pii_fields(): assert result == expected # Check if the function can obfuscate data even when some PII -# fields are missing from some of the data +# 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"}, @@ -62,7 +63,7 @@ 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 +# 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"] @@ -71,7 +72,8 @@ 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 +# 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 = [ { -- cgit v1.2.3 From 7d9725dcc3270c13fccdb35cbe499ac7a99b87ec Mon Sep 17 00:00:00 2001 From: Alex Schofield Date: Mon, 17 Feb 2025 16:04:09 +0000 Subject: add comments for description of csv_reader.py tests --- test/test_csv_reader.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/test_csv_reader.py b/test/test_csv_reader.py index 7f54c25..0ce3401 100644 --- a/test/test_csv_reader.py +++ b/test/test_csv_reader.py @@ -5,21 +5,24 @@ from obfuscator.csv_reader import CSVReader 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" @@ -33,7 +36,8 @@ 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" -- cgit v1.2.3 From e2b0f2553b8dfcbe39f6e6fdc86ca68cc63f5705 Mon Sep 17 00:00:00 2001 From: Alex Schofield Date: Mon, 17 Feb 2025 16:04:27 +0000 Subject: remove repeated test in test_csv_reader.py --- test/test_csv_reader.py | 7 ------- 1 file changed, 7 deletions(-) (limited to 'test') diff --git a/test/test_csv_reader.py b/test/test_csv_reader.py index 0ce3401..1b3d071 100644 --- a/test/test_csv_reader.py +++ b/test/test_csv_reader.py @@ -50,10 +50,3 @@ def test_csv_with_quoted_fields_should_run_as_expected(): {"student_id": "5678", "name": "Student 2", "course": "Course 2"}, ] assert result == expected - - -def test_non_csv_file_should_return_no_content(): - content = "" - result = reader.read_string(content) - expected = [] - assert result == expected -- cgit v1.2.3