Clean imports in code

In some part in the code we import objects.
In the Openstack style guidelines they recommend to import only
modules.
We need to fix that.

Change-Id: I9c7481462ac7350bddae78c0a05af1e835a282e2
This commit is contained in:
Nguyen Hung Phuong 2016-08-16 12:41:55 +07:00
parent b67d76d68b
commit e8f6c36440
3 changed files with 14 additions and 14 deletions

View File

@ -11,7 +11,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from heat.common.exception import NotFound from heat.common import exception
from oslo_utils import timeutils from oslo_utils import timeutils
import six import six
@ -67,5 +67,5 @@ class CooldownMixin(object):
metadata['scaling_in_progress'] = False metadata['scaling_in_progress'] = False
try: try:
self.metadata_set(metadata) self.metadata_set(metadata)
except NotFound: except exception.NotFound:
pass pass

View File

@ -14,7 +14,7 @@
import copy import copy
import mock import mock
from heat.common.exception import StackValidationFailed from heat.common import exception
from heat.common import grouputils from heat.common import grouputils
from heat.engine.resources.openstack.heat import resource_chain from heat.engine.resources.openstack.heat import resource_chain
from heat.engine import rsrc_defn from heat.engine import rsrc_defn
@ -144,7 +144,7 @@ class ResourceChainTest(common.HeatTestCase):
try: try:
chain.validate_nested_stack() chain.validate_nested_stack()
self.fail('Exception expected') self.fail('Exception expected')
except StackValidationFailed as e: except exception.StackValidationFailed as e:
self.assertTrue('unknown property group' in e.message.lower()) self.assertTrue('unknown property group' in e.message.lower())
def test_validate_fake_resource_type(self): def test_validate_fake_resource_type(self):
@ -160,7 +160,7 @@ class ResourceChainTest(common.HeatTestCase):
try: try:
chain.validate_nested_stack() chain.validate_nested_stack()
self.fail('Exception expected') self.fail('Exception expected')
except StackValidationFailed as e: except exception.StackValidationFailed as e:
self.assertTrue('could not be found' in e.message.lower()) self.assertTrue('could not be found' in e.message.lower())
self.assertTrue('foo' in e.message) self.assertTrue('foo' in e.message)

View File

