-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HJ-20 save data categories nested fields #22
Changes from all commits
e290bfb
6443566
81e96eb
a0ef7a1
a445b8b
f19d678
21eb174
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
"""Common fixtures to be used across tests.""" | ||
|
||
import os | ||
from typing import Any, Dict | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -717,59 +717,61 @@ def test_return_all_elements_on_array_field(self): | |
) | ||
|
||
def test_data_categories_at_object_level(self): | ||
with pytest.raises(ValidationError) as exc: | ||
DatasetField( | ||
name="test_field", | ||
data_categories=["user"], | ||
fides_meta=FidesMeta( | ||
references=None, | ||
identify=None, | ||
primary_key=False, | ||
data_type="object", | ||
length=None, | ||
return_all_elements=None, | ||
read_only=None, | ||
), | ||
fields=[DatasetField(name="nested_field")], | ||
) | ||
assert_error_message_includes( | ||
exc, "Object field 'test_field' cannot have specified data_categories" | ||
) | ||
|
||
def test_object_field_conflicting_types(self): | ||
with pytest.raises(ValidationError) as exc: | ||
DatasetField( | ||
name="test_field", | ||
data_categories=["user"], | ||
fides_meta=FidesMeta( | ||
references=None, | ||
identify=None, | ||
primary_key=False, | ||
data_type="string", | ||
length=None, | ||
return_all_elements=None, | ||
read_only=None, | ||
), | ||
fields=[DatasetField(name="nested_field")], | ||
) | ||
assert_error_message_includes( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we want users to add data categories to the "non-terminal" nested fields (middle fields, or top level) then this validation needs to be removed and the reverse of this test is now the case |
||
exc, "The data type 'string' on field 'test_field' is not compatible with" | ||
field = DatasetField( | ||
name="test_field", | ||
data_categories=["user"], | ||
fides_meta=FidesMeta( | ||
references=None, | ||
identify=None, | ||
primary_key=False, | ||
data_type="object", | ||
length=None, | ||
return_all_elements=None, | ||
read_only=None, | ||
), | ||
fields=[DatasetField(name="nested_field")], | ||
) | ||
|
||
assert field | ||
assert field.data_categories == ["user"] | ||
assert field.fides_meta.data_type == "object" | ||
|
||
def test_data_categories_on_nested_fields(self): | ||
DatasetField( | ||
name="test_field", | ||
|
||
field = DatasetField( | ||
name="test_for_nest", | ||
data_categories=["user"], | ||
fides_meta=FidesMeta( | ||
references=None, | ||
identify=None, | ||
primary_key=False, | ||
data_type="object", | ||
length=None, | ||
return_all_elements=None, | ||
read_only=None, | ||
), | ||
fields=[DatasetField(name="nested_field", data_categories=["user"])], | ||
fields=[ | ||
DatasetField( | ||
name="nested_field", | ||
data_categories=["user"], | ||
fides_meta=FidesMeta( | ||
references=None, | ||
identify=None, | ||
primary_key=False, | ||
data_type="string", | ||
length=None, | ||
read_only=None, | ||
data_categories=["user"], | ||
), | ||
) | ||
], | ||
) | ||
|
||
assert field | ||
assert field.data_categories == ["user"] | ||
assert field.fields[0].data_categories == ["user"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. real test here, a nested field can in fact have a category |
||
|
||
|
||
class TestCollectionMeta: | ||
def test_invalid_collection_key(self): | ||
|
@@ -806,7 +808,6 @@ def test_erase_after(self): | |
assert meta.erase_after == [FidesCollectionKey("test_dataset.test_collection")] | ||
|
||
|
||
|
||
class TestAnyUrlString: | ||
def test_valid_url(self): | ||
assert AnyUrlString("https://www.example.com/") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
autoformatter