Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
fealho committed Feb 22, 2024
1 parent d7022b2 commit dfed849
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ max-attributes = 11
ignore-comments = yes
ignore-docstrings = yes
ignore-imports = yes
disable = R0801, R0903, R0913, R0914, R1708, C0209, W0223, W0221, W0237, C0411,
disable = R0801, R0902, R0903, R0913, R0914, R1708, C0209, W0223, W0221, W0237, C0411,
W0231 # __init__ method from base class is not called on a child class
ignored-classes = sre_parse

13 changes: 11 additions & 2 deletions tests/unit/transformers/pii/test_anonymizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,8 @@ def test___init__error_missing_value_generation(self):

@patch('rdt.transformers.pii.anonymizer.faker')
@patch('rdt.transformers.pii.anonymizer.AnonymizedFaker.check_provider_function')
def test___init__custom(self, mock_check_provider_function, mock_faker):
@patch('rdt.transformers.pii.anonymizer.warnings')
def test___init__custom(self, mock_warnings, mock_check_provider_function, mock_faker):
"""Test the instantiation of the transformer with custom parameters.
Test that the transformer can be instantiated with a custom provider and function, and
Expand Down Expand Up @@ -362,7 +363,8 @@ def test___init__custom(self, mock_check_provider_function, mock_faker):
'type': 'visa'
},
locales=['en_US', 'fr_FR'],
cardinality_rule='match'
cardinality_rule='match',
enforce_uniqueness=True
)

# Assert
Expand All @@ -373,6 +375,13 @@ def test___init__custom(self, mock_check_provider_function, mock_faker):
assert instance.locales == ['en_US', 'fr_FR']
mock_faker.Faker.assert_called_once_with(['en_US', 'fr_FR'])
assert instance.cardinality_rule == 'match'
mock_warnings.warn.assert_has_calls([
call(
"The 'enforce_uniqueness' parameter is no longer supported. "
"Please use the 'cardinality_rule' parameter instead.",
FutureWarning
)
])

def test___init__no_function_name(self):
"""Test the instantiation of the transformer with custom parameters.
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/transformers/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import sre_parse
from sre_constants import MAXREPEAT
from unittest.mock import patch

import numpy as np
import pandas as pd
import pytest
import sre_parse
from sre_constants import MAXREPEAT

from rdt.transformers.utils import (
_any, _max_repeat, check_nan_in_transform, flatten_column_list, learn_rounding_digits,
Expand Down

0 comments on commit dfed849

Please sign in to comment.