Manually mock service_catalog in stub_keystoneclient
MockObject.__init__ ignores properties, fixes: FAIL: test_get_default_role (openstack_dashboard.test.api_tests.keystone_tests.RoleAPITests) ---------------------------------------------------------------------- Traceback (most recent call last): File "/var/lib/openstack-dashboard-test/openstack_dashboard/test/api_tests/keystone_tests.py", line 78, in test_get_default_role keystoneclient = self.stub_keystoneclient() File "/var/lib/openstack-dashboard-test/openstack_dashboard/test/helpers.py", line 287, in stub_keystoneclient self.keystoneclient = self.mox.CreateMock(keystone_client.Client) File "/usr/lib64/python2.6/site-packages/mox.py", line 258, in CreateMock new_mock = MockObject(class_to_mock, attrs=attrs) File "/usr/lib64/python2.6/site-packages/mox.py", line 556, in __init__ attr = getattr(class_to_mock, method) File "/usr/lib64/python2.6/site-packages/mox.py", line 608, in __getattr__ raise UnknownMethodCallError(name) UnknownMethodCallError: Method called is not a member of the object: service_catalog >> raise UnknownMethodCallError('service_catalog') Change-Id: I0af2f571855ad63c204e26d8283a713be0caae8f
This commit is contained in:
parent
cea720e793
commit
82bdecb117
@ -282,9 +282,10 @@ class APITestCase(TestCase):
|
||||
def stub_keystoneclient(self):
|
||||
if not hasattr(self, "keystoneclient"):
|
||||
self.mox.StubOutWithMock(keystone_client, 'Client')
|
||||
# NOTE(saschpe): Mock the 'auth_token' property specifically,
|
||||
# MockObject.__init__ ignores properties altogether:
|
||||
# NOTE(saschpe): Mock the 'auth_token' and 'service_catalog'
|
||||
# property specifically, MockObject.__init__ ignores properties:
|
||||
keystone_client.Client.auth_token = 'foo'
|
||||
keystone_client.Client.service_catalog = None
|
||||
self.keystoneclient = self.mox.CreateMock(keystone_client.Client)
|
||||
return self.keystoneclient
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user