Skip to content

Commit

Permalink
feat(tests): customize tests to the new flow
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlevinwork committed May 13, 2024
1 parent 80269cc commit e3bc384
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
3 changes: 0 additions & 3 deletions tests/dataset.csv

This file was deleted.

20 changes: 17 additions & 3 deletions tests/test_algo.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
3 changes: 2 additions & 1 deletion tests/test_data_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
Expand Down

0 comments on commit e3bc384

Please sign in to comment.