Chromium Code Reviews| 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 raised = False | |
| 23 try: | |
| 24 streamname.validate_stream_name(name) | |
| 25 except ValueError: | |
| 26 raised = True | |
| 27 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.
| |
| 28 name,)) | |
| 29 | |
| 30 def testValidStreamNamesDoNotRaise(self): | |
| 31 for name in ( | |
| 32 'a', | |
| 33 'a' * (streamname._MAX_STREAM_NAME_LENGTH), | |
| 34 'foo/bar', | |
| 35 'f123/four/five-_.:', | |
| 36 ): | |
| 37 raised = False | |
| 38 try: | |
| 39 streamname.validate_stream_name(name) | |
| 40 except ValueError: | |
| 41 raised = True | |
| 42 self.assertFalse(raised, "Stream name '%s' raised ValueError" % (name,)) | |
| 43 | |
| 44 | |
| 45 if __name__ == '__main__': | |
| 46 unittest.main() | |
| OLD | NEW |