Patch nova_cc_utils config() before it's imported by nova_cc_context

This commit is contained in:
Felipe Reyes 2014-11-20 12:07:29 -03:00
parent 3b26fda2c5
commit 4ab20c2a33
2 changed files with 15 additions and 0 deletions

View File

@ -1,6 +1,20 @@
from __future__ import print_function
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
from charmhelpers.contrib.openstack import utils

View File

@ -1,6 +1,7 @@
from mock import MagicMock, patch, call
from test_utils import CharmTestCase, patch_open
import os
with patch('charmhelpers.core.hookenv.config') as config:
config.return_value = 'neutron'
import nova_cc_utils as utils