Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1472)

Unified Diff: recipe_engine/third_party/client-py/libs/logdog/tests/streamname_test.py

Issue 2265673002: Add LogDog / annotation protobuf support. (Closed) Base URL: https://github.com/luci/recipes-py@step-formal-struct
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: recipe_engine/third_party/client-py/libs/logdog/tests/streamname_test.py
diff --git a/recipe_engine/third_party/client-py/libs/logdog/tests/streamname_test.py b/recipe_engine/third_party/client-py/libs/logdog/tests/streamname_test.py
index f5898a4fe02825e83dc9dfa73a360646aa37bb52..c84292a6554a30417868d8ed57089a6afd84c422 100755
--- a/recipe_engine/third_party/client-py/libs/logdog/tests/streamname_test.py
+++ b/recipe_engine/third_party/client-py/libs/logdog/tests/streamname_test.py
@@ -43,6 +43,24 @@ class StreamNameTestCase(unittest.TestCase):
raised = True
self.assertFalse(raised, "Stream name '%s' raised ValueError" % (name,))
+ def testNormalize(self):
+ for name, normalized in (
+ ('', 'PFX'),
+ ('_invalid_start_char', 'PFX_invalid_start_char'),
+ ('valid_stream_name.1:2-3', 'valid_stream_name.1:2-3'),
+ ('some stream (with stuff)', 'some_stream__with_stuff_'),
+ ('_invalid/st!ream/name entry', 'PFX_invalid/st_ream/name_entry'),
+ (' ', 'PFX_____'),
+ ):
+ self.assertEqual(streamname.normalize(name, prefix='PFX'), normalized)
+
+ # Assert that an empty stream name with no prefix will raise a ValueError.
+ self.assertRaises(ValueError, streamname.normalize, '')
+
+ # Assert that a stream name with an invalid starting character and no prefix
+ # will raise a ValueError.
+ self.assertRaises(ValueError, streamname.normalize, '_invalid_start_char')
+
if __name__ == '__main__':
unittest.main()

Powered by Google App Engine
This is Rietveld 408576698