Move tests: unit/network_services/helpers 63/58763/9
authorEmma Foley <emma.l.foley@intel.com>
Fri, 27 Apr 2018 10:33:17 +0000 (10:33 +0000)
committerEmma Foley <emma.l.foley@intel.com>
Tue, 26 Jun 2018 11:03:05 +0000 (11:03 +0000)
* Fix pylint errors
* Add TODOs

Some errors are ignored locally, as they were a symptom of other problems.
These issues have been flagged with a TODO, and should be fixed later.

JIRA: YARDSTICK-837
Signed-off-by: Emma Foley <emma.l.foley@intel.com>
Change-Id: If0b77a6e0b102071ecfb212362647c62a621e4f9
(cherry-picked from commit 065c00d3147d12c692d43179d9c1c9afadb97825)

yardstick/tests/unit/network_services/helpers/__init__.py [moved from tests/unit/network_services/helpers/__init__.py with 100% similarity]
yardstick/tests/unit/network_services/helpers/acl_vnf_topology_ixia.yaml [moved from tests/unit/network_services/helpers/acl_vnf_topology_ixia.yaml with 100% similarity]
yardstick/tests/unit/network_services/helpers/test_cpu.py [moved from tests/unit/network_services/helpers/test_cpu.py with 82% similarity]
yardstick/tests/unit/network_services/helpers/test_dpdkbindnic_helper.py [moved from tests/unit/network_services/helpers/test_dpdkbindnic_helper.py with 100% similarity]
yardstick/tests/unit/network_services/helpers/test_iniparser.py [moved from tests/unit/network_services/helpers/test_iniparser.py with 97% similarity]
yardstick/tests/unit/network_services/helpers/test_samplevnf_helper.py [moved from tests/unit/network_services/helpers/test_samplevnf_helper.py with 99% similarity]

@@ -13,7 +13,6 @@
 # limitations under the License.
 #
 
-from __future__ import absolute_import
 from __future__ import division
 import unittest
 import mock
@@ -25,15 +24,20 @@ from yardstick.network_services.helpers.cpu import \
 
 class TestCpuSysCores(unittest.TestCase):
 
+    def setUp(self):
+        self._mock_ssh = mock.patch("yardstick.ssh.SSH")
+        self.mock_ssh = self._mock_ssh.start()
+
+        self.addCleanup(self._cleanup)
+
+    def _cleanup(self):
+        self._mock_ssh.stop()
+
     def test___init__(self):
-        with mock.patch("yardstick.ssh.SSH") as ssh:
-            ssh_mock = mock.Mock(autospec=ssh.SSH)
-            ssh_mock.execute = \
-                mock.Mock(return_value=(1, "", ""))
-            ssh_mock.put = \
-                mock.Mock(return_value=(1, "", ""))
-            cpu_topo = CpuSysCores(ssh_mock)
-            self.assertIsNotNone(cpu_topo.connection)
+        self.mock_ssh.execute.return_value = 1, "", ""
+        self.mock_ssh.put.return_value = 1, "", ""
+        cpu_topo = CpuSysCores(self.mock_ssh)
+        self.assertIsNotNone(cpu_topo.connection)
 
     def test__get_core_details(self):
         with mock.patch("yardstick.ssh.SSH") as ssh:
@@ -52,7 +56,7 @@ class TestCpuSysCores(unittest.TestCase):
         with mock.patch("yardstick.ssh.SSH") as ssh:
             ssh_mock = mock.Mock(autospec=ssh.SSH)
             ssh_mock.execute = \
-                    mock.Mock(return_value=(1, "cpu:1\ntest:2\n \n", ""))
+                mock.Mock(return_value=(1, "cpu:1\ntest:2\n \n", ""))
             ssh_mock.put = \
                 mock.Mock(return_value=(1, "", ""))
             cpu_topo = CpuSysCores(ssh_mock)
@@ -68,7 +72,7 @@ class TestCpuSysCores(unittest.TestCase):
         with mock.patch("yardstick.ssh.SSH") as ssh:
             ssh_mock = mock.Mock(autospec=ssh.SSH)
             ssh_mock.execute = \
-                    mock.Mock(return_value=(1, "cpu:1\ntest:2\n \n", ""))
+                mock.Mock(return_value=(1, "cpu:1\ntest:2\n \n", ""))
             ssh_mock.put = \
                 mock.Mock(return_value=(1, "", ""))
             cpu_topo = CpuSysCores(ssh_mock)
