feat(SIMPL-24642): migrate tests from 3 source repos with updated imports
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
import pytest
|
||||
from pydantic import ValidationError
|
||||
|
||||
from template_code_location.dataframe_level_anonymisation.config_models.base_config import BaseConfiguration
|
||||
|
||||
|
||||
def test_valid_configuration_with_overrides():
|
||||
cfg = BaseConfiguration(
|
||||
ident=["id"],
|
||||
quasi_identifiers=["age"],
|
||||
supp_level=10.0,
|
||||
generalisation_hierarchies={"age": "age_hierarchy"},
|
||||
)
|
||||
assert cfg.ident == ["id"]
|
||||
assert cfg.quasi_identifiers == ["age"]
|
||||
assert cfg.supp_level == 10.0
|
||||
assert cfg.generalisation_hierarchies == {"age": "age_hierarchy"}
|
||||
|
||||
|
||||
def test_default_values_are_loaded():
|
||||
cfg = BaseConfiguration()
|
||||
assert cfg.ident == ["Name"]
|
||||
assert cfg.quasi_identifiers == ["Age"]
|
||||
assert cfg.supp_level == 50.0
|
||||
assert cfg.generalisation_hierarchies == {"Age": "simpl_age"}
|
||||
|
||||
|
||||
def test_missing_ident_raises_error():
|
||||
with pytest.raises(ValidationError):
|
||||
BaseConfiguration(
|
||||
ident=[]
|
||||
)
|
||||
|
||||
|
||||
def test_missing_quasi_ident_raises_error():
|
||||
with pytest.raises(ValidationError):
|
||||
BaseConfiguration(
|
||||
quasi_identifiers=[]
|
||||
)
|
||||
|
||||
|
||||
def test_overlap_between_ident_and_quasi_identifiers():
|
||||
with pytest.raises(ValidationError):
|
||||
BaseConfiguration(
|
||||
ident=["age"],
|
||||
quasi_identifiers=["age"]
|
||||
)
|
||||
|
||||
|
||||
def test_supp_level_bounds():
|
||||
with pytest.raises(ValidationError):
|
||||
BaseConfiguration(
|
||||
supp_level=150.0 # fuori range
|
||||
)
|
||||
Reference in New Issue
Block a user