Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hugorodgerbrown committed Sep 24, 2023
1 parent 327d210 commit 8441a68
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,27 @@ def test_model_fields_data(user_anonymiser: UserAnonymiser) -> None:
assert mfs.redaction_strategy == user_anonymiser.FieldRedactionStratgy.CUSTOM


@pytest.mark.parametrize(
"field_name,strategy",
[
("first_name", UserAnonymiser.FieldRedactionStratgy.CUSTOM),
# non-custom redactions of char fields
("last_name", UserAnonymiser.FieldRedactionStratgy.AUTO),
("biography", UserAnonymiser.FieldRedactionStratgy.AUTO),
("location", UserAnonymiser.FieldRedactionStratgy.AUTO),
# date / UUID not redacted automatically
("date_of_birth", UserAnonymiser.FieldRedactionStratgy.NONE),
("uuid", UserAnonymiser.FieldRedactionStratgy.NONE),
],
)
def test_model_fields_redaction_strategy(
field_name: str, strategy: str, user_anonymiser: UserAnonymiser
) -> None:
field = User._meta.get_field(field_name)
mfs = ModelFieldSummary(User, field, user_anonymiser)
assert mfs.redaction_strategy == strategy


@pytest.mark.django_db
class TestAnonymisableUserModel:
def test_anonymise_not_implemented(
Expand Down

0 comments on commit 8441a68

Please sign in to comment.