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

Unified Diff: client/libs/logdog/tests/streamname_test.py

Issue 1961603002: Add LogDog Python client library. (Closed) Base URL: https://github.com/luci/luci-py@master
Patch Set: Created 4 years, 7 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: client/libs/logdog/tests/streamname_test.py
diff --git a/client/libs/logdog/tests/streamname_test.py b/client/libs/logdog/tests/streamname_test.py
new file mode 100644
index 0000000000000000000000000000000000000000..94a895d4366fd29afbf289666f3202abc56d6f6f
--- /dev/null
+++ b/client/libs/logdog/tests/streamname_test.py
@@ -0,0 +1,46 @@
+# Copyright 2016 The LUCI Authors. All rights reserved.
+# Use of this source code is governed by the Apache v2.0 license that can be
+# found in the LICENSE file.
+
+import unittest
+import itertools
+import StringIO
+
+from client.libs.logdog import streamname
+
+
+class StreamNameTestCase(unittest.TestCase):
+
+ def testInvalidStreamNamesRaiseValueError(self):
+ for name in (
+ '',
+ 'a' * (streamname._MAX_STREAM_NAME_LENGTH+1),
+ ' s p a c e s ',
+ '-hyphen',
+ 'stream/path/+/not/name',
+ ):
+ raised = False
+ try:
+ streamname.validate_stream_name(name)
+ except ValueError:
+ raised = True
+ self.assertTrue(raised, "Stream name '%s' did not raise ValueError" % (
martiniss 2016/05/10 22:12:38 you can do `with self.assertRaises(ValueError)` in
dnj (Google) 2016/05/12 17:54:03 Done.
+ name,))
+
+ def testValidStreamNamesDoNotRaise(self):
+ for name in (
+ 'a',
+ 'a' * (streamname._MAX_STREAM_NAME_LENGTH),
+ 'foo/bar',
+ 'f123/four/five-_.:',
+ ):
+ raised = False
+ try:
+ streamname.validate_stream_name(name)
+ except ValueError:
+ raised = True
+ self.assertFalse(raised, "Stream name '%s' raised ValueError" % (name,))
+
+
+if __name__ == '__main__':
+ unittest.main()

Powered by Google App Engine
This is Rietveld 408576698