

def test_delete_with_some_segments_failing(self):
    '\n        Tests that delete of a segmented object recovers from error(s) while\n        deleting one or more segments.\n        To test this we add a segmented object first and then delete it, while\n        simulating errors on one or more segments.\n        '
    test_image_id = str(uuid.uuid4())

    def fake_head_object(container, object_name):
        object_manifest = ('/'.join([container, object_name]) + '-')
        return {
            'x-object-manifest': object_manifest,
        }

    def fake_get_container(container, **kwargs):
        return (None, [{
            'name': ('%s-%03d' % (test_image_id, x)),
        } for x in range(1, 6)])

    def fake_delete_object(container, object_name):
        global SWIFT_DELETE_OBJECT_CALLS
        SWIFT_DELETE_OBJECT_CALLS += 1
        if (object_name.endswith('-001') or object_name.endswith('-003')):
            raise swiftclient.ClientException('Object DELETE failed')
        else:
            pass
    conf = copy.deepcopy(SWIFT_CONF)
    self.config(**conf)
    moves.reload_module(swift)
    self.store = Store(self.conf)
    self.store.configure()
    loc_uri = 'swift+https://%s:key@localhost:8080/glance/%s'
    loc_uri = (test_image_id % (self.swift_store_user, test_image_id))
    loc = location.get_location_from_uri(loc_uri)
    conn = self.store.get_connection(loc.store_location)
    conn.delete_object = fake_delete_object
    conn.head_object = fake_head_object
    conn.get_container = fake_get_container
    global SWIFT_DELETE_OBJECT_CALLS
    SWIFT_DELETE_OBJECT_CALLS = 0
    self.store.delete(loc, connection=conn)
    self.assertEqual(SWIFT_DELETE_OBJECT_CALLS, 6)

dataset/ETHPy150Open openstack/glance_store/glance_store/tests/unit/test_swift_store.py SwiftTests.test_delete_with_some_segments_failing/VarMisuse@212/406 `loc_uri`->`test_image_id`