Skip to content

Commit

Permalink
Add enforce_uniqueness attribute to AnonymizedFaker (#771)
Browse files Browse the repository at this point in the history
  • Loading branch information
fealho authored Mar 16, 2024
1 parent c7706fa commit 7850f50
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions rdt/transformers/pii/anonymizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ def __init__(self, provider_name=None, function_name=None, function_kwargs=None,
super().__init__()
self._data_cardinality = None
self.data_length = None
self.enforce_uniqueness = enforce_uniqueness
self.cardinality_rule = cardinality_rule.lower() if cardinality_rule else None
if enforce_uniqueness:
warnings.warn(
Expand Down
8 changes: 8 additions & 0 deletions tests/unit/transformers/pii/test_anonymizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,14 @@ def test__function_cardinality_rule_none(self):
function.assert_called_once_with(type='int')
assert result == 1

def test___init___enforce_uniqueness_exists(self):
"""Test `enforce_uniqueness` attribute exists."""
# Run
instance = AnonymizedFaker()

# Assert
assert instance.enforce_uniqueness is False

def test__function_cardinality_rule_unique(self):
"""Test that ``_function`` uses the ``faker.unique``.
Expand Down

0 comments on commit 7850f50

Please sign in to comment.