@GlobalStorageAccountPreparer()
@AsyncStorageTestCase.await_prepared_test
async def test_soft_delete_single_blob_snapshot(self, resource_group, location, storage_account, storage_account_key):
    try:
        (await self._setup(storage_account.name, storage_account_key))
        (await self._enable_soft_delete())
        blob_name = (await self._create_block_blob())
        blob = self.bsc.get_blob_client(self.container_name, blob_name)
        blob_snapshot_1 = (await blob.create_snapshot())
        blob_snapshot_2 = (await blob.create_snapshot())
        snapshot_1 = self.bsc.get_blob_client(self.container_name, blob_name, snapshot=blob_snapshot_1)
        (await snapshot_1.delete_blob())
        with self.assertRaises(ValueError):
            (await snapshot_1.delete_blob(delete_snapshots='only'))
        container = self.bsc.get_container_client(self.container_name)
        blob_list = []
        async for b in container.list_blobs(include=['snapshots', 'deleted']):
            blob_list.append(b)
        self.assertEqual(len(blob_list), 3)
        for listedblob in blob_list:
            if (listedblob.snapshot == blob_snapshot_1['snapshot']):
                self._assert_blob_is_soft_deleted(listedblob)
            else:
                self._assert_blob_not_soft_deleted(listedblob)
        blob_list = []
        async for b in container.list_blobs(include='snapshots'):
            blob_list.append(b)
        self.assertEqual(len(blob_list), 2)
        (await blob.undelete_blob())
        blob_list = []
        async for b in container.list_blobs(include=['snapshots', 'deleted']):
            blob_list.append(b)
        self.assertEqual(len(blob_list), 3)
        for blob in blob_list:
            self._assert_blob_not_soft_deleted(blob)
    finally:
        (await self._disable_soft_delete())
@GlobalStorageAccountPreparer()
@AsyncStorageTestCase.await_prepared_test
async def test_soft_delete_single_blob_snapshot(self, resource_group, location, storage_account, storage_account_key):
    try:
        (await self._setup(storage_account.name, storage_account_key))
        (await self._enable_soft_delete())
        blob_name = (await self._create_block_blob())
        blob = self.bsc.get_blob_client(self.container_name, blob_name)
        blob_snapshot_1 = (await blob.create_snapshot())
        blob_snapshot_2 = (await blob.create_snapshot())
        snapshot_1 = self.bsc.get_blob_client(self.container_name, blob_name, snapshot=blob_snapshot_1)
        (await snapshot_1.delete_blob())
        with self.assertRaises(ValueError):
            (await snapshot_1.delete_blob(delete_snapshots='only'))
        container = self.bsc.get_container_client(self.container_name)
        blob_list = []
        async for b in container.list_blobs(include=['snapshots', 'deleted']):
            blob_list.append(b)
        self.assertEqual(len(blob_list), 3)
        for listedblob in blob_list:
            if (listedblob.snapshot == blob_snapshot_1['snapshot']):
                self._assert_blob_is_soft_deleted(listedblob)
            else:
                self._assert_blob_not_soft_deleted(listedblob)
        blob_list = []
        async for b in container.list_blobs(include='snapshots'):
            blob_list.append(b)
        self.assertEqual(len(blob_list), 2)
        (await blob.undelete_blob())
        blob_list = []
        async for b in container.list_blobs(include=['snapshots', 'deleted']):
            blob_list.append(b)
        self.assertEqual(len(blob_list), 3)
        for blob in blob_list:
            self._assert_blob_not_soft_deleted(blob)
    finally:
        (await self._disable_soft_delete())