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

Unified Diff: client/tests/isolateserver_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: fix client fetching 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
« no previous file with comments | « client/tests/httpserver_mock.py ('k') | client/tests/run_isolated_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/tests/isolateserver_mock.py
diff --git a/client/tests/isolateserver_mock.py b/client/tests/isolateserver_mock.py
index 9d48ec83cd066f1b484a124ef9db5bb19b6df74b..7f803e2596e64e132a2bd53b9efc8c614a684a37 100644
--- a/client/tests/isolateserver_mock.py
+++ b/client/tests/isolateserver_mock.py
@@ -2,18 +2,15 @@
# Use of this source code is governed under the Apache License, Version 2.0
# that can be found in the LICENSE file.
-import BaseHTTPServer
import base64
import hashlib
import json
import logging
import re
-import sys
-import threading
-import urllib2
-import urlparse
import zlib
+import httpserver_mock
+
ALGO = hashlib.sha1
@@ -36,40 +33,7 @@ class FakeSigner(object):
return json.loads(a.groups()[0])
-class MockHandler(BaseHTTPServer.BaseHTTPRequestHandler):
- def _json(self, data):
- """Sends a JSON response."""
- self.send_response(200)
- self.send_header('Content-type', 'application/json')
- self.end_headers()
- json.dump(data, self.wfile)
-
- def _octet_stream(self, data):
- """Sends a binary response."""
- self.send_response(200)
- self.send_header('Content-type', 'application/octet-stream')
- self.end_headers()
- self.wfile.write(data)
-
- def _read_body(self):
- """Reads the request body."""
- return self.rfile.read(int(self.headers['Content-Length']))
-
- def _drop_body(self):
- """Reads the request body."""
- size = int(self.headers['Content-Length'])
- while size:
- chunk = min(4096, size)
- self.rfile.read(chunk)
- size -= chunk
-
- def log_message(self, fmt, *args):
- logging.info(
- '%s - - [%s] %s', self.address_string(), self.log_date_time_string(),
- fmt % args)
-
-
-class IsolateServerHandler(MockHandler):
+class IsolateServerHandler(httpserver_mock.MockHandler):
"""An extremely minimal implementation of the isolate server API v1.0."""
def _should_push_to_gs(self, isolated, size):
@@ -182,39 +146,7 @@ class IsolateServerHandler(MockHandler):
raise NotImplementedError(self.path)
-class MockServer(object):
- _HANDLER_CLS = None
-
- def __init__(self):
- self._closed = False
- self._server = BaseHTTPServer.HTTPServer(
- ('127.0.0.1', 0), self._HANDLER_CLS)
- self._server.url = self.url = 'http://localhost:%d' % (
- self._server.server_port)
- self._thread = threading.Thread(target=self._run, name='httpd')
- self._thread.daemon = True
- self._thread.start()
- logging.info('%s', self.url)
-
- def close(self):
- self.close_start()
- self.close_end()
-
- def close_start(self):
- assert not self._closed
- self._closed = True
- urllib2.urlopen(self.url + '/on/quit')
-
- def close_end(self):
- assert self._closed
- self._thread.join()
-
- def _run(self):
- while not self._closed:
- self._server.handle_request()
-
-
-class MockIsolateServer(MockServer):
+class MockIsolateServer(httpserver_mock.MockServer):
_HANDLER_CLS = IsolateServerHandler
def __init__(self):
« no previous file with comments | « client/tests/httpserver_mock.py ('k') | client/tests/run_isolated_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698