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

Unified 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, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « client/libs/logdog/tests/stream_test.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
index c84292a6554a30417868d8ed57089a6afd84c422..25adfb6b9e024773fc23cf2616d544ad52d22178 100755
--- a/client/libs/logdog/tests/streamname_test.py
+++ b/client/libs/logdog/tests/streamname_test.py
@@ -62,5 +62,59 @@ class StreamNameTestCase(unittest.TestCase):
self.assertRaises(ValueError, streamname.normalize, '_invalid_start_char')
+class StreamPathTestCase(unittest.TestCase):
+
+ def testParseValidPath(self):
+ for path in (
+ 'foo/+/bar',
+ 'foo/bar/+/baz',
+ ):
+ prefix, name = path.split('/+/')
+ parsed = streamname.StreamPath.parse(path)
+ self.assertEqual(
+ parsed,
+ streamname.StreamPath(prefix=prefix, name=name))
+ self.assertEqual(str(parsed), path)
+
+ def testParseInvalidValidPathRaisesValueError(self):
+ for path in (
+ '',
+ 'foo/+',
+ 'foo/+/',
+ '+/bar',
+ '/+/bar',
+ 'foo/bar',
+ '!!!invalid!!!/+/bar',
+ 'foo/+/!!!invalid!!!',
+ ):
+ with self.assertRaises(ValueError):
+ streamname.StreamPath.parse(path)
+
+ def testLogDogViewerUrl(self):
+ for project, path, url in (
+ ('test', streamname.StreamPath(prefix='foo', name='bar/baz'),
+ 'https://example.appspot.com/v/?s=test%2Ffoo%2F%2B%2Fbar%2Fbaz'),
+
+ ('test', streamname.StreamPath(prefix='foo', name='bar/**'),
+ 'https://example.appspot.com/v/?s=test%2Ffoo%2F%2B%2Fbar%2F%2A%2A'),
+
+ ('test', streamname.StreamPath(prefix='**', name='**'),
+ 'https://example.appspot.com/v/?s=test%2F%2A%2A%2F%2B%2F%2A%2A'),
+ ):
+ self.assertEqual(
+ streamname.get_logdog_viewer_url('example.appspot.com', project,
+ path),
+ url)
+
+ # Multiple streams.
+ self.assertEqual(
+ streamname.get_logdog_viewer_url('example.appspot.com', 'test',
+ streamname.StreamPath(prefix='foo', name='bar/baz'),
+ streamname.StreamPath(prefix='qux', name='**'),
+ ),
+ ('https://example.appspot.com/v/?s=test%2Ffoo%2F%2B%2Fbar%2Fbaz&'
+ 's=test%2Fqux%2F%2B%2F%2A%2A'))
+
+
if __name__ == '__main__':
unittest.main()
« 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