def test_create_values_out_dict_2(self): """Test JSON out""" from ExportIndicators import create_values_out_dict, FORMAT_JSON, CTX_VALUES_KEY with open('ExportIndicators_test/TestHelperFunctions/demisto_iocs.json', 'r') as iocs_json_f: iocs_json = json.load(iocs_json_f) json_out = json.loads(create_values_out_dict(iocs_json, FORMAT_JSON).get(CTX_VALUES_KEY)) assert json_out == iocs_json
def test_create_values_out_dict_3(self): """Test JSON_SEQ out""" from ExportIndicators import create_values_out_dict, FORMAT_JSON_SEQ, CTX_VALUES_KEY with open('ExportIndicators_test/TestHelperFunctions/demisto_iocs.json', 'r') as iocs_json_f: iocs_json = json.loads(iocs_json_f.read()) json_seq_out = create_values_out_dict(iocs_json, FORMAT_JSON_SEQ).get(CTX_VALUES_KEY) for seq_line in json_seq_out.split('\n'): assert json.loads(seq_line) in iocs_json
def test_create_values_out_dict_4(self): """Test TEXT out""" from ExportIndicators import create_values_out_dict, FORMAT_TEXT, CTX_VALUES_KEY with open('ExportIndicators_test/TestHelperFunctions/demisto_iocs.json', 'r') as iocs_json_f: iocs_json = json.loads(iocs_json_f.read()) text_out = create_values_out_dict(iocs_json, FORMAT_TEXT).get(CTX_VALUES_KEY) with open('ExportIndicators_test/TestHelperFunctions/iocs_cache_values_text.json', 'r') as iocs_txt_f: iocs_txt_json = json.load(iocs_txt_f) for line in text_out.split('\n'): assert line in iocs_txt_json
def test_create_values_out_dict_1(self): """Test CSV out""" from ExportIndicators import create_values_out_dict, FORMAT_CSV with open('ExportIndicators_test/TestHelperFunctions/demisto_iocs.json', 'r') as iocs_json_f: iocs_json = json.loads(iocs_json_f.read()) csv_out = create_values_out_dict(iocs_json, FORMAT_CSV) # assert len(csv_out) == IOC_RES_LEN + 1 with open('ExportIndicators_test/TestHelperFunctions/iocs_out_csv.txt', 'r') as iocs_out_f: expected_csv_out = iocs_out_f.read() for csv_line in csv_out.values(): assert csv_line in expected_csv_out