From e3bc384b54226c4fe74dc8c7969eed40287b0fb2 Mon Sep 17 00:00:00 2001 From: davidlevinwork Date: Mon, 13 May 2024 08:19:16 +0300 Subject: [PATCH] feat(tests): customize tests to the new flow --- tests/dataset.csv | 3 --- tests/test_algo.py | 20 +++++++++++++++++--- tests/test_data_processor.py | 3 ++- 3 files changed, 19 insertions(+), 7 deletions(-) delete mode 100644 tests/dataset.csv diff --git a/tests/dataset.csv b/tests/dataset.csv deleted file mode 100644 index 7f37f02..0000000 --- a/tests/dataset.csv +++ /dev/null @@ -1,3 +0,0 @@ -feature_0,feature_1,feature_2,class -1,2,3,0 -4,5,6,1 diff --git a/tests/test_algo.py b/tests/test_algo.py index 40681aa..6ae92e0 100644 --- a/tests/test_algo.py +++ b/tests/test_algo.py @@ -1,18 +1,32 @@ +from typing import Optional from unittest.mock import patch - from gbfs.algorithms.base import FeatureSelectorBase +import pandas as pd + + +class ConcreteFeatureSelector(FeatureSelectorBase): + def select_features(self) -> Optional[list]: + return [] @patch('gbfs.models.dim_reducer.DimReducerProtocol') -def test_initialization(mock_dim_reducer_protocol): +@patch('pandas.read_csv') +def test_initialization(mock_read_csv, mock_dim_reducer_protocol): """ Test initialization of FeatureSelectorBase with mocked dependencies. """ + # Mock read_csv to return a DataFrame + mock_read_csv.return_value = pd.DataFrame({ + 'feature1': [1, 2, 3], + 'feature2': [4, 5, 6], + 'class': [0, 1, 0] + }) + dataset_path = 'tests/dataset.csv' separability_metric = 'jm' label_column = 'class' - fs_base = FeatureSelectorBase( + fs_base = ConcreteFeatureSelector( dataset_path, separability_metric, mock_dim_reducer_protocol, diff --git a/tests/test_data_processor.py b/tests/test_data_processor.py index 19ff889..b107dc0 100644 --- a/tests/test_data_processor.py +++ b/tests/test_data_processor.py @@ -59,10 +59,11 @@ def test_compute_data_properties(): } ), ) + feature_costs = {'feature1': 1.0, 'feature2': 1.0} data_processor = DataProcessor('tests/dataset.csv') - data_props = data_processor._compute_data_properties(mock_data_collection) + data_props = data_processor._compute_data_properties(mock_data_collection, feature_costs) assert isinstance(data_props, DataProps), 'Should return a DataProps instance.' assert data_props.n_features == 2, 'There should be two features.'