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
This commit is contained in:
Julia Kreger 2018-05-11 14:25:44 -07:00
parent ce4594e2c5
commit f88d993dac
2 changed files with 5 additions and 4 deletions

View File

@ -64,7 +64,7 @@ def get_admin_context():
"""Create an administrator context.""" """Create an administrator context."""
context = RequestContext(auth_token=None, context = RequestContext(auth_token=None,
tenant=None, project_id=None,
is_admin=True, is_admin=True,
overwrite=False) overwrite=False)
return context return context

View File

@ -69,7 +69,7 @@ class MyObj(base.IronicObject, object_base.VersionedObjectDictCompat):
@object_base.remotable @object_base.remotable
def update_test(self, context=None): def update_test(self, context=None):
if context and context.tenant == 'alternate': if context and context.project_id == 'alternate':
self.bar = 'alternate-context' self.bar = 'alternate-context'
else: else:
self.bar = 'updated' self.bar = 'updated'
@ -232,8 +232,9 @@ class _TestObject(object):
base.IronicObject.obj_class_from_name, 'foo', '1.0') base.IronicObject.obj_class_from_name, 'foo', '1.0')
def test_with_alternate_context(self): def test_with_alternate_context(self):
ctxt1 = context.RequestContext(auth_token='foo', tenant='foo') ctxt1 = context.RequestContext(auth_token='foo', project_id='foo')
ctxt2 = context.RequestContext(auth_token='bar', tenant='alternate') ctxt2 = context.RequestContext(auth_token='bar',
project_id='alternate')
obj = MyObj.query(ctxt1) obj = MyObj.query(ctxt1)
obj.update_test(ctxt2) obj.update_test(ctxt2)
self.assertEqual('alternate-context', obj.bar) self.assertEqual('alternate-context', obj.bar)