diff --git a/spreadsheets/example_spreadsheet.xlsx b/spreadsheets/example_spreadsheet.xlsx new file mode 100644 index 0000000..e933f72 Binary files /dev/null and b/spreadsheets/example_spreadsheet.xlsx differ diff --git a/tests/test_data.py b/tests/test_data.py new file mode 100644 index 0000000..1ec033b --- /dev/null +++ b/tests/test_data.py @@ -0,0 +1,31 @@ +"""Pytest test suite for the filesystem module.""" + +from pathlib import Path + +from cellveyor import data + + +def test_access_dataframes() -> None: + spreadsheet_file_one = Path("spreadsheets/fake_spreadsheet.xlsx") + spreadsheet_file_two = Path("spreadsheets/example_spreadsheet.xlsx") + test_one = data.access_dataframes(spreadsheet_file_one) + test_two = data.access_dataframes(spreadsheet_file_two) + assert test_one != test_two + + +def test_key_attribute_column_filter() -> None: + # Test key_attribute_column_filter function + dataframes_dict = data.access_dataframes(Path("spreadsheets/fake_spreadsheet.xlsx")) + sheet1_dataframe = dataframes_dict["Main"] + + # Test filtering with a key attribute and columns regex + key_attribute_name = "Student GitHub" + column_regexp = "^(Summary Grade|Final Grade) .*$" + key_attribute_value = "gkapfham" + selected_columns, result_df = data.key_attribute_column_filter( + sheet1_dataframe, key_attribute_name, column_regexp, key_attribute_value + ) + + assert ("Summary Grade for Team Participation") in selected_columns.columns + assert ("Student GitHub") in result_df.columns + assert key_attribute_value in result_df["Student GitHub"].values