From f88d993dacdf3f963a6ee18f3074bb889ea901e8 Mon Sep 17 00:00:00 2001 From: Julia Kreger Date: Fri, 11 May 2018 14:25:44 -0700 Subject: [PATCH] Fix tenant DeprecationWarning from oslo_context Unit tests run a bit slow because all context invocations were resulting in a deprecation warning being logged for each task invocation. Seems like it was an easy change! Error: DeprecationWarning: Using the 'tenant' argument is deprecated in version '2.18' and will be removed in version '3.0', please use the 'project_id' argument instead Change-Id: Ie555a5c554356c04d929fce972b061f720701355 --- ironic/common/context.py | 2 +- ironic/tests/unit/objects/test_objects.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ironic/common/context.py b/ironic/common/context.py index 9329efd439..4af76ecb11 100644 --- a/ironic/common/context.py +++ b/ironic/common/context.py @@ -64,7 +64,7 @@ def get_admin_context(): """Create an administrator context.""" context = RequestContext(auth_token=None, - tenant=None, + project_id=None, is_admin=True, overwrite=False) return context diff --git a/ironic/tests/unit/objects/test_objects.py b/ironic/tests/unit/objects/test_objects.py index 486084ea19..f75d4ed124 100644 --- a/ironic/tests/unit/objects/test_objects.py +++ b/ironic/tests/unit/objects/test_objects.py @@ -69,7 +69,7 @@ class MyObj(base.IronicObject, object_base.VersionedObjectDictCompat): @object_base.remotable def update_test(self, context=None): - if context and context.tenant == 'alternate': + if context and context.project_id == 'alternate': self.bar = 'alternate-context' else: self.bar = 'updated' @@ -232,8 +232,9 @@ class _TestObject(object): base.IronicObject.obj_class_from_name, 'foo', '1.0') def test_with_alternate_context(self): - ctxt1 = context.RequestContext(auth_token='foo', tenant='foo') - ctxt2 = context.RequestContext(auth_token='bar', tenant='alternate') + ctxt1 = context.RequestContext(auth_token='foo', project_id='foo') + ctxt2 = context.RequestContext(auth_token='bar', + project_id='alternate') obj = MyObj.query(ctxt1) obj.update_test(ctxt2) self.assertEqual('alternate-context', obj.bar)