| OLD | NEW |
| (Empty) | |
| 1 # Copyright 2016 The LUCI Authors. All rights reserved. |
| 2 # Use of this source code is governed by the Apache v2.0 license that can be |
| 3 # found in the LICENSE file. |
| 4 |
| 5 import unittest |
| 6 import itertools |
| 7 import StringIO |
| 8 |
| 9 from client.libs.logdog import streamname |
| 10 |
| 11 |
| 12 class StreamNameTestCase(unittest.TestCase): |
| 13 |
| 14 def testInvalidStreamNamesRaiseValueError(self): |
| 15 for name in ( |
| 16 '', |
| 17 'a' * (streamname._MAX_STREAM_NAME_LENGTH+1), |
| 18 ' s p a c e s ', |
| 19 '-hyphen', |
| 20 'stream/path/+/not/name', |
| 21 ): |
| 22 with self.assertRaises(ValueError): |
| 23 streamname.validate_stream_name(name) |
| 24 |
| 25 def testValidStreamNamesDoNotRaise(self): |
| 26 for name in ( |
| 27 'a', |
| 28 'a' * (streamname._MAX_STREAM_NAME_LENGTH), |
| 29 'foo/bar', |
| 30 'f123/four/five-_.:', |
| 31 ): |
| 32 raised = False |
| 33 try: |
| 34 streamname.validate_stream_name(name) |
| 35 except ValueError: |
| 36 raised = True |
| 37 self.assertFalse(raised, "Stream name '%s' raised ValueError" % (name,)) |
| 38 |
| 39 |
| 40 if __name__ == '__main__': |
| 41 unittest.main() |
| OLD | NEW |