diff --git a/cellveyor/data.py b/cellveyor/data.py index f61dcdd..12090cf 100644 --- a/cellveyor/data.py +++ b/cellveyor/data.py @@ -16,6 +16,7 @@ def access_dataframes(spreadsheet_file: Path) -> Dict[str, pandas.DataFrame]: name_to_dataframe_dict = pandas.read_excel(spreadsheet_file, sheet_name=None) return name_to_dataframe_dict + def key_attribute_column_filter( sheet_dataframe: pandas.DataFrame, key_attribute_name: str, diff --git a/tests/test_data.py b/tests/test_data.py index 7abee50..356ce42 100644 --- a/tests/test_data.py +++ b/tests/test_data.py @@ -10,24 +10,24 @@ 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_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 + +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