Hard-code stubbed novaclient api_version to 2.1

The unit tests fail with novaclient 6.0.0 which requires
the use of an api_version property on the base Client class.

This change hard-codes the stubbed api_version attribute to
be 2.1 which is equivalent to the preferred version used in
the actual openstack_dashboard.api.nova.VERSSIONS code.

Change-Id: I9b89a224ad715cd0933d9757ca70e8a577eefc95
Closes-Bug: #1619093
This commit is contained in:
Matt Riedemann 2016-08-31 22:31:17 -04:00
parent 5b4a399c12
commit 9db0f0c0fd
1 changed files with 7 additions and 0 deletions

View File

@ -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