mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-10-11 00:35:22 +00:00

* Add PIICategoryTags and some utilities on top of them. * Fix static-check * Add test for fqn representation * Add NEREntityGeneralTags.json from Collate * Add test to check PIICategoryTags agree with the ones used by OM server * Add LabelExtractor * Fix style * Add ignore superflous-parens for pylint * Ass comment as per PR review * Fix not-updated PII-IT * Remove duplicated IT test for PII --------- Co-authored-by: Pere Menal <pere.menal@getcollate.io> Co-authored-by: Sriharsha Chintalapani <harshach@users.noreply.github.com>
34 lines
1.3 KiB
Python
34 lines
1.3 KiB
Python
from metadata.generated.schema.type.tagLabel import LabelType, TagSource
|
|
from metadata.pii.algorithms.tags import PIICategoryTag, PIISensitivityTag
|
|
from metadata.pii.processor import get_tag_label
|
|
|
|
|
|
def test_get_general_tag_label_from_pii_tag_category():
|
|
"""
|
|
Test that the general tag FQN from a tag category never fails.
|
|
"""
|
|
for tag in PIICategoryTag:
|
|
try:
|
|
tag_label = get_tag_label(tag)
|
|
assert tag_label.tagFQN.root == f"General.{tag.value}"
|
|
assert tag_label.source == TagSource.Classification
|
|
assert tag_label.labelType == LabelType.Generated
|
|
except ValueError:
|
|
raise AssertionError(f"Failed to get general tag FQN for tag {tag}.")
|
|
|
|
|
|
def test_get_general_tag_label_from_pii_sensitivity():
|
|
"""
|
|
Test that the general tag FQN from a PII sensitivity never fails.
|
|
"""
|
|
for tag in PIISensitivityTag:
|
|
try:
|
|
tag_label = get_tag_label(tag)
|
|
assert tag_label.tagFQN.root == f"PII.{tag.value}"
|
|
assert tag_label.source == TagSource.Classification
|
|
assert tag_label.labelType == LabelType.Generated
|
|
except ValueError:
|
|
raise AssertionError(
|
|
f"Failed to get general tag FQN for sensitivity {tag}."
|
|
)
|