Patch nova_cc_utils config() before it's imported by nova_cc_context
This commit is contained in:
parent
3b26fda2c5
commit
4ab20c2a33
@ -1,6 +1,20 @@
|
|||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
|
#####
|
||||||
|
# NOTE(freyes): this is a workaround to patch config() function imported by
|
||||||
|
# nova_cc_utils before it gets a reference to the actual config() provided by
|
||||||
|
# hookenv module.
|
||||||
|
from charmhelpers.core import hookenv
|
||||||
|
_conf = hookenv.config
|
||||||
|
hookenv.config = mock.MagicMock()
|
||||||
|
import nova_cc_utils as _utils
|
||||||
|
# this assert is a double check + to avoid pep8 warning
|
||||||
|
assert _utils.config == hookenv.config
|
||||||
|
hookenv.config = _conf
|
||||||
|
#####
|
||||||
|
|
||||||
import nova_cc_context as context
|
import nova_cc_context as context
|
||||||
|
|
||||||
from charmhelpers.contrib.openstack import utils
|
from charmhelpers.contrib.openstack import utils
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
from mock import MagicMock, patch, call
|
from mock import MagicMock, patch, call
|
||||||
from test_utils import CharmTestCase, patch_open
|
from test_utils import CharmTestCase, patch_open
|
||||||
import os
|
import os
|
||||||
|
|
||||||
with patch('charmhelpers.core.hookenv.config') as config:
|
with patch('charmhelpers.core.hookenv.config') as config:
|
||||||
config.return_value = 'neutron'
|
config.return_value = 'neutron'
|
||||||
import nova_cc_utils as utils
|
import nova_cc_utils as utils
|
||||||
|
Loading…
Reference in New Issue
Block a user