| 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()
|
|
|