Skip to content

Commit

Permalink
unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: Ketan Umare <[email protected]>
  • Loading branch information
kumare3 committed Oct 15, 2021
1 parent 2c450a6 commit c777360
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion flytekit/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from flytekit.models.core import identifier as _identifier


def _dnsify(value): # type: (str) -> str
def _dnsify(value: str) -> str:
"""
Converts value into a DNS-compliant (RFC1035/RFC1123 DNS_LABEL). The resulting string must only consist of
alphanumeric (lower-case a-z, and 0-9) and not exceed 63 characters. It's permitted to have '-' character as long
Expand Down
2 changes: 1 addition & 1 deletion flytekit/core/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def name(self) -> str:

@property
def short_name(self) -> str:
return self._name.split(".")[-1]
return extract_obj_name(self._name)

@property
def workflow_metadata(self) -> Optional[WorkflowMetadata]:
Expand Down
22 changes: 22 additions & 0 deletions tests/flytekit/unit/common_tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import pytest

from flytekit.common.utils import _dnsify


@pytest.mark.parametrize(
"input,expected",
[
("test.abc", "test-abc"),
("test", "test"),
("", ""),
(".test", "test"),
("Test", "test"),
("test.", "test"),
("test-", "test"),
("test$", "test"),
("te$t$", "tet"),
("t" * 64, f"da4b348ebe-{'t'*52}"),
],
)
def test_dnsify(input, expected):
assert _dnsify(input) == expected

0 comments on commit c777360

Please sign in to comment.