'Test case for waiting for successful resource deletion.
The delete operation may fail until the servers are really gone; the
resource retries until success.'

def test_delete_waits_for_server_deletion(self):

    self._setup_test_stack()
    delete_counter = itertools.count()
    def delete(group_id):
        count = next(delete_counter)
        if (count < 3):
            raise auto_scale.Forbidden('Not    empty!')
    self.patchobject(self.fake_auto_scale, 'delete', side_effect=delete)
    resource = self.stack['my_group']
    scheduler.TaskRunner(resource.delete)()
    self.assertEqual(4, next(delete_counter))
