(self, request_handler)
| 56 | self.headers = headers |
| 57 | |
| 58 | def match(self, request_handler) -> MatchResult: |
| 59 | match_result = MatchResult() |
| 60 | |
| 61 | match_result.add_match_result('method', self.method, request_handler.request.method) |
| 62 | match_result.add_match_result( |
| 63 | 'path', |
| 64 | self.path_pattern, |
| 65 | request_handler.request.uri, |
| 66 | lambda: re.match(self.path_pattern, request_handler.request.uri) |
| 67 | ) |
| 68 | |
| 69 | if self.request_body: |
| 70 | actual_body = request_handler.request.body |
| 71 | if actual_body: |
| 72 | actual_body = actual_body.decode('utf8') |
| 73 | match_result.add_match_result( |
| 74 | 'body', |
| 75 | self.request_body, |
| 76 | actual_body) |
| 77 | |
| 78 | if self.headers: |
| 79 | for header, value in self.headers.items(): |
| 80 | actual_value = request_handler.request.headers.get(header) |
| 81 | match_result.add_match_result('Header:' + header, value, actual_value) |
| 82 | |
| 83 | return match_result |
| 84 | |
| 85 | def handle(self, request_handler): |
| 86 | if self.response_handler: |
no test coverage detected