@@ -77,14 +81,14 @@ class TestCpuSysCores(unittest.TestCase):
                 mock.Mock(side_effect=[[{'Core(s) per socket': '2', 'Thread(s) per core': '1'}],
                                        [{'physical id': '2', 'processor': '1'}]])
             cpu_topo.core_map = \
-                {'thread_per_core': '1', '2':['1'], 'cores_per_socket': '2'}
+                {'thread_per_core': '1', '2': ['1'], 'cores_per_socket': '2'}
             self.assertEqual(-1, cpu_topo.validate_cpu_cfg())
 
     def test_validate_cpu_cfg_2t(self):
         with mock.patch("yardstick.ssh.SSH") as ssh:
             ssh_mock = mock.Mock(autospec=ssh.SSH)
             ssh_mock.execute = \
-                    mock.Mock(return_value=(1, "cpu:1\ntest:2\n \n", ""))
+                mock.Mock(return_value=(1, "cpu:1\ntest:2\n \n", ""))
             ssh_mock.put = \
                 mock.Mock(return_value=(1, "", ""))
             cpu_topo = CpuSysCores(ssh_mock)
@@ -93,7 +97,7 @@ class TestCpuSysCores(unittest.TestCase):
                 mock.Mock(side_effect=[[{'Core(s) per socket': '2', 'Thread(s) per core': '1'}],
                                        [{'physical id': '2', 'processor': '1'}]])
             cpu_topo.core_map = \
-                {'thread_per_core': 1, '2':['1'], 'cores_per_socket': '2'}
+                {'thread_per_core': 1, '2': ['1'], 'cores_per_socket': '2'}
             vnf_cfg = {'lb_config': 'SW', 'lb_count': 1, 'worker_config':
                        '1C/2T', 'worker_threads': 1}
             self.assertEqual(-1, cpu_topo.validate_cpu_cfg(vnf_cfg))
@@ -102,7 +106,7 @@ class TestCpuSysCores(unittest.TestCase):
         with mock.patch("yardstick.ssh.SSH") as ssh:
             ssh_mock = mock.Mock(autospec=ssh.SSH)
             ssh_mock.execute = \
-                    mock.Mock(return_value=(1, "cpu:1\ntest:2\n \n", ""))
+                mock.Mock(return_value=(1, "cpu:1\ntest:2\n \n", ""))
             ssh_mock.put = \
                 mock.Mock(return_value=(1, "", ""))
             cpu_topo = CpuSysCores(ssh_mock)
@@ -111,7 +115,7 @@ class TestCpuSysCores(unittest.TestCase):
                 mock.Mock(side_effect=[[{'Core(s) per socket': '2', 'Thread(s) per core': '1'}],
                                        [{'physical id': '2', 'processor': '1'}]])
             cpu_topo.core_map = \
-                {'thread_per_core': 1, '2':[1], 'cores_per_socket': 2}
+                {'thread_per_core': 1, '2': [1], 'cores_per_socket': 2}
             vnf_cfg = {'lb_config': 'SW', 'lb_count': 1, 'worker_config':
                        '1C/1T', 'worker_threads': 1}
             self.assertEqual(-1, cpu_topo.validate_cpu_cfg(vnf_cfg))
 # limitations under the License.
 #
 
-from __future__ import absolute_import
-
 import unittest
 from contextlib import contextmanager
 import mock
 
-from tests.unit import STL_MOCKS
+from yardstick.tests import STL_MOCKS
 
 
 STLClient = mock.MagicMock()
@@ -105,7 +103,7 @@ class TestBaseParser(unittest.TestCase):
     @staticmethod
     def make_open(text_blob):
         @contextmanager
-        def internal_open(*args, **kwargs):
+        def internal_open(*args):
             yield text_blob.split('\n')
 
         return internal_open
@@ -136,7 +134,7 @@ class TestConfigParser(unittest.TestCase):
     @staticmethod
     def make_open(text_blob):
         @contextmanager
-        def internal_open(*args, **kwargs):
+        def internal_open(*args):
             yield text_blob.split('\n')
 
         return internal_open
@@ -700,7 +700,6 @@ class TestMultiPortConfig(unittest.TestCase):
         self.assertIsNone(result)
 
     def test_generate_arp_route_tbl(self):
-        # ELF: could n=do this in setup
         topology_file = mock.Mock()
         config_tpl = mock.Mock()
         tmp_file = ""