diff options
-rw-r--r-- | heatclient/common/environment_format.py | 4 | ||||
-rw-r--r-- | heatclient/shell.py | 2 | ||||
-rw-r--r-- | heatclient/tests/test_build_info.py | 4 | ||||
-rw-r--r-- | heatclient/tests/test_events.py | 29 | ||||
-rw-r--r-- | heatclient/tests/test_resource_types.py | 6 | ||||
-rw-r--r-- | heatclient/tests/test_resources.py | 8 | ||||
-rw-r--r-- | heatclient/tests/test_software_configs.py | 14 | ||||
-rw-r--r-- | heatclient/tests/test_software_deployments.py | 17 | ||||
-rw-r--r-- | heatclient/tests/test_stacks.py | 41 | ||||
-rw-r--r-- | heatclient/tests/test_template_utils.py | 4 | ||||
-rw-r--r-- | heatclient/v1/__init__.py | 2 | ||||
-rw-r--r-- | tox.ini | 2 |
12 files changed, 67 insertions, 66 deletions
diff --git a/heatclient/common/environment_format.py b/heatclient/common/environment_format.py index 82d6f1a..22269fe 100644 --- a/heatclient/common/environment_format.py +++ b/heatclient/common/environment_format.py @@ -10,7 +10,7 @@ # License for the specific language governing permissions and limitations # under the License. -from heatclient.common.template_format import yaml_loader +from heatclient.common import template_format import yaml @@ -26,7 +26,7 @@ def parse(env_str): YAML format. ''' try: - env = yaml.load(env_str, Loader=yaml_loader) + env = yaml.load(env_str, Loader=template_format.yaml_loader) except yaml.YAMLError as yea: raise ValueError(yea) else: diff --git a/heatclient/shell.py b/heatclient/shell.py index c3733ae..ed1d827 100644 --- a/heatclient/shell.py +++ b/heatclient/shell.py @@ -33,7 +33,7 @@ import heatclient from heatclient import client as heat_client from heatclient.common import utils from heatclient import exc -from heatclient.openstack.common.gettextutils import _ +from heatclient.openstack.common.gettextutils import _ # noqa from heatclient.openstack.common import importutils from heatclient.openstack.common import strutils diff --git a/heatclient/tests/test_build_info.py b/heatclient/tests/test_build_info.py index 51c0a95..3f2f1a9 100644 --- a/heatclient/tests/test_build_info.py +++ b/heatclient/tests/test_build_info.py @@ -16,7 +16,7 @@ import mock import testtools -from heatclient.v1.build_info import BuildInfoManager +from heatclient.v1 import build_info class BuildInfoManagerTest(testtools.TestCase): @@ -24,7 +24,7 @@ class BuildInfoManagerTest(testtools.TestCase): super(BuildInfoManagerTest, self).setUp() self.client = mock.Mock() self.client.json_request.return_value = ('resp', 'body') - self.manager = BuildInfoManager(self.client) + self.manager = build_info.BuildInfoManager(self.client) def test_build_info_makes_a_call_to_the_api(self): self.manager.build_info() diff --git a/heatclient/tests/test_events.py b/heatclient/tests/test_events.py index cae4fa7..e94b7eb 100644 --- a/heatclient/tests/test_events.py +++ b/heatclient/tests/test_events.py @@ -13,10 +13,9 @@ # under the License. from heatclient.common import utils -from heatclient.v1.events import EventManager +from heatclient.v1 import events -from mock import MagicMock -from mock import patch +import mock from mox3 import mox import testtools @@ -32,11 +31,11 @@ class EventManagerTest(testtools.TestCase): def test_list_event(self): stack_id = 'teststack', resource_name = 'testresource' - manager = EventManager(None) + manager = events.EventManager(None) self.m.StubOutWithMock(manager, '_resolve_stack_id') manager._resolve_stack_id(stack_id).AndReturn('teststack/abcd1234') self.m.ReplayAll() - manager._list = MagicMock() + manager._list = mock.MagicMock() manager.list(stack_id, resource_name) # Make sure url is correct. manager._list.assert_called_once_with('/stacks/teststack%2Fabcd1234/' @@ -46,11 +45,11 @@ class EventManagerTest(testtools.TestCase): def test_list_event_with_unicode_resource_name(self): stack_id = 'teststack', resource_name = u'\u5de5\u4f5c' - manager = EventManager(None) + manager = events.EventManager(None) self.m.StubOutWithMock(manager, '_resolve_stack_id') manager._resolve_stack_id(stack_id).AndReturn('teststack/abcd1234') self.m.ReplayAll() - manager._list = MagicMock() + manager._list = mock.MagicMock() manager.list(stack_id, resource_name) # Make sure url is correct. manager._list.assert_called_once_with('/stacks/teststack%2Fabcd1234/' @@ -59,8 +58,8 @@ class EventManagerTest(testtools.TestCase): def test_list_event_with_none_resource_name(self): stack_id = 'teststack', - manager = EventManager(None) - manager._list = MagicMock() + manager = events.EventManager(None) + manager._list = mock.MagicMock() manager.list(stack_id) # Make sure url is correct. manager._list.assert_called_once_with('/stacks/teststack/' @@ -75,11 +74,11 @@ class EventManagerTest(testtools.TestCase): 'resource_action': 'CREATE', 'resource_status': 'COMPLETE' }} - manager = EventManager(None) + manager = events.EventManager(None) self.m.StubOutWithMock(manager, '_resolve_stack_id') manager._resolve_stack_id(stack_id).AndReturn('teststack/abcd1234') self.m.ReplayAll() - manager._list = MagicMock() + manager._list = mock.MagicMock() manager.list(stack_id, resource_name, **kwargs) # Make sure url is correct. self.assertEqual(1, manager._list.call_count) @@ -112,8 +111,8 @@ class EventManagerTest(testtools.TestCase): assert args == expect return {}, {'event': []} - manager = EventManager(FakeAPI()) - with patch('heatclient.v1.events.Event'): + manager = events.EventManager(FakeAPI()) + with mock.patch('heatclient.v1.events.Event'): self.m.StubOutWithMock(manager, '_resolve_stack_id') manager._resolve_stack_id('teststack').AndReturn( 'teststack/abcd1234') @@ -135,8 +134,8 @@ class EventManagerTest(testtools.TestCase): assert args == expect return {}, {'event': []} - manager = EventManager(FakeAPI()) - with patch('heatclient.v1.events.Event'): + manager = events.EventManager(FakeAPI()) + with mock.patch('heatclient.v1.events.Event'): self.m.StubOutWithMock(manager, '_resolve_stack_id') manager._resolve_stack_id('teststack').AndReturn( 'teststack/abcd1234') diff --git a/heatclient/tests/test_resource_types.py b/heatclient/tests/test_resource_types.py index b5e3cb0..16a6190 100644 --- a/heatclient/tests/test_resource_types.py +++ b/heatclient/tests/test_resource_types.py @@ -13,7 +13,7 @@ import testtools -from heatclient.v1.resource_types import ResourceTypeManager +from heatclient.v1 import resource_types class ResourceTypeManagerTest(testtools.TestCase): @@ -31,7 +31,7 @@ class ResourceTypeManagerTest(testtools.TestCase): ret = key and {key: []} or {} return {}, {key: ret} - manager = ResourceTypeManager(FakeAPI()) + manager = resource_types.ResourceTypeManager(FakeAPI()) return manager def test_list_types(self): @@ -47,7 +47,7 @@ class ResourceTypeManagerTest(testtools.TestCase): assert ('GET', args[0]) == expect return FakeResponse() - manager = ResourceTypeManager(FakeClient()) + manager = resource_types.ResourceTypeManager(FakeClient()) manager.list() def test_get(self): diff --git a/heatclient/tests/test_resources.py b/heatclient/tests/test_resources.py index 889426b..a5f70e3 100644 --- a/heatclient/tests/test_resources.py +++ b/heatclient/tests/test_resources.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -from heatclient.v1.resources import ResourceManager +from heatclient.v1 import resources from mox3 import mox import testtools @@ -39,7 +39,7 @@ class ResourceManagerTest(testtools.TestCase): ret = key and {key: []} or {} return {}, {key: ret} - manager = ResourceManager(FakeAPI()) + manager = resources.ResourceManager(FakeAPI()) self.m.StubOutWithMock(manager, '_resolve_stack_id') manager._resolve_stack_id('teststack').AndReturn('teststack/abcd1234') self.m.ReplayAll() @@ -82,7 +82,7 @@ class ResourceManagerTest(testtools.TestCase): assert args[0] == expect return FakeResponse() - manager = ResourceManager(FakeClient()) + manager = resources.ResourceManager(FakeClient()) self.m.StubOutWithMock(manager, '_resolve_stack_id') manager._resolve_stack_id('teststack').AndReturn('teststack/abcd1234') self.m.ReplayAll() @@ -103,7 +103,7 @@ class ResourceManagerTest(testtools.TestCase): assert args[0] == expect return FakeResponse() - manager = ResourceManager(FakeClient()) + manager = resources.ResourceManager(FakeClient()) self.m.StubOutWithMock(manager, '_resolve_stack_id') manager._resolve_stack_id('teststack').AndReturn('teststack/abcd1234') self.m.ReplayAll() diff --git a/heatclient/tests/test_software_configs.py b/heatclient/tests/test_software_configs.py index 4313e7b..9cc87e4 100644 --- a/heatclient/tests/test_software_configs.py +++ b/heatclient/tests/test_software_configs.py @@ -13,8 +13,7 @@ import mock import testtools -from heatclient.v1.software_configs import SoftwareConfig -from heatclient.v1.software_configs import SoftwareConfigManager +from heatclient.v1 import software_configs class SoftwareConfigTest(testtools.TestCase): @@ -22,7 +21,8 @@ class SoftwareConfigTest(testtools.TestCase): def setUp(self): super(SoftwareConfigTest, self).setUp() config_id = 'bca6871d-86c0-4aff-b792-58a1f6947b57' - self.config = SoftwareConfig(mock.MagicMock(), info={'id': config_id}) + self.config = software_configs.SoftwareConfig(mock.MagicMock(), + info={'id': config_id}) self.config_id = config_id def test_delete(self): @@ -44,7 +44,7 @@ class SoftwareConfigManagerTest(testtools.TestCase): def setUp(self): super(SoftwareConfigManagerTest, self).setUp() - self.manager = SoftwareConfigManager(mock.MagicMock()) + self.manager = software_configs.SoftwareConfigManager(mock.MagicMock()) def test_get(self): config_id = 'bca6871d-86c0-4aff-b792-58a1f6947b57' @@ -60,7 +60,8 @@ class SoftwareConfigManagerTest(testtools.TestCase): self.manager.client.json_request.return_value = ( {}, {'software_config': data}) result = self.manager.get(config_id=config_id) - self.assertEqual(SoftwareConfig(self.manager, data), result) + self.assertEqual(software_configs.SoftwareConfig(self.manager, data), + result) call_args = self.manager.client.json_request.call_args self.assertEqual( ('GET', '/software_configs/%s' % config_id), *call_args) @@ -79,7 +80,8 @@ class SoftwareConfigManagerTest(testtools.TestCase): self.manager.client.json_request.return_value = ( {}, {'software_config': data}) result = self.manager.create(**body) - self.assertEqual(SoftwareConfig(self.manager, data), result) + self.assertEqual(software_configs.SoftwareConfig(self.manager, data), + result) args, kargs = self.manager.client.json_request.call_args self.assertEqual('POST', args[0]) self.assertEqual('/software_configs', args[1]) diff --git a/heatclient/tests/test_software_deployments.py b/heatclient/tests/test_software_deployments.py index c80b292..fedb742 100644 --- a/heatclient/tests/test_software_deployments.py +++ b/heatclient/tests/test_software_deployments.py @@ -13,8 +13,7 @@ import mock import testtools -from heatclient.v1.software_deployments import SoftwareDeployment -from heatclient.v1.software_deployments import SoftwareDeploymentManager +from heatclient.v1 import software_deployments class SoftwareDeploymentTest(testtools.TestCase): @@ -22,7 +21,7 @@ class SoftwareDeploymentTest(testtools.TestCase): def setUp(self): super(SoftwareDeploymentTest, self).setUp() deployment_id = 'bca6871d-86c0-4aff-b792-58a1f6947b57' - self.deployment = SoftwareDeployment( + self.deployment = software_deployments.SoftwareDeployment( mock.MagicMock(), info={'id': deployment_id}) self.deployment_id = deployment_id @@ -48,7 +47,8 @@ class SoftwareDeploymentManagerTest(testtools.TestCase): def setUp(self): super(SoftwareDeploymentManagerTest, self).setUp() - self.manager = SoftwareDeploymentManager(mock.MagicMock()) + self.manager = software_deployments.SoftwareDeploymentManager( + mock.MagicMock()) def test_list(self): server_id = 'fc01f89f-e151-4dc5-9c28-543c0d20ed6a' @@ -102,7 +102,8 @@ class SoftwareDeploymentManagerTest(testtools.TestCase): self.manager.client.json_request.return_value = ( {}, {'software_deployment': data}) result = self.manager.get(deployment_id=deployment_id) - self.assertEqual(SoftwareDeployment(self.manager, data), result) + self.assertEqual(software_deployments.SoftwareDeployment( + self.manager, data), result) call_args = self.manager.client.json_request.call_args self.assertEqual( ('GET', '/software_deployments/%s' % deployment_id), *call_args) @@ -124,7 +125,8 @@ class SoftwareDeploymentManagerTest(testtools.TestCase): self.manager.client.json_request.return_value = ( {}, {'software_deployment': data}) result = self.manager.create(**body) - self.assertEqual(SoftwareDeployment(self.manager, data), result) + self.assertEqual(software_deployments.SoftwareDeployment( + self.manager, data), result) args, kwargs = self.manager.client.json_request.call_args self.assertEqual('POST', args[0]) self.assertEqual('/software_deployments', args[1]) @@ -154,7 +156,8 @@ class SoftwareDeploymentManagerTest(testtools.TestCase): self.manager.client.json_request.return_value = ( {}, {'software_deployment': data}) result = self.manager.update(deployment_id, **body) - self.assertEqual(SoftwareDeployment(self.manager, data), result) + self.assertEqual(software_deployments.SoftwareDeployment( + self.manager, data), result) args, kwargs = self.manager.client.json_request.call_args self.assertEqual('PUT', args[0]) self.assertEqual('/software_deployments/%s' % deployment_id, args[1]) diff --git a/heatclient/tests/test_stacks.py b/heatclient/tests/test_stacks.py index 0d7b0c3..12ebdc0 100644 --- a/heatclient/tests/test_stacks.py +++ b/heatclient/tests/test_stacks.py @@ -9,19 +9,18 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -from heatclient.v1.stacks import Stack -from heatclient.v1.stacks import StackManager +from heatclient.v1 import stacks -from mock import MagicMock +import mock import testscenarios -from testscenarios.scenarios import multiply_scenarios +from testscenarios import scenarios as scnrs import testtools load_tests = testscenarios.load_tests_apply_scenarios def mock_stack(manager, stack_name, stack_id): - return Stack(manager, { + return stacks.Stack(manager, { "id": stack_id, "stack_name": stack_name, "links": [{ @@ -38,7 +37,7 @@ def mock_stack(manager, stack_name, stack_id): class StackStatusActionTest(testtools.TestCase): - scenarios = multiply_scenarios([ + scenarios = scnrs.multiply_scenarios([ ('CREATE', dict(action='CREATE')), ('DELETE', dict(action='DELETE')), ('UPDATE', dict(action='UPDATE')), @@ -70,70 +69,70 @@ class StackIdentifierTest(testtools.TestCase): class StackOperationsTest(testtools.TestCase): def test_delete_stack(self): - manager = MagicMock() + manager = mock.MagicMock() stack = mock_stack(manager, 'the_stack', 'abcd1234') stack.delete() manager.delete.assert_called_once_with('the_stack/abcd1234') def test_abandon_stack(self): - manager = MagicMock() + manager = mock.MagicMock() stack = mock_stack(manager, 'the_stack', 'abcd1234') stack.abandon() manager.abandon.assert_called_once_with('the_stack/abcd1234') def test_get_stack(self): - manager = MagicMock() + manager = mock.MagicMock() stack = mock_stack(manager, 'the_stack', 'abcd1234') stack.get() manager.get.assert_called_once_with('the_stack/abcd1234') def test_update_stack(self): - manager = MagicMock() + manager = mock.MagicMock() stack = mock_stack(manager, 'the_stack', 'abcd1234') stack.update() manager.update.assert_called_once_with('the_stack/abcd1234') def test_create_stack(self): - manager = MagicMock() + manager = mock.MagicMock() stack = mock_stack(manager, 'the_stack', 'abcd1234') stack = stack.create() manager.create.assert_called_once_with('the_stack/abcd1234') def test_preview_stack(self): - manager = MagicMock() + manager = mock.MagicMock() stack = mock_stack(manager, 'the_stack', 'abcd1234') stack = stack.preview() manager.preview.assert_called_once_with() def test_snapshot(self): - manager = MagicMock() + manager = mock.MagicMock() stack = mock_stack(manager, 'the_stack', 'abcd1234') stack.snapshot('foo') manager.snapshot.assert_called_once_with('the_stack/abcd1234', 'foo') def test_snapshot_show(self): - manager = MagicMock() + manager = mock.MagicMock() stack = mock_stack(manager, 'the_stack', 'abcd1234') stack.snapshot_show('snap1234') manager.snapshot_show.assert_called_once_with( 'the_stack/abcd1234', 'snap1234') def test_snapshot_delete(self): - manager = MagicMock() + manager = mock.MagicMock() stack = mock_stack(manager, 'the_stack', 'abcd1234') stack.snapshot_delete('snap1234') manager.snapshot_delete.assert_called_once_with( 'the_stack/abcd1234', 'snap1234') def test_restore(self): - manager = MagicMock() + manager = mock.MagicMock() stack = mock_stack(manager, 'the_stack', 'abcd1234') stack.restore('snap1234') manager.restore.assert_called_once_with( 'the_stack/abcd1234', 'snap1234') def test_snapshot_list(self): - manager = MagicMock() + manager = mock.MagicMock() stack = mock_stack(manager, 'the_stack', 'abcd1234') stack.snapshot_list() manager.snapshot_list.assert_called_once_with('the_stack/abcd1234') @@ -160,8 +159,8 @@ class StackManagerNoPaginationTest(testtools.TestCase): limit = 50 def mock_manager(self): - manager = StackManager(None) - manager._list = MagicMock() + manager = stacks.StackManager(None) + manager._list = mock.MagicMock() def mock_list(*args, **kwargs): def results(): @@ -260,8 +259,8 @@ class StackManagerPaginationTest(testtools.TestCase): limit = 50 def mock_manager(self): - manager = StackManager(None) - manager._list = MagicMock() + manager = stacks.StackManager(None) + manager._list = mock.MagicMock() def mock_list(arg_url, arg_response_key): try: diff --git a/heatclient/tests/test_template_utils.py b/heatclient/tests/test_template_utils.py index 78679e2..bf38c38 100644 --- a/heatclient/tests/test_template_utils.py +++ b/heatclient/tests/test_template_utils.py @@ -19,7 +19,7 @@ import six from six.moves.urllib import request import tempfile import testtools -from testtools.matchers import MatchesRegex +from testtools import matchers import yaml from heatclient.common import template_utils @@ -429,7 +429,7 @@ class TestGetTemplateContents(testtools.TestCase): tmpl_file.name) self.assertThat( str(ex), - MatchesRegex( + matchers.MatchesRegex( 'Error parsing template file://%s ' % tmpl_file.name)) def test_get_template_contents_url(self): diff --git a/heatclient/v1/__init__.py b/heatclient/v1/__init__.py index d801aba..0661739 100644 --- a/heatclient/v1/__init__.py +++ b/heatclient/v1/__init__.py @@ -15,4 +15,4 @@ __all__ = ['Client'] -from heatclient.v1.client import Client +from heatclient.v1.client import Client # noqa @@ -29,7 +29,5 @@ downloadcache = ~/cache/pip [flake8] show-source = True -# H302: Do not import objects, only modules -ignore = H302 exclude=.venv,.git,.tox,dist,*openstack/common*,*lib/python*,*egg,build max-complexity=20 |