Skip to content
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

HA-415 - Adding new data_types: time, date and datetime #26

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/fideslang/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ def parse_data_type_string(type_string: Optional[str]) -> Tuple[Optional[str], b
"boolean",
"object_id",
"object",
"time",
"date",
"datetime",
}


Expand Down
33 changes: 33 additions & 0 deletions tests/fideslang/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,39 @@ def test_valid_length(self):


class TestValidateDatasetField:

@pytest.mark.parametrize("data_type", ["string", "integer", "float", "boolean", "object", "time", "date", "datetime"])
def test_valid_types(self, data_type):
field = DatasetField(
name="test_field",
fides_meta=FidesMeta(
references=None,
identity="identifiable_field_name",
primary_key=False,
data_type=data_type,
length=None,
return_all_elements=None,
read_only=None,
),
)
assert field.fides_meta.data_type == data_type

@pytest.mark.parametrize("data_type", ["not_string", "not_integer", "not_float", "not_boolean", "not_object", "not_time", "not_date", "not_datetime"])
def test_invalid_types(self, data_type):
Comment on lines +703 to +704

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't seem to be using the data_type argument in this test, unless I'm missing something?

field = DatasetField(
name="test_field",
fides_meta=FidesMeta(
references=None,
identity="identifiable_field_name",
primary_key=False,
data_type="string",
length=None,
return_all_elements=None,
read_only=None,
),
)
assert field.fides_meta.data_type == "string"

def test_return_all_elements_not_array_field(self):
with pytest.raises(ValidationError) as exc:
DatasetField(
Expand Down
Loading