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

Side by Side 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: simplified closing of list file 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 unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright 2014 The LUCI Authors. All rights reserved.
2 # Use of this source code is governed under the Apache License, Version 2.0
3 # that can be found in the LICENSE file.
4
5 import logging
6
7 import httpserver_mock
8
9
10 class CipdServerHandler(httpserver_mock.MockHandler):
11 """An extremely minimal implementation of the cipd server API v1.0."""
12
13 ### Mocked HTTP Methods
14
15 def do_GET(self):
16 logging.info('GET %s', self.path)
17 if self.path in ('/on/load', '/on/quit'):
18 self._octet_stream('')
19 elif self.path == '/auth/api/v1/server/oauth_config':
20 self._json({
21 'client_id': 'c',
22 'client_not_so_secret': 's',
23 'primary_url': self.server.url})
24 elif self.path.startswith('/_ah/api/repo/v1/instance/resolve?'):
25 self._json({
26 'status': 'SUCCESS',
27 'instance_id': 'a' * 40,
28 })
29 elif self.path.startswith('/_ah/api/repo/v1/client?'):
30 self._json({
31 'status': 'SUCCESS',
32 'client_binary': {
33 'fetch_url': self.server.url + '/fake_google_storage/cipd_client',
34 },
35 })
36 elif self.path == '/fake_google_storage/cipd_client':
37 # The content is not actually used because run_isolated_test.py
38 # mocks popen.
39 self._octet_stream('#!/usr/sh\n')
40 else:
41 raise NotImplementedError(self.path)
42
43
44 class MockCipdServer(httpserver_mock.MockServer):
45 _HANDLER_CLS = CipdServerHandler
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698