def format_output_as_json(check_results_by_path): """ This function takes as input a dict where key = filepath, value = list of CheckResults and formats them to json. :param check_results_by_path: dict - key = str (filepath), value = list[CheckResult] :return: json formatted string """ CheckResultJSONEncoder = MappingJSONEncoderClassBuilder(CheckResult, CheckResult.to_json_mapping()).build() return json.dumps(check_results_by_path, cls=CheckResultJSONEncoder)
def format_output_as_json(check_results_by_path): """ This function takes as input a dict where key = filepath, value = list of CheckResults and formats them to json. :param check_results_by_path: dict - key = str (filepath), value = list[CheckResult] :return: json formatted string """ CheckResultJSONEncoder = MappingJSONEncoderClassBuilder( CheckResult, CheckResult.to_json_mapping()).build() return json.dumps(check_results_by_path, cls=CheckResultJSONEncoder)
def setUp(self): self.check_result_as_json_dict = { "check_name": _NAME, "executed": _EXEUCTED, "result": _RESULT, "severity": _SEVERITY, "error_message": _ERROR_MESSAGE } self.CheckResultJSONDecoder = MappingJSONDecoderClassBuilder(CheckResult, CheckResult.to_json_mapping()).build()
def setUp(self): self.check_result = CheckResult( _NAME, executed=_EXEUCTED, result=_RESULT, severity=_SEVERITY, error_message=_ERROR_MESSAGE) self.CheckResultJSONEncoder = MappingJSONEncoderClassBuilder(CheckResult, CheckResult.to_json_mapping()).build()