'Do not block stack deletion if user_creds is missing.
It may happen that user_creds were deleted when a delete operation was
stopped. We should be resilient to this and still complete the delete
operation.'

def test_delete_user_creds_gone_missing(self):

    self.stack = stack.Stack(self.ctx, 'delete_test', self.tmpl)
    stack_id = self.stack.store()
    db_s = stack_object.Stack.get_by_id(self.ctx, stack_id)
    self.assertIsNotNone(db_s)
    self.assertIsNotNone(db_s.user_creds_id)
    user_creds_id = db_s.user_creds_id
    db_creds = ucreds_object.UserCreds.get_by_id(self.ctx, db_s.user_creds_id)
    self.assertIsNotNone(db_creds)
    ucreds_object.UserCreds.delete(self.ctx, user_creds_id)
    self.stack.delete()
    db_s = stack_object.Stack.get_by_id(self.ctx, stack_id)
    self.assertIsNone(db_s)
    db_creds = ucreds_object.UserCreds.get_by_id(self.ctx, user_creds_id)
    self.assertIsNone(db_creds)
    del_db_s = stack_object.Stack.get_by_id(self.ctx, stack_id, show_deleted=True)
    self.assertIsNone(del_db_s.user_creds_id)
    self.assertEqual((stack.Stack.DELETE, stack.Stack.COMPLETE), self.stack.state)
