def request_fake_pushdata(self): first_push = self.make_push_dict(self.push_data[0]) first_request = self.make_request_dict(self.request_data[0]) first_request["tags"] = "buildbot" second_request = self.make_request_dict(self.request_data[1]) # Prepare pushdata the way PushServlet accepts. This is the # format API also replies to pushdata requests. pushinfo = util.push_to_jsonable(first_push) requests = { first_request["state"]: [util.request_to_jsonable(first_request)], "all": [util.request_to_jsonable(first_request)], } available_requests = [util.request_to_jsonable(second_request)] pushdata = [pushinfo, requests, available_requests] with contextlib.nested( mock.patch.object(PushServlet, "get_current_user", return_value="testuser"), mock.patch.object(PushServlet, "async_api_call", side_effect=self.mocked_api_call), mock.patch.object(self, "api_response", return_value=json.dumps(pushdata)), ): self.fetch("/push?id=%d" % first_push["id"]) response = self.wait() yield pushdata, response
def request_fake_pushdata(self): first_push = self.make_push_dict(self.push_data[0]) first_request = self.make_request_dict(self.request_data[0]) first_request['tags'] = "buildbot" second_request = self.make_request_dict(self.request_data[1]) # Prepare pushdata the way PushServlet accepts. This is the # format API also replies to pushdata requests. pushinfo = util.push_to_jsonable(first_push) requests = { first_request['state']: [util.request_to_jsonable(first_request)], 'all': [util.request_to_jsonable(first_request)] } available_requests = [util.request_to_jsonable(second_request)] pushdata = [pushinfo, requests, available_requests] with contextlib.nested( mock.patch.object(PushServlet, "get_current_user", return_value="testuser"), mock.patch.object(PushServlet, "async_api_call", side_effect=self.mocked_api_call), mock.patch.object(self, "api_response", return_value=json.dumps(pushdata))): self.fetch("/push?id=%d" % first_push['id']) response = self.wait() yield pushdata, response
def _on_PUSHCONTENTS_db_response(self, success, db_results): self.check_db_results(success, db_results) requests = [ util.request_to_jsonable(request) for request in db_results ] return self._xjson(requests)
def _on_REQUEST_db_response(self, success, db_results): self.check_db_results(success, db_results) request = db_results.first() if not request: return self.send_error(404) else: return self._xjson(util.request_to_jsonable(request))
def _on_REQUESTSEARCH_db_response(self, success, db_results): if not success: return self.send_error(500) requests = [ util.request_to_jsonable(request) for request in db_results ] return self._xjson(requests)
def _on_PUSHDATA_db_response(self, success, db_results): self.check_db_results(success, db_results) push_info, push_contents, available_requests = db_results push_info = push_info.first() if not push_info: return self.send_error(404) push_info = util.push_to_jsonable(push_info) available_requests = [util.request_to_jsonable(r) for r in available_requests.fetchall()] push_requests = {} for request in push_contents: request = util.request_to_jsonable(request) push_requests.setdefault(request['state'], []).append(request) push_requests.setdefault('all', []).append(request) return self._xjson([push_info, push_requests, available_requests])
def _on_PUSHDATA_db_response(self, success, db_results): self.check_db_results(success, db_results) push_info, push_contents, available_requests = db_results push_info = push_info.first() if not push_info: return self.send_error(404) push_info = util.push_to_jsonable(push_info) available_requests = [ util.request_to_jsonable(r) for r in available_requests.fetchall() ] push_requests = {} for request in push_contents: request = util.request_to_jsonable(request) push_requests.setdefault(request['state'], []).append(request) push_requests.setdefault('all', []).append(request) return self._xjson([push_info, push_requests, available_requests])
def _on_REQUESTSEARCH_db_response(self, success, db_results): if not success: return self.send_error(500) requests = [util.request_to_jsonable(request) for request in db_results] return self._xjson(requests)
def _on_PUSHITEMS_db_response(self, success, db_results): self.check_db_results(success, db_results) return self._xjson([util.request_to_jsonable(request) for request in db_results])