def test_main_empty_file(self, mocker): from ParseCSV import main with open("./TestData/empty_result.json") as f: expected = json.load(f) self.mock_demisto( mocker, file_obj=self.create_file_object("./TestData/empty.csv")) main() result = self.get_demisto_results() assert expected == result
def test_main_with_nullbytes(self, mocker): from ParseCSV import main with open("./TestData/nullbytes_results.json") as f: expeced = json.load(f) file_obj = self.create_file_object("./TestData/nullbytes.csv") self.mock_demisto(mocker, file_obj=file_obj) main() result = self.get_demisto_results() assert result == expeced
def test_main_one_lined_csv(self, mocker): from ParseCSV import main with open("./TestData/one_lined_csv_results.json") as f: expected = json.load(f) self.mock_demisto(mocker, file_obj=TestParseCSV.create_file_object( "./TestData/one_lined_csv.csv")) main() result = self.get_demisto_results() assert expected == result
def test_main_with_hash_empty_file(self, mocker): from ParseCSV import main args = { "entryID": "entry_id", "parseAll": "no", "codec": "utf-8", "hashes": "1" } file_obj = self.create_file_object("./TestData/empty.csv") self.mock_demisto(mocker, args_value=args, file_obj=file_obj) with pytest.raises(SystemExit, match="0"): main()
def test_main_with_hash(self, mocker): from ParseCSV import main with open("./TestData/one_is_hash_results.json") as f: expected = json.load(f) args = { "entryID": "entry_id", "parseAll": "no", "codec": "utf-8", "hashes": "1" } file_obj = self.create_file_object("./TestData/one_is_hash.csv") self.mock_demisto(mocker, args_value=args, file_obj=file_obj) main() result = self.get_demisto_results() assert expected == result