def test_csv_read_write(self): dir_info = file_info.load_dir_info(_TEST_CASES_SRC) output = cStringIO.StringIO() dir_info.write_to_csv(output) dir_info_from_csv = file_info.load_dir_info_from_csv( cStringIO.StringIO(output.getvalue()), _TEST_CASES_SRC) file_info_list = [x for x in dir_info.flat_file_info_list()] file_info_list_from_csv = [ x for x in dir_info_from_csv.flat_file_info_list()] self.assertEqual(len(file_info_list), len(file_info_list_from_csv)) for i in range(len(file_info_list)): self._assert_file_info_list_valid_and_equal( file_info_list[i], file_info_list_from_csv[i])
def test_csv_read_write_with_compressed_file_info(self): compressed_file_info = file_info.FileInfo( './test.boxwrap.zip', False, 0100644, 100, 1234567890, file_hash='adfavdasdsa') test_file_info = file_info.FileInfo( './test.zip', False, 0100664, 200, 1234567895, file_hash='123kasdasd', compressed_file_info=compressed_file_info) dir_info = file_info.DirInfo('.', [file_info.FileInfo('.', True, 040775, None, 1234567890)], {'.': file_info.DirInfo('.', [test_file_info], {})}) output = cStringIO.StringIO() dir_info.write_to_csv(output) dir_info_from_csv = file_info.load_dir_info_from_csv( cStringIO.StringIO(output.getvalue()), '.') file_info_list = [x for x in dir_info.flat_file_info_list()] file_info_list_from_csv = [ x for x in dir_info_from_csv.flat_file_info_list()] self.assertEqual(len(file_info_list), len(file_info_list_from_csv)) for i in range(len(file_info_list)): self._assert_file_info_list_valid_and_equal( file_info_list[i], file_info_list_from_csv[i])