Fix glance create client unit tests
If tests test_create_glance_client_with_protocol_http and test_create_glance_client_with_protocol_https from cinder.tests.unit.image.test_glance.TestGlanceImageServiceClient are run one after the other (regardless of the order) it will result in an error: "AssertionError: Expected 'load_from_options' to be called once. Called 0 times.". The reason is that in cinder/image/glance.py we cache the session in variable _SESSION, so the first test will set it and the second one will reuse it and won't call the load_from_options method. This patch solves this issue by resetting the caching variable in the tests. TrivialFix Change-Id: Ia77d9d1a3aa4b54a08912584164739f851188784
This commit is contained in:
parent
335c55766f
commit
1b9a2deaa5
@ -822,6 +822,7 @@ class TestGlanceImageServiceClient(test.TestCase):
|
||||
@mock.patch.object(ks_session.Session, 'load_from_options')
|
||||
def test_create_glance_client_with_protocol_http(
|
||||
self, mock_load, mock_get_auth_plugin):
|
||||
glance._SESSION = None
|
||||
self.flags(auth_strategy='keystone')
|
||||
self.flags(glance_request_timeout=None)
|
||||
|
||||
@ -850,6 +851,7 @@ class TestGlanceImageServiceClient(test.TestCase):
|
||||
@mock.patch.object(ks_session.Session, 'load_from_options')
|
||||
def test_create_glance_client_with_protocol_https(
|
||||
self, mock_load, mock_get_auth_plugin):
|
||||
glance._SESSION = None
|
||||
self.flags(auth_strategy='keystone')
|
||||
self.flags(glance_request_timeout=60)
|
||||
self.flags(
|
||||
|
Loading…
x
Reference in New Issue
Block a user