From dba80b27427aede8546cdf0bf8522e27f3ceeecd Mon Sep 17 00:00:00 2001 From: Bo Chi Date: Sun, 15 Nov 2015 04:21:26 -0500 Subject: [PATCH] Rename "endpoint" to "credential" (part 1) Copied rally/common/objects/endpoint.py to credential.py Marked objects.Endpoint as deprecated Modified use of objects.Endpoint to objects.Credential Variable and key names are not changed in this patch Partial-Bug: #1447682 Change-Id: Ia62881473d1bf63f952528b66e7420eea6323f08 --- rally/plugins/openstack/context/keystone/users.py | 2 +- tests/hacking/checks.py | 3 +++ tests/unit/fakes.py | 6 +++--- .../openstack/context/keystone/test_users.py | 13 +++++++------ 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/rally/plugins/openstack/context/keystone/users.py b/rally/plugins/openstack/context/keystone/users.py index 679820a1..bca9f4e8 100644 --- a/rally/plugins/openstack/context/keystone/users.py +++ b/rally/plugins/openstack/context/keystone/users.py @@ -216,7 +216,7 @@ class UserGenerator(UserContextMixin, context.Context): user = client.create_user(username, password, "%s@email.me" % username, tenant_id, user_dom) - user_endpoint = objects.Endpoint( + user_endpoint = objects.Credential( client.auth_url, user.name, password, self.context["tenants"][tenant_id]["name"], consts.EndpointPermission.USER, client.region_name, diff --git a/tests/hacking/checks.py b/tests/hacking/checks.py index ce61421c..aebeff13 100644 --- a/tests/hacking/checks.py +++ b/tests/hacking/checks.py @@ -275,6 +275,9 @@ def check_no_direct_rally_objects_import(logical_line, filename): if filename == "./rally/common/objects/__init__.py": return + if filename == "./rally/common/objects/endpoint.py": + return + if (logical_line.startswith("from rally.common.objects") or logical_line.startswith("import rally.common.objects.")): yield (0, "N340: Import objects module:" diff --git a/tests/unit/fakes.py b/tests/unit/fakes.py index 6a587c9f..bddea629 100644 --- a/tests/unit/fakes.py +++ b/tests/unit/fakes.py @@ -1468,7 +1468,7 @@ class FakeClients(object): self._murano = None self._monasca = None self._ec2 = None - self._endpoint = endpoint_ or objects.Endpoint( + self._endpoint = endpoint_ or objects.Credential( "http://fake.example.org:5000/v2.0/", "fake_username", "fake_password", @@ -1649,11 +1649,11 @@ class FakeUserContext(FakeContext): admin = { "id": "adminuuid", - "endpoint": objects.Endpoint("aurl", "aname", "apwd", "atenant") + "endpoint": objects.Credential("aurl", "aname", "apwd", "atenant") } user = { "id": "uuid", - "endpoint": objects.Endpoint("url", "name", "pwd", "tenant"), + "endpoint": objects.Credential("url", "name", "pwd", "tenant"), "tenant_id": "uuid" } tenants = {"uuid": {"name": "tenant"}} diff --git a/tests/unit/plugins/openstack/context/keystone/test_users.py b/tests/unit/plugins/openstack/context/keystone/test_users.py index 3e797c46..944e34e9 100644 --- a/tests/unit/plugins/openstack/context/keystone/test_users.py +++ b/tests/unit/plugins/openstack/context/keystone/test_users.py @@ -312,9 +312,9 @@ class UserGeneratorTestCase(test.ScenarioTestCase): wrapped_keystone = mock.MagicMock() mock_keystone.wrap.return_value = wrapped_keystone - endpoint = objects.Endpoint("foo_url", "foo", "foo_pass", - https_insecure=True, - https_cacert="cacert") + endpoint = objects.Credential("foo_url", "foo", "foo_pass", + https_insecure=True, + https_cacert="cacert") tmp_context = dict(self.context) tmp_context["config"]["users"] = {"tenants": 1, "users_per_tenant": 2, @@ -362,8 +362,9 @@ class UserGeneratorTestCase(test.ScenarioTestCase): @mock.patch("%s.keystone" % CTX) def test_users_contains_correct_endpoint_type(self, mock_keystone): - endpoint = objects.Endpoint("foo_url", "foo", "foo_pass", - endpoint_type=consts.EndpointType.INTERNAL) + endpoint = objects.Credential( + "foo_url", "foo", "foo_pass", + endpoint_type=consts.EndpointType.INTERNAL) config = { "config": { "users": { @@ -384,7 +385,7 @@ class UserGeneratorTestCase(test.ScenarioTestCase): @mock.patch("%s.keystone" % CTX) def test_users_contains_default_endpoint_type(self, mock_keystone): - endpoint = objects.Endpoint("foo_url", "foo", "foo_pass") + endpoint = objects.Credential("foo_url", "foo", "foo_pass") config = { "config": { "users": {