def test_resolve_mispositioned_record_with_empty_disk_control(_mocked_exists, mocked_data_file, _mocked_index_file, header_index, position, headers, expect_result): """Check different combinations of headers sequences. Check different combinations of headers sequences with BlobRepairer.resolve_mispositioned_record and empty disk control. TODO(karapuz): not all branches are tested within: eblob_kit.BlobRepairer.resolve_mispositioned_record :param int header_index: :param int position: :param List[eblob_kit.DiskControl] headers: :param bool expect_result: """ mocked_data_file.return_value.read_disk_control.return_value = make_header() blob_repairer = BlobRepairer(TEST_BLOB_PATH) assert blob_repairer.valid blob_repairer._index_headers = headers assert blob_repairer.resolve_mispositioned_record(header_index, position, []) == expect_result
def test_resolve_mispositioned_record_with_positioned_disk_control( _mocked_exists, mocked_data_file, _mocked_index_file, header_index, position, disk_control_position): """Check different combinations of headers sequences with non empty disk_control. TODO(karapuz): add test to this test case. :param int header_index: :param int position: :param int disk_control_position: """ mocked_data_file.return_value.read_disk_control.return_value = make_header( position=disk_control_position) blob_repairer = BlobRepairer(TEST_BLOB_PATH) assert blob_repairer.valid blob_repairer._index_headers = [ make_header(disk_size=5, position=3), make_header(position=4), ] assert not blob_repairer.resolve_mispositioned_record( header_index, position, [])
def test_resolve_mispositioned_record_with_empty_disk_control( _mocked_exists, mocked_data_file, _mocked_index_file, header_index, position, headers, expect_result): """Check different combinations of headers sequences. Check different combinations of headers sequences with BlobRepairer.resolve_mispositioned_record and empty disk control. TODO(karapuz): not all branches are tested within: eblob_kit.BlobRepairer.resolve_mispositioned_record :param int header_index: :param int position: :param List[eblob_kit.DiskControl] headers: :param bool expect_result: """ mocked_data_file.return_value.read_disk_control.return_value = make_header( ) blob_repairer = BlobRepairer(TEST_BLOB_PATH) assert blob_repairer.valid blob_repairer._index_headers = headers assert blob_repairer.resolve_mispositioned_record(header_index, position, []) == expect_result
def test_resolve_mispositioned_record_assert(_mocked_exists, mocked_data_file, _index_file_mock, header_index, position, headers): """Check for resolve_mispositioned_record fail on assert. :param int header_index: :param int position: :param List[eblob_kit.DiskControl] headers: """ mocked_data_file.return_value.read_disk_control.return_value = make_header( ) blob_repairer = BlobRepairer(TEST_BLOB_PATH) assert blob_repairer.valid with pytest.raises(AssertionError): blob_repairer._index_headers = headers blob_repairer.resolve_mispositioned_record(header_index, position, [])
def test_resolve_mispositioned_record_assert(_mocked_exists, mocked_data_file, _index_file_mock, header_index, position, headers): """Check for resolve_mispositioned_record fail on assert. :param int header_index: :param int position: :param List[eblob_kit.DiskControl] headers: """ mocked_data_file.return_value.read_disk_control.return_value = make_header() blob_repairer = BlobRepairer(TEST_BLOB_PATH) assert blob_repairer.valid with pytest.raises(AssertionError): blob_repairer._index_headers = headers blob_repairer.resolve_mispositioned_record(header_index, position, [])
def test_resolve_mispositioned_record_with_positioned_disk_control(_mocked_exists, mocked_data_file, _mocked_index_file, header_index, position, disk_control_position): """Check different combinations of headers sequences with non empty disk_control. TODO(karapuz): add test to this test case. :param int header_index: :param int position: :param int disk_control_position: """ mocked_data_file.return_value.read_disk_control.return_value = make_header(position=disk_control_position) blob_repairer = BlobRepairer(TEST_BLOB_PATH) assert blob_repairer.valid blob_repairer._index_headers = [make_header(disk_size=5, position=3), make_header(position=4), ] assert not blob_repairer.resolve_mispositioned_record(header_index, position, [])