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

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: Remove "client." from package name, make pylint happy. 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
« no previous file with comments | « client/libs/logdog/tests/stream_test.py ('k') | client/libs/logdog/tests/varint_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 100755
index 0000000000000000000000000000000000000000..92c91a4e15b18bd4520e7186e644d1dcc6438303
--- /dev/null
+++ b/client/libs/logdog/tests/streamname_test.py
@@ -0,0 +1,47 @@
+#!/usr/bin/env python
+# 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 os
+import sys
+import unittest
+import StringIO
+
+ROOT_DIR = os.path.dirname(os.path.abspath(os.path.join(
+ __file__, os.pardir, os.pardir, os.pardir)))
+sys.path.insert(0, ROOT_DIR)
+
+from 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',
+ ):
+ with self.assertRaises(ValueError):
+ streamname.validate_stream_name(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()
« no previous file with comments | « client/libs/logdog/tests/stream_test.py ('k') | client/libs/logdog/tests/varint_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698