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

Unified Diff: client/tests/cipdserver_mock.py

Issue 2037253002: run_isolated.py: install CIPD packages (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-py@master
Patch Set: Created 4 years, 6 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
Index: client/tests/cipdserver_mock.py
diff --git a/client/tests/cipdserver_mock.py b/client/tests/cipdserver_mock.py
new file mode 100644
index 0000000000000000000000000000000000000000..97f6e8fd2fc4b8eeca54e194e782dcd797857265
--- /dev/null
+++ b/client/tests/cipdserver_mock.py
@@ -0,0 +1,45 @@
+# Copyright 2014 The LUCI Authors. All rights reserved.
+# Use of this source code is governed under the Apache License, Version 2.0
+# that can be found in the LICENSE file.
+
+import logging
+
+import httpserver_mock
+
+
+class CipdServerHandler(httpserver_mock.MockHandler):
+ """An extremely minimal implementation of the cipd server API v1.0."""
+
+ ### Mocked HTTP Methods
+
+ def do_GET(self):
+ logging.info('GET %s', self.path)
+ if self.path in ('/on/load', '/on/quit'):
+ self._octet_stream('')
+ elif self.path == '/auth/api/v1/server/oauth_config':
+ self._json({
+ 'client_id': 'c',
+ 'client_not_so_secret': 's',
+ 'primary_url': self.server.url})
+ elif self.path.startswith('/_ah/api/repo/v1/instance/resolve?'):
+ self._json({
+ 'status': 'SUCCESS',
+ 'instance_id': 'a' * 40,
+ })
+ elif self.path.startswith('/_ah/api/repo/v1/client?'):
+ self._json({
+ 'status': 'SUCCESS',
+ 'client_binary': {
+ 'fetch_url': self.server.url + '/fake_google_storage/cipd_client',
+ },
+ })
+ elif self.path == '/fake_google_storage/cipd_client':
+ # The content is not actually used because run_isolated_test.py
+ # mocks popen.
+ self._octet_stream('#!/usr/sh\n')
+ else:
+ raise NotImplementedError(self.path)
+
+
+class MockCipdServer(httpserver_mock.MockServer):
+ _HANDLER_CLS = CipdServerHandler

Powered by Google App Engine
This is Rietveld 408576698