diff --git a/openstack_dashboard/test/helpers.py b/openstack_dashboard/test/helpers.py index 692e509af9..42d3158edc 100644 --- a/openstack_dashboard/test/helpers.py +++ b/openstack_dashboard/test/helpers.py @@ -41,6 +41,7 @@ from keystoneclient.v2_0 import client as keystone_client import mock from mox3 import mox from neutronclient.v2_0 import client as neutron_client +from novaclient import api_versions as nova_api_versions from novaclient.v2 import client as nova_client from openstack_auth import user from openstack_auth import utils @@ -442,6 +443,12 @@ class APITestCase(TestCase): def stub_novaclient(self): if not hasattr(self, "novaclient"): self.mox.StubOutWithMock(nova_client, 'Client') + # mock the api_version since MockObject.__init__ ignores it. + # The preferred version in the api.nova code is 2 but that's + # equivalent to 2.1 now and is the base version that's backward + # compatible to 2.0 anyway. + api_version = nova_api_versions.APIVersion('2.1') + nova_client.Client.api_version = api_version self.novaclient = self.mox.CreateMock(nova_client.Client) return self.novaclient