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

Metadata tag whitespace proposed solution #2538

Merged
Merged
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
8 changes: 8 additions & 0 deletions elyra/metadata/schemas/airflow.json
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,15 @@
"tags": {
"title": "Tags",
"description": "Tags for categorizing Apache Airflow",
"uniqueItems": true,
"type": "array",
"items": {
"allOf": [
{ "minLength": 1 },
{ "pattern": "^[^ \t]+" },
{ "pattern": "[^ \t]+$" }
]
},
"uihints": {
"field_type": "tags"
}
Expand Down
8 changes: 8 additions & 0 deletions elyra/metadata/schemas/code-snippet.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@
"title": "Tags",
"description": "Tags for categorizing snippets",
"type": "array",
"uniqueItems": true,
"items": {
"allOf": [
{ "minLength": 1 },
{ "pattern": "^[^ \t]+" },
{ "pattern": "[^ \t]+$" }
]
},
"uihints": {
"field_type": "tags"
}
Expand Down
8 changes: 8 additions & 0 deletions elyra/metadata/schemas/kfp.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,15 @@
"tags": {
"title": "Tags",
"description": "Tags for categorizing Kubeflow pipelines",
"uniqueItems": true,
"type": "array",
"items": {
"allOf": [
{ "minLength": 1 },
{ "pattern": "^[^ \t]+" },
{ "pattern": "[^ \t]+$" }
]
},
"uihints": {
"field_type": "tags"
}
Expand Down
10 changes: 10 additions & 0 deletions elyra/metadata/schemas/metadata-test.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,16 @@
"type": "string",
"pattern": "^[a-z0-9][a-z0-9-.]*[a-z0-9]$"
},
"string_complex_test": {
"title": "String Complex Test",
"description": "Property used to test strings with multiple restrictions",
"type": "string",
"allOf": [
{ "minLength": 1 },
{ "pattern": "^[^ \t]+" },
{ "pattern": "[^ \t]+$" }
]
},
"enum_test": {
"title": "Enum Test",
"description": "Property used to test properties with enums",
Expand Down
8 changes: 8 additions & 0 deletions elyra/metadata/schemas/runtime-image.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,15 @@
"tags": {
"title": "Tags",
"description": "Tags for categorizing runtime images",
"uniqueItems": true,
"type": "array",
"items": {
"allOf": [
{ "minLength": 1 },
{ "pattern": "^[^ \t]+" },
{ "pattern": "[^ \t]+$" }
]
},
"uihints": {
"field_type": "tags"
}
Expand Down
34 changes: 34 additions & 0 deletions elyra/tests/metadata/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,40 @@ def test_manager_add_display_name(tests_manager, schemaspace_location):
tests_manager.metadata_store.fetch_instances(metadata_name)


@pytest.mark.parametrize(
"complex_string, valid",
[
("", False),
(" ", False),
(" starting-whitespace", False),
("ending-whitespace ", False),
(" whitespace-both-ends ", False),
("whitespace in between", True),
("no-whitespace", True),
],
)
def test_manager_complex_string_schema(tests_manager, schemaspace_location, complex_string, valid):
metadata_name = "valid_metadata_instance"
metadata_dict = {**valid_metadata_json}
metadata_dict["metadata"]["string_complex_test"] = complex_string
metadata = Metadata.from_dict(METADATA_TEST_SCHEMASPACE_ID, metadata_dict)

if not valid:
with pytest.raises(ValidationError):
tests_manager.create(metadata_name, metadata)

else:
instance = tests_manager.create(metadata_name, metadata)
assert instance.metadata.get("string_complex_test") == complex_string

# And finally, remove it.
tests_manager.remove(metadata_name)

# Verify removal using metadata_store
with pytest.raises(MetadataNotFoundError):
tests_manager.metadata_store.fetch_instances(metadata_name)


def test_manager_get_include_invalid(tests_manager):
metadata_list = tests_manager.get_all(include_invalid=False)
assert len(metadata_list) == 2
Expand Down