+ request_body_json = self._get_request_body()
+ if request_body_json is not None:
+ self._apply_expected_data(request_body_json)
+ logging.info("EXPECTED RESPONSES: " + str(self._expected_responses))
+ logging.info("EXPECTED REQUESTS: " + str(self._expected_requests))
+ response_status = 200
+ else:
+ response_status = 400
+ self.send_response(response_status)
+ self._set_headers()
+
+ def rest_method(self,method):
+ expected_response = self._get_response_by_endpoint(self.path,method)
+ if expected_response:
+ self.send_response(expected_response["responseCode"])
+ self._set_headers()
+ self.wfile.write(json.dumps(expected_response["body"]).encode("utf-8"))
+ else:
+ response_body = "{\"message:\" \"no response for endpoint\"}"
+ self.send_response(400)
+ self._set_headers()
+ self.wfile.write(json.dumps(response_body).encode("utf-8"))