From a69fba56b08d4cb5bf7c7da414fc05fdf6c8a0d1 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Wed, 18 Sep 2024 12:11:02 +0900 Subject: [PATCH] Remove usage of deprecated RequestContext attributes These attributes were deprecated in oslo.context 2.6.0 . Change-Id: Iadb5fb54f82b9368242d59cc4843b26b7e99b385 --- oslo_log/tests/unit/test_log.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/oslo_log/tests/unit/test_log.py b/oslo_log/tests/unit/test_log.py index 968e4050..19328a89 100644 --- a/oslo_log/tests/unit/test_log.py +++ b/oslo_log/tests/unit/test_log.py @@ -71,7 +71,7 @@ def _fake_context(): ctxt = context.RequestContext(user_id="myuser", user_name="myuser", system_scope="myscope", - domain="mydomain", + domain_id="mydomain", project_id="mytenant", project_name="mytenant", project_domain_id="mydomain", @@ -940,8 +940,9 @@ class ContextFormatterTestCase(LogTestBase): message = 'test' self.log.info(message, context=ctxt) expected = ("HAS CONTEXT [%s %s %s %s %s %s %s]: %s\n" % - (ctxt.request_id, ctxt.user, ctxt.project_id, ctxt.domain, - ctxt.system_scope, ctxt.user_domain, ctxt.project_domain, + (ctxt.request_id, ctxt.user_id, ctxt.project_id, + ctxt.domain_id, ctxt.system_scope, + ctxt.user_domain_id, ctxt.project_domain_id, str(message))) self.assertEqual(expected, self.stream.getvalue()) @@ -969,7 +970,7 @@ class ContextFormatterTestCase(LogTestBase): message = 'test' self.log.info(message, context=ctxt) expected = ("HAS CONTEXT [%s %s %s]: %s\n" % - (ctxt.request_id, ctxt.user, ctxt.project_id, + (ctxt.request_id, ctxt.user_id, ctxt.project_id, str(message))) self.assertEqual(expected, self.stream.getvalue()) @@ -1275,9 +1276,9 @@ class DomainTestCase(LogTestBase): ctxt = _fake_context() user_identity = (self.CONF.logging_user_identity_format % ctxt.get_logging_values()) - self.assertIn(ctxt.domain, user_identity) - self.assertIn(ctxt.project_domain, user_identity) - self.assertIn(ctxt.user_domain, user_identity) + self.assertIn(ctxt.domain_id, user_identity) + self.assertIn(ctxt.project_domain_id, user_identity) + self.assertIn(ctxt.user_domain_id, user_identity) self._validate_keys(ctxt, ('[%s]: %s' % (ctxt.request_id, user_identity)))