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

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

Issue 2453273002: Update LogDog client library to generate URLs. (Closed)
Patch Set: Forgot project, oops. Addressed nits. Created 4 years, 1 month 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
« no previous file with comments | « client/libs/logdog/tests/stream_test.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 self.assertEqual(streamname.normalize(name, prefix='PFX'), normalized) 55 self.assertEqual(streamname.normalize(name, prefix='PFX'), normalized)
56 56
57 # Assert that an empty stream name with no prefix will raise a ValueError. 57 # Assert that an empty stream name with no prefix will raise a ValueError.
58 self.assertRaises(ValueError, streamname.normalize, '') 58 self.assertRaises(ValueError, streamname.normalize, '')
59 59
60 # Assert that a stream name with an invalid starting character and no prefix 60 # Assert that a stream name with an invalid starting character and no prefix
61 # will raise a ValueError. 61 # will raise a ValueError.
62 self.assertRaises(ValueError, streamname.normalize, '_invalid_start_char') 62 self.assertRaises(ValueError, streamname.normalize, '_invalid_start_char')
63 63
64 64
65 class StreamPathTestCase(unittest.TestCase):
66
67 def testParseValidPath(self):
68 for path in (
69 'foo/+/bar',
70 'foo/bar/+/baz',
71 ):
72 prefix, name = path.split('/+/')
73 parsed = streamname.StreamPath.parse(path)
74 self.assertEqual(
75 parsed,
76 streamname.StreamPath(prefix=prefix, name=name))
77 self.assertEqual(str(parsed), path)
78
79 def testParseInvalidValidPathRaisesValueError(self):
80 for path in (
81 '',
82 'foo/+',
83 'foo/+/',
84 '+/bar',
85 '/+/bar',
86 'foo/bar',
87 '!!!invalid!!!/+/bar',
88 'foo/+/!!!invalid!!!',
89 ):
90 with self.assertRaises(ValueError):
91 streamname.StreamPath.parse(path)
92
93 def testLogDogViewerUrl(self):
94 for project, path, url in (
95 ('test', streamname.StreamPath(prefix='foo', name='bar/baz'),
96 'https://example.appspot.com/v/?s=test%2Ffoo%2F%2B%2Fbar%2Fbaz'),
97
98 ('test', streamname.StreamPath(prefix='foo', name='bar/**'),
99 'https://example.appspot.com/v/?s=test%2Ffoo%2F%2B%2Fbar%2F%2A%2A'),
100
101 ('test', streamname.StreamPath(prefix='**', name='**'),
102 'https://example.appspot.com/v/?s=test%2F%2A%2A%2F%2B%2F%2A%2A'),
103 ):
104 self.assertEqual(
105 streamname.get_logdog_viewer_url('example.appspot.com', project,
106 path),
107 url)
108
109 # Multiple streams.
110 self.assertEqual(
111 streamname.get_logdog_viewer_url('example.appspot.com', 'test',
112 streamname.StreamPath(prefix='foo', name='bar/baz'),
113 streamname.StreamPath(prefix='qux', name='**'),
114 ),
115 ('https://example.appspot.com/v/?s=test%2Ffoo%2F%2B%2Fbar%2Fbaz&'
116 's=test%2Fqux%2F%2B%2F%2A%2A'))
117
118
65 if __name__ == '__main__': 119 if __name__ == '__main__':
66 unittest.main() 120 unittest.main()
OLDNEW
« no previous file with comments | « client/libs/logdog/tests/stream_test.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698