Skip to content

Commit

Permalink
coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
R-Palazzo committed Aug 23, 2023
1 parent c8d0ef6 commit 66c34f5
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
26 changes: 26 additions & 0 deletions tests/unit/test_hyper_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,32 @@ def test__validate_config(self):
with pytest.raises(InvalidConfigError, match=error_msg):
HyperTransformer._validate_config(config)

def test_validate_config_not_unique_field(self):
"""Test the ``_validate_config`` method when a column is repeated in a field."""
# Setup
transformers = {
'column1': FloatFormatter(),
'column2': FrequencyEncoder(),
('column2', 'column3'): None
}
sdtypes = {
'column1': 'numerical',
'column2': 'numerical',
'column3': 'numerical'
}
config = {
'sdtypes': sdtypes,
'transformers': transformers
}

# Run
error_msg = re.escape(
'Error: Invalid config. Please provide unique keys for the sdtypes '
'and transformers.'
)
with pytest.raises(InvalidConfigError, match=error_msg):
HyperTransformer._validate_config(config)

@patch('rdt.hyper_transformer.warnings')
def test__validate_config_no_warning(self, warnings_mock):
"""Test the ``_validate_config`` method with no warning.
Expand Down
15 changes: 14 additions & 1 deletion tests/unit/transformers/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sre_parse
from sre_constants import MAXREPEAT

from rdt.transformers.utils import _any, _max_repeat, strings_from_regex
from rdt.transformers.utils import _any, _max_repeat, flatten_column_list, strings_from_regex


def test_strings_from_regex_literal():
Expand Down Expand Up @@ -53,3 +53,16 @@ def test_strings_from_regex_very_large_regex():

assert size == 173689027553046619421110743915454114823342474255318764491341273608665169920
[next(generator) for _ in range(100_000)]


def test_flatten_column_list():
"""Test `flatten_column_list` function."""
# Setup
column_list = ['column1', ('column2', 'column3'), 'column4', ('column5',), 'column6']

# Run
flattened_list = flatten_column_list(column_list)

# Assert
expected_flattened_list = ['column1', 'column2', 'column3', 'column4', 'column5', 'column6']
assert flattened_list == expected_flattened_list

0 comments on commit 66c34f5

Please sign in to comment.