MCPcopy Index your code
hub / github.com/bugy/script-server / handle_request

Method handle_request

src/tests/utils/mock_server.py:118–133  ·  view source on GitHub ↗
(self, request_handler: tornado.web.RequestHandler)

Source from the content-addressed store, hash-verified

116 return 'http://127.0.0.1:' + str(self._port)
117
118 def handle_request(self, request_handler: tornado.web.RequestHandler):
119 all_matches = []
120 for mock_handler in self.mock_handlers:
121 all_matches.append((mock_handler, mock_handler.match(request_handler)))
122
123 sorted_matches = sorted(all_matches, key=lambda x: (x[1].matches, x[1].match_count), reverse=True)
124
125 (most_suitable_handler, match_result) = sorted_matches[0]
126
127 if match_result.matches:
128 most_suitable_handler.handle(request_handler)
129 return
130
131 raise Exception('Cannot match request + ' + repr(request_handler.request) + '\n'
132 + 'Most suitable handler : ' + most_suitable_handler.matcher_info() + '\n'
133 + 'Unmatches fields: ' + str(match_result.unmatched_fields))
134
135 def register_mock(
136 self,

Callers 2

getMethod · 0.80
postMethod · 0.80

Calls 4

appendMethod · 0.80
matchMethod · 0.80
matcher_infoMethod · 0.80
handleMethod · 0.45

Tested by

no test coverage detected