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

Side by Side Diff: recipe_engine/third_party/client-py/libs/logdog/tests/streamname_test.py

Issue 2265673002: Add LogDog / annotation protobuf support. (Closed) Base URL: https://github.com/luci/recipes-py@step-formal-struct
Patch Set: Created 4 years, 4 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 unified diff | Download patch
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2016 The LUCI Authors. All rights reserved. 2 # Copyright 2016 The LUCI Authors. All rights reserved.
3 # Use of this source code is governed under the Apache License, Version 2.0 3 # Use of this source code is governed under the Apache License, Version 2.0
4 # that can be found in the LICENSE file. 4 # that can be found in the LICENSE file.
5 5
6 import os 6 import os
7 import sys 7 import sys
8 import unittest 8 import unittest
9 import StringIO 9 import StringIO
10 10
(...skipping 25 matching lines...) Expand all
36 'foo/bar', 36 'foo/bar',
37 'f123/four/five-_.:', 37 'f123/four/five-_.:',
38 ): 38 ):
39 raised = False 39 raised = False
40 try: 40 try:
41 streamname.validate_stream_name(name) 41 streamname.validate_stream_name(name)
42 except ValueError: 42 except ValueError:
43 raised = True 43 raised = True
44 self.assertFalse(raised, "Stream name '%s' raised ValueError" % (name,)) 44 self.assertFalse(raised, "Stream name '%s' raised ValueError" % (name,))
45 45
46 def testNormalize(self):
47 for name, normalized in (
48 ('', 'PFX'),
49 ('_invalid_start_char', 'PFX_invalid_start_char'),
50 ('valid_stream_name.1:2-3', 'valid_stream_name.1:2-3'),
51 ('some stream (with stuff)', 'some_stream__with_stuff_'),
52 ('_invalid/st!ream/name entry', 'PFX_invalid/st_ream/name_entry'),
53 (' ', 'PFX_____'),
54 ):
55 self.assertEqual(streamname.normalize(name, prefix='PFX'), normalized)
56
57 # Assert that an empty stream name with no prefix will raise a ValueError.
58 self.assertRaises(ValueError, streamname.normalize, '')
59
60 # Assert that a stream name with an invalid starting character and no prefix
61 # will raise a ValueError.
62 self.assertRaises(ValueError, streamname.normalize, '_invalid_start_char')
63
46 64
47 if __name__ == '__main__': 65 if __name__ == '__main__':
48 unittest.main() 66 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698