diff options
Diffstat (limited to 'tests/unit/benchmark/contexts')
-rw-r--r-- | tests/unit/benchmark/contexts/test_dummy.py | 1 | ||||
-rw-r--r-- | tests/unit/benchmark/contexts/test_heat.py | 25 | ||||
-rw-r--r-- | tests/unit/benchmark/contexts/test_model.py | 5 | ||||
-rw-r--r-- | tests/unit/benchmark/contexts/test_node.py | 2 |
4 files changed, 24 insertions, 9 deletions
diff --git a/tests/unit/benchmark/contexts/test_dummy.py b/tests/unit/benchmark/contexts/test_dummy.py index 5214e6630..1a54035df 100644 --- a/tests/unit/benchmark/contexts/test_dummy.py +++ b/tests/unit/benchmark/contexts/test_dummy.py @@ -11,6 +11,7 @@ # Unittest for yardstick.benchmark.contexts.dummy +from __future__ import absolute_import import unittest from yardstick.benchmark.contexts import dummy diff --git a/tests/unit/benchmark/contexts/test_heat.py b/tests/unit/benchmark/contexts/test_heat.py index dd830a485..f8f349205 100644 --- a/tests/unit/benchmark/contexts/test_heat.py +++ b/tests/unit/benchmark/contexts/test_heat.py @@ -11,14 +11,21 @@ # Unittest for yardstick.benchmark.contexts.heat +from __future__ import absolute_import + +import logging import os -import mock import unittest +import uuid + +import mock -from yardstick.benchmark.contexts import model from yardstick.benchmark.contexts import heat +LOG = logging.getLogger(__name__) + + class HeatContextTestCase(unittest.TestCase): def setUp(self): @@ -70,7 +77,8 @@ class HeatContextTestCase(unittest.TestCase): 'bar', self.test_context, networks['bar']) self.assertTrue(len(self.test_context.networks) == 1) - mock_server.assert_called_with('baz', self.test_context, servers['baz']) + mock_server.assert_called_with('baz', self.test_context, + servers['baz']) self.assertTrue(len(self.test_context.servers) == 1) if os.path.exists(self.test_context.key_filename): @@ -78,7 +86,8 @@ class HeatContextTestCase(unittest.TestCase): os.remove(self.test_context.key_filename) os.remove(self.test_context.key_filename + ".pub") except OSError: - LOG.exception("key_filename: %s", e.key_filename) + LOG.exception("key_filename: %s", + self.test_context.key_filename) @mock.patch('yardstick.benchmark.contexts.heat.HeatTemplate') def test__add_resources_to_template_no_servers(self, mock_template): @@ -88,8 +97,9 @@ class HeatContextTestCase(unittest.TestCase): self.test_context.key_uuid = "2f2e4997-0a8e-4eb7-9fa4-f3f8fbbc393b" self.test_context._add_resources_to_template(mock_template) - mock_template.add_keypair.assert_called_with("foo-key", - "2f2e4997-0a8e-4eb7-9fa4-f3f8fbbc393b") + mock_template.add_keypair.assert_called_with( + "foo-key", + "2f2e4997-0a8e-4eb7-9fa4-f3f8fbbc393b") mock_template.add_security_group.assert_called_with("foo-secgroup") @mock.patch('yardstick.benchmark.contexts.heat.HeatTemplate') @@ -113,12 +123,13 @@ class HeatContextTestCase(unittest.TestCase): self.assertTrue(mock_template.delete.called) - def test__get_server(self): self.mock_context.name = 'bar' self.mock_context.stack.outputs = {'public_ip': '127.0.0.1', 'private_ip': '10.0.0.1'} + self.mock_context.key_uuid = uuid.uuid4() + attr_name = {'name': 'foo.bar', 'public_ip_attr': 'public_ip', 'private_ip_attr': 'private_ip'} diff --git a/tests/unit/benchmark/contexts/test_model.py b/tests/unit/benchmark/contexts/test_model.py index a1978e320..537a8c008 100644 --- a/tests/unit/benchmark/contexts/test_model.py +++ b/tests/unit/benchmark/contexts/test_model.py @@ -11,6 +11,7 @@ # Unittest for yardstick.benchmark.contexts.model +from __future__ import absolute_import import mock import unittest @@ -119,7 +120,8 @@ class NetworkTestCase(unittest.TestCase): attrs = {'external_network': 'ext_net'} test_network = model.Network('foo', self.mock_context, attrs) - exp_router = model.Router('router', 'foo', self.mock_context, 'ext_net') + exp_router = model.Router('router', 'foo', self.mock_context, + 'ext_net') self.assertEqual(test_network.router.stack_name, exp_router.stack_name) self.assertEqual(test_network.router.stack_if_name, @@ -219,4 +221,3 @@ class ServerTestCase(unittest.TestCase): user=self.mock_context.user, key_name=self.mock_context.keypair_name, scheduler_hints='hints') - diff --git a/tests/unit/benchmark/contexts/test_node.py b/tests/unit/benchmark/contexts/test_node.py index 6939b8551..de5ba7066 100644 --- a/tests/unit/benchmark/contexts/test_node.py +++ b/tests/unit/benchmark/contexts/test_node.py @@ -11,6 +11,7 @@ # Unittest for yardstick.benchmark.contexts.node +from __future__ import absolute_import import os import unittest @@ -21,6 +22,7 @@ class NodeContextTestCase(unittest.TestCase): NODES_SAMPLE = "nodes_sample.yaml" NODES_DUPLICATE_SAMPLE = "nodes_duplicate_sample.yaml" + def setUp(self): self.test_context = node.NodeContext() |