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)
Beispiel #2
0
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)
Beispiel #3
0
 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()
Beispiel #4
0
 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()