def test_rebuild_sections(tags01): tool = recover.Recover() sections = tool.rebuild_sections(tags01) expected = sum(int(tag == (0, 'SECTION')) for tag in tags01) orphans = sections.pop() assert len(sections) == expected assert len(orphans) == 4
def test_build_section_dict(tags01): tool = recover.Recover() sections = tool.rebuild_sections(tags01) tool.load_section_dict(sections) assert len(tool.section_dict) == 2 header = tool.section_dict['HEADER'][0] assert len(header) == 6 assert header[0] == (0, 'SECTION') assert header[1] == (2, 'HEADER') assert len(tool.section_dict['ENTITIES']) == 1505
def test_build_section_dict(tags01): tool = recover.Recover() sections = tool.rebuild_sections(tags01) tool.load_section_dict(sections) assert len(tool.section_dict) == 2 header = tool.section_dict["HEADER"][0] assert len(header) == 6 assert header[0] == (0, "SECTION") assert header[1] == (2, "HEADER") assert len(tool.section_dict["ENTITIES"]) == 1505
def test_rebuild_tables(tags02): recover_tool = recover.Recover() sections = recover_tool.rebuild_sections(tags02) recover_tool.load_section_dict(sections) tables = recover_tool.section_dict.get('TABLES') random.shuffle(tables) tables = recover_tool.rebuild_tables(tables) assert tables[0] == [(0, 'SECTION'), (2, 'TABLES')] assert tables[1][0] == (0, 'TABLE') assert tables[1][1] == (2, 'VPORT') assert tables[2][0] == (0, 'VPORT') assert tables[3][0] == (0, 'ENDTAB') assert tables[4][0] == (0, 'TABLE') assert tables[4][1] == (2, 'LTYPE') assert tables[5][0] == (0, 'LTYPE') assert tables[8][0] == (0, 'ENDTAB') assert tables[-5][0] == (0, 'TABLE') assert tables[-5][1] == (2, 'BLOCK_RECORD') assert tables[-4][0] == (0, 'BLOCK_RECORD') assert tables[-1][0] == (0, 'ENDTAB')
def test_rebuild_tables(tags02): recover_tool = recover.Recover() sections = recover_tool.rebuild_sections(tags02) recover_tool.load_section_dict(sections) tables = recover_tool.section_dict.get("TABLES") random.shuffle(tables) tables = recover_tool.rebuild_tables(tables) assert tables[0] == [(0, "SECTION"), (2, "TABLES")] assert tables[1][0] == (0, "TABLE") assert tables[1][1] == (2, "VPORT") assert tables[2][0] == (0, "VPORT") assert tables[3][0] == (0, "ENDTAB") assert tables[4][0] == (0, "TABLE") assert tables[4][1] == (2, "LTYPE") assert tables[5][0] == (0, "LTYPE") assert tables[8][0] == (0, "ENDTAB") assert tables[-5][0] == (0, "TABLE") assert tables[-5][1] == (2, "BLOCK_RECORD") assert tables[-4][0] == (0, "BLOCK_RECORD") assert tables[-1][0] == (0, "ENDTAB")
def tags02(): filename = fullpath(RECOVER2) tool = recover.Recover() with open(filename, 'rb') as fp: return list(tool.load_tags(fp, errors='ignore'))
def tags01(): filename = fullpath(RECOVER1) tool = recover.Recover() with open(filename, 'rb') as fp: return list(tool.load_tags(fp))
def tags01(filename01): tool = recover.Recover() with open(filename01, 'rb') as fp: return list(tool.load_tags(fp))
def tags01(): filename = fullpath(RECOVER1) tool = recover.Recover() with open(filename, "rb") as fp: return list(tool.load_tags(fp, errors="ignore"))