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

Unified Diff: client/libs/logdog/tests/bootstrap_test.py

Issue 1961603002: Add LogDog Python client library. (Closed) Base URL: https://github.com/luci/luci-py@master
Patch Set: Remove "client." from package name, make pylint happy. Created 4 years, 7 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/streamname.py ('k') | client/libs/logdog/tests/stream_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/libs/logdog/tests/bootstrap_test.py
diff --git a/client/libs/logdog/tests/bootstrap_test.py b/client/libs/logdog/tests/bootstrap_test.py
new file mode 100755
index 0000000000000000000000000000000000000000..a676546c79cb7defa1dea05d60be90434e8d5f91
--- /dev/null
+++ b/client/libs/logdog/tests/bootstrap_test.py
@@ -0,0 +1,54 @@
+#!/usr/bin/env python
+# Copyright 2016 The LUCI Authors. All rights reserved.
+# Use of this source code is governed by the Apache v2.0 license that can be
+# found in the LICENSE file.
+
+import os
+import sys
+import unittest
+
+ROOT_DIR = os.path.dirname(os.path.abspath(os.path.join(
+ __file__, os.pardir, os.pardir, os.pardir)))
+sys.path.insert(0, ROOT_DIR)
+
+from libs.logdog import bootstrap
+
+
+class BootstrapTestCase(unittest.TestCase):
+
+ def setUp(self):
+ self.env = {
+ bootstrap.ButlerBootstrap._ENV_PROJECT: 'test-project',
+ bootstrap.ButlerBootstrap._ENV_PREFIX: 'foo/bar',
+ bootstrap.ButlerBootstrap._ENV_STREAM_SERVER_PATH: 'fake:path',
+ }
+
+ def testProbeSucceeds(self):
+ bs = bootstrap.ButlerBootstrap.probe(self.env)
+ self.assertEqual(bs, bootstrap.ButlerBootstrap(
+ project='test-project',
+ prefix='foo/bar',
+ streamserver_uri='fake:path'))
+
+ def testProbeNoBootstrapRaisesError(self):
+ self.assertRaises(bootstrap.NotBootstrappedError,
+ bootstrap.ButlerBootstrap.probe, env={})
+
+ def testProbeMissingProjectRaisesError(self):
+ self.env.pop(bootstrap.ButlerBootstrap._ENV_PROJECT)
+ self.assertRaises(bootstrap.NotBootstrappedError,
+ bootstrap.ButlerBootstrap.probe, env=self.env)
+
+ def testProbeMissingPrefixRaisesError(self):
+ self.env.pop(bootstrap.ButlerBootstrap._ENV_PREFIX)
+ self.assertRaises(bootstrap.NotBootstrappedError,
+ bootstrap.ButlerBootstrap.probe, env=self.env)
+
+ def testProbeInvalidPrefixRaisesError(self):
+ self.env[bootstrap.ButlerBootstrap._ENV_PREFIX] = '!!! not valid !!!'
+ self.assertRaises(bootstrap.NotBootstrappedError,
+ bootstrap.ButlerBootstrap.probe, env=self.env)
+
+
+if __name__ == '__main__':
+ unittest.main()
« no previous file with comments | « client/libs/logdog/streamname.py ('k') | client/libs/logdog/tests/stream_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698