-
Notifications
You must be signed in to change notification settings - Fork 791
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
57 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import re | ||
from metaflow.plugins.aws.eks.kubernetes import sanitize_label_value, LABEL_VALUE_REGEX | ||
|
||
|
||
def test_label_value_santitizer(): | ||
assert LABEL_VALUE_REGEX.match(sanitize_label_value('HelloFlow')) | ||
|
||
# The value is too long | ||
assert LABEL_VALUE_REGEX.match(sanitize_label_value('a' * 1000)) | ||
|
||
# Different long values should still not be equal after sanitization | ||
assert sanitize_label_value('a' * 1000) != sanitize_label_value('a' * 1001) | ||
assert sanitize_label_value('-' * 1000) != sanitize_label_value('-' * 1001) | ||
|
||
# Different long values should still not be equal after sanitization | ||
assert sanitize_label_value('alice!') != sanitize_label_value('alice?') | ||
|
||
# ends with dash | ||
assert LABEL_VALUE_REGEX.match(sanitize_label_value('HelloFlow-')) | ||
|
||
# non-ascii | ||
assert LABEL_VALUE_REGEX.match(sanitize_label_value('метафлоу')) | ||
|
||
# different only in case | ||
assert sanitize_label_value('Alice') != sanitize_label_value('alice') | ||
|
||
# spaces | ||
assert LABEL_VALUE_REGEX.match(sanitize_label_value('Meta flow')) |