@ -20,8 +20,8 @@ from six.moves.urllib import parse as urlparse
from heat.common import exception from heat.common import exception
from heat.common import template_format from heat.common import template_format
from heat.engine.clients.os.heat_plugin import HeatClientPlugin from heat.engine.clients.os import heat_plugin
from heat.engine.clients.os.swift import SwiftClientPlugin from heat.engine.clients.os import swift
from heat.engine import scheduler from heat.engine import scheduler
from heat.engine import stack as stk from heat.engine import stack as stk
from heat.engine import template from heat.engine import template
@ -148,7 +148,7 @@ class SignalTest(common.HeatTestCase):
rsrc, 'user_id') rsrc, 'user_id')
self.assertEqual('1234', rsrc._get_user_id()) self.assertEqual('1234', rsrc._get_user_id())
@mock.patch.object(HeatClientPlugin, 'get_heat_cfn_url') @mock.patch.object(heat_plugin.HeatClientPlugin, 'get_heat_cfn_url')
def test_FnGetAtt_alarm_url(self, mock_get): def test_FnGetAtt_alarm_url(self, mock_get):
# Setup # Setup
stack_id = stack_name = 'FnGetAtt-alarm-url' stack_id = stack_name = 'FnGetAtt-alarm-url'
@ -214,7 +214,7 @@ class SignalTest(common.HeatTestCase):
mock_has.assert_called_once_with('signal_handler') mock_has.assert_called_once_with('signal_handler')
self.assertEqual(second_url, 'cached') self.assertEqual(second_url, 'cached')
@mock.patch.object(HeatClientPlugin, 'get_heat_url') @mock.patch.object(heat_plugin.HeatClientPlugin, 'get_heat_url')
def test_FnGetAtt_heat_signal(self, mock_get): def test_FnGetAtt_heat_signal(self, mock_get):
# Setup # Setup
stack = self._create_stack(TEMPLATE_HEAT_TEMPLATE_SIGNAL) stack = self._create_stack(TEMPLATE_HEAT_TEMPLATE_SIGNAL)
@ -310,7 +310,7 @@ class SignalTest(common.HeatTestCase):
@mock.patch('swiftclient.client.Connection.put_container') @mock.patch('swiftclient.client.Connection.put_container')
@mock.patch('swiftclient.client.Connection.put_object') @mock.patch('swiftclient.client.Connection.put_object')
@mock.patch.object(SwiftClientPlugin, 'get_temp_url') @mock.patch.object(swift.SwiftClientPlugin, 'get_temp_url')
def test_FnGetAtt_swift_signal(self, mock_get_url, def test_FnGetAtt_swift_signal(self, mock_get_url,
mock_put_object, mock_put_container): mock_put_object, mock_put_container):
# Setup # Setup
@ -333,7 +333,7 @@ class SignalTest(common.HeatTestCase):
@mock.patch('swiftclient.client.Connection.put_container') @mock.patch('swiftclient.client.Connection.put_container')
@mock.patch('swiftclient.client.Connection.put_object') @mock.patch('swiftclient.client.Connection.put_object')
@mock.patch.object(SwiftClientPlugin, 'get_temp_url') @mock.patch.object(swift.SwiftClientPlugin, 'get_temp_url')
@mock.patch.object(stk.Stack, 'cache_data_resource_attribute') @mock.patch.object(stk.Stack, 'cache_data_resource_attribute')
@mock.patch.object(stk.Stack, 'has_cache_data') @mock.patch.object(stk.Stack, 'has_cache_data')
def test_FnGetAtt_swift_signal_is_cached(self, mock_has, mock_get, def test_FnGetAtt_swift_signal_is_cached(self, mock_has, mock_get,
@ -368,7 +368,7 @@ class SignalTest(common.HeatTestCase):
self.assertEqual(1, mock_put_object.call_count) self.assertEqual(1, mock_put_object.call_count)
self.assertEqual(1, mock_get_url.call_count) self.assertEqual(1, mock_get_url.call_count)
@mock.patch.object(HeatClientPlugin, 'get_heat_cfn_url') @mock.patch.object(heat_plugin.HeatClientPlugin, 'get_heat_cfn_url')
def test_FnGetAtt_delete(self, mock_get): def test_FnGetAtt_delete(self, mock_get):
# Setup # Setup
mock_get.return_value = 'http://server.test:8000/v1' mock_get.return_value = 'http://server.test:8000/v1'
@ -390,7 +390,7 @@ class SignalTest(common.HeatTestCase):
self.assertEqual(2, mock_get.call_count) self.assertEqual(2, mock_get.call_count)
@mock.patch.object(HeatClientPlugin, 'get_heat_url') @mock.patch.object(heat_plugin.HeatClientPlugin, 'get_heat_url')
def test_FnGetAtt_heat_signal_delete(self, mock_get): def test_FnGetAtt_heat_signal_delete(self, mock_get):
# Setup # Setup
mock_get.return_value = 'http://server.test:8004/v1' mock_get.return_value = 'http://server.test:8004/v1'
@ -417,7 +417,7 @@ class SignalTest(common.HeatTestCase):
@mock.patch('swiftclient.client.Connection.delete_container') @mock.patch('swiftclient.client.Connection.delete_container')
@mock.patch('swiftclient.client.Connection.delete_object') @mock.patch('swiftclient.client.Connection.delete_object')
@mock.patch('swiftclient.client.Connection.get_container') @mock.patch('swiftclient.client.Connection.get_container')
@mock.patch.object(SwiftClientPlugin, 'get_temp_url') @mock.patch.object(swift.SwiftClientPlugin, 'get_temp_url')
@mock.patch('swiftclient.client.Connection.head_container') @mock.patch('swiftclient.client.Connection.head_container')
@mock.patch('swiftclient.client.Connection.put_container') @mock.patch('swiftclient.client.Connection.put_container')
@mock.patch('swiftclient.client.Connection.put_object') @mock.patch('swiftclient.client.Connection.put_object')