Use keystoneauth.betamax for shade mocks
Instead of mocking the clients, use keystoneauth1.betamax fixture to intercept keystoneauth.construct_session, and provide our own recorded fixtures. Change-Id: I7b2973b0f89b66c19d6bf10571c3c93692107aa3
This commit is contained in:
parent
a53db2c680
commit
5f5c925631
@ -8,7 +8,7 @@ os-client-config>=1.17.0
|
||||
requestsexceptions>=1.1.1
|
||||
six
|
||||
|
||||
keystoneauth1>=1.0.0
|
||||
keystoneauth1>=2.8.0
|
||||
netifaces>=0.10.4
|
||||
python-novaclient>=2.21.0,!=2.27.0,!=2.32.0
|
||||
python-keystoneclient>=0.11.0
|
||||
|
@ -18,6 +18,7 @@
|
||||
import time
|
||||
|
||||
import fixtures
|
||||
import os
|
||||
import os_client_config as occ
|
||||
import tempfile
|
||||
|
||||
@ -56,10 +57,21 @@ class TestCase(base.TestCase):
|
||||
vendor.write(b'{}')
|
||||
vendor.close()
|
||||
|
||||
# set record mode depending on environment
|
||||
record_mode = os.environ.get('BETAMAX_RECORD_FIXTURES', False)
|
||||
if record_mode:
|
||||
self.record_fixtures = 'new_episodes'
|
||||
else:
|
||||
self.record_fixtures = None
|
||||
|
||||
test_cloud = os.environ.get('SHADE_OS_CLOUD', '_test_cloud_')
|
||||
self.config = occ.OpenStackConfig(
|
||||
config_files=[config.name],
|
||||
vendor_files=[vendor.name])
|
||||
self.cloud_config = self.config.get_one_cloud(cloud='_test_cloud_')
|
||||
self.cloud_config = self.config.get_one_cloud(cloud=test_cloud)
|
||||
self.cloud = shade.OpenStackCloud(
|
||||
cloud_config=self.cloud_config,
|
||||
log_inner_exceptions=True)
|
||||
self.op_cloud = shade.OperatorCloud(
|
||||
cloud_config=self.cloud_config,
|
||||
log_inner_exceptions=True)
|
||||
|
@ -24,7 +24,6 @@ class TestFlavors(base.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestFlavors, self).setUp()
|
||||
self.op_cloud = shade.operator_cloud(validate=False)
|
||||
|
||||
@mock.patch.object(shade.OpenStackCloud, 'nova_client')
|
||||
def test_create_flavor(self, mock_nova):
|
||||
|
@ -1,5 +1,6 @@
|
||||
hacking>=0.10.0,<0.11
|
||||
|
||||
betamax-serializers>=0.1.1
|
||||
coverage>=3.6
|
||||
discover
|
||||
fixtures>=0.3.14
|
||||
|
14
tox.ini
14
tox.ini
@ -15,6 +15,20 @@ deps = -r{toxinidir}/requirements.txt
|
||||
-r{toxinidir}/test-requirements.txt
|
||||
commands = python setup.py testr --slowest --testr-args='{posargs}'
|
||||
|
||||
[testenv:record]
|
||||
usedevelop = True
|
||||
install_command = pip install -U {opts} {packages}
|
||||
setenv =
|
||||
VIRTUAL_ENV={envdir}
|
||||
LANG=en_US.UTF-8
|
||||
LANGUAGE=en_US:en
|
||||
LC_ALL=C
|
||||
BETAMAX_RECORD_FIXTURES=1
|
||||
passenv = SHADE_OS_CLOUD
|
||||
deps = -r{toxinidir}/requirements.txt
|
||||
-r{toxinidir}/test-requirements.txt
|
||||
commands = python setup.py testr --slowest --testr-args='--concurrency=1 {posargs}'
|
||||
|
||||
[testenv:functional]
|
||||
setenv =
|
||||
OS_TEST_PATH = ./shade/tests/functional
|
||||
|
Loading…
Reference in New Issue
Block a user