From 2e75e6d27240945ec985998bbe9ec6241d11626a Mon Sep 17 00:00:00 2001 From: Emma Foley Date: Fri, 27 Apr 2018 10:29:27 +0000 Subject: [PATCH] Move tests: unit/network_services/{lib/,collector/,*.py} * 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 Change-Id: Idc2e70291b6d9b4cf7e7249a10c4a290b999206c --- .../tests/unit/network_services}/__init__.py | 0 .../tests/unit/network_services/collector}/__init__.py | 0 .../unit/network_services/collector/test_publisher.py | 3 --- .../unit/network_services/collector/test_subscriber.py | 3 --- .../tests/unit/network_services/libs}/__init__.py | 0 .../tests/unit/network_services/libs/ixia_libs/__init__.py | 0 .../unit/network_services/libs/ixia_libs/test_IxNet.py | 14 +++++--------- .../tests}/unit/network_services/test_utils.py | 2 -- .../tests}/unit/network_services/test_yang_model.py | 12 +++--------- 9 files changed, 8 insertions(+), 26 deletions(-) rename {tests/unit/network_services/collector => yardstick/tests/unit/network_services}/__init__.py (100%) rename {tests/unit/network_services/libs => yardstick/tests/unit/network_services/collector}/__init__.py (100%) rename {tests => yardstick/tests}/unit/network_services/collector/test_publisher.py (91%) rename {tests => yardstick/tests}/unit/network_services/collector/test_subscriber.py (96%) rename {tests/unit/network_services/libs/ixia_libs => yardstick/tests/unit/network_services/libs}/__init__.py (100%) create mode 100644 yardstick/tests/unit/network_services/libs/ixia_libs/__init__.py rename {tests => yardstick/tests}/unit/network_services/libs/ixia_libs/test_IxNet.py (98%) rename {tests => yardstick/tests}/unit/network_services/test_utils.py (99%) rename {tests => yardstick/tests}/unit/network_services/test_yang_model.py (96%) diff --git a/tests/unit/network_services/collector/__init__.py b/yardstick/tests/unit/network_services/__init__.py similarity index 100% rename from tests/unit/network_services/collector/__init__.py rename to yardstick/tests/unit/network_services/__init__.py diff --git a/tests/unit/network_services/libs/__init__.py b/yardstick/tests/unit/network_services/collector/__init__.py similarity index 100% rename from tests/unit/network_services/libs/__init__.py rename to yardstick/tests/unit/network_services/collector/__init__.py diff --git a/tests/unit/network_services/collector/test_publisher.py b/yardstick/tests/unit/network_services/collector/test_publisher.py similarity index 91% rename from tests/unit/network_services/collector/test_publisher.py rename to yardstick/tests/unit/network_services/collector/test_publisher.py index 4a175841d..145441ddd 100644 --- a/tests/unit/network_services/collector/test_publisher.py +++ b/yardstick/tests/unit/network_services/collector/test_publisher.py @@ -13,9 +13,6 @@ # limitations under the License. # -# Unittest for yardstick.network_services.collector.publisher - -from __future__ import absolute_import import unittest from yardstick.network_services.collector import publisher diff --git a/tests/unit/network_services/collector/test_subscriber.py b/yardstick/tests/unit/network_services/collector/test_subscriber.py similarity index 96% rename from tests/unit/network_services/collector/test_subscriber.py rename to yardstick/tests/unit/network_services/collector/test_subscriber.py index d4b4ecf7a..9b9649979 100644 --- a/tests/unit/network_services/collector/test_subscriber.py +++ b/yardstick/tests/unit/network_services/collector/test_subscriber.py @@ -13,9 +13,6 @@ # limitations under the License. # -# Unittest for yardstick.network_services.collector.subscriber - -from __future__ import absolute_import import unittest import mock diff --git a/tests/unit/network_services/libs/ixia_libs/__init__.py b/yardstick/tests/unit/network_services/libs/__init__.py similarity index 100% rename from tests/unit/network_services/libs/ixia_libs/__init__.py rename to yardstick/tests/unit/network_services/libs/__init__.py diff --git a/yardstick/tests/unit/network_services/libs/ixia_libs/__init__.py b/yardstick/tests/unit/network_services/libs/ixia_libs/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/unit/network_services/libs/ixia_libs/test_IxNet.py b/yardstick/tests/unit/network_services/libs/ixia_libs/test_IxNet.py similarity index 98% rename from tests/unit/network_services/libs/ixia_libs/test_IxNet.py rename to yardstick/tests/unit/network_services/libs/ixia_libs/test_IxNet.py index 2a97048aa..fe750e5ba 100644 --- a/tests/unit/network_services/libs/ixia_libs/test_IxNet.py +++ b/yardstick/tests/unit/network_services/libs/ixia_libs/test_IxNet.py @@ -13,9 +13,6 @@ # limitations under the License. # -# Unittest for yardstick.network_services.libs.ixia_libs.IxNet - -from __future__ import absolute_import import unittest import mock @@ -23,10 +20,10 @@ from yardstick.network_services.libs.ixia_libs.IxNet.IxNet import IxNextgen from yardstick.network_services.libs.ixia_libs.IxNet.IxNet import IP_VERSION_4 from yardstick.network_services.libs.ixia_libs.IxNet.IxNet import IP_VERSION_6 - UPLINK = "uplink" DOWNLINK = "downlink" + class TestIxNextgen(unittest.TestCase): def test___init__(self): @@ -40,7 +37,8 @@ class TestIxNextgen(unittest.TestCase): ixnet_gen.get_config = mock.MagicMock() ixnet_gen.get_ixnet = mock.MagicMock() - self.assertRaises(ImportError, ixnet_gen._connect, {"py_lib_path": "/tmp"}) + self.assertRaises(ImportError, ixnet_gen._connect, + {"py_lib_path": "/tmp"}) def test_clear_ixia_config(self): ixnet = mock.MagicMock() @@ -628,11 +626,9 @@ class TestIxNextgen(unittest.TestCase): def test_set_random_ip_multi_attributes_bad_ip_version(self): bad_ip_version = object() ixnet_gen = IxNextgen(mock.Mock()) - mock1 = mock.Mock() - mock2 = mock.Mock() - mock3 = mock.Mock() with self.assertRaises(ValueError): - ixnet_gen.set_random_ip_multi_attributes(mock1, bad_ip_version, mock2, mock3) + ixnet_gen.set_random_ip_multi_attributes( + mock.Mock(), bad_ip_version, mock.Mock(), mock.Mock()) def test_get_config(self): tg_cfg = { diff --git a/tests/unit/network_services/test_utils.py b/yardstick/tests/unit/network_services/test_utils.py similarity index 99% rename from tests/unit/network_services/test_utils.py rename to yardstick/tests/unit/network_services/test_utils.py index bf98a4474..2b2eb7109 100644 --- a/tests/unit/network_services/test_utils.py +++ b/yardstick/tests/unit/network_services/test_utils.py @@ -13,8 +13,6 @@ # limitations under the License. # -# Unittest for yardstick.network_services.utils - import os import unittest import mock diff --git a/tests/unit/network_services/test_yang_model.py b/yardstick/tests/unit/network_services/test_yang_model.py similarity index 96% rename from tests/unit/network_services/test_yang_model.py rename to yardstick/tests/unit/network_services/test_yang_model.py index 0b29da701..a7eb36b8a 100644 --- a/tests/unit/network_services/test_yang_model.py +++ b/yardstick/tests/unit/network_services/test_yang_model.py @@ -13,14 +13,8 @@ # limitations under the License. # -# Unittest for yardstick.network_services.utils - -from __future__ import absolute_import - -import unittest import mock - -import yaml +import unittest from yardstick.network_services.yang_model import YangModel @@ -95,9 +89,9 @@ class YangModelTestCase(unittest.TestCase): y._get_entries() self.assertEqual(y._rules, '') - @mock.patch('yardstick.network_services.yang_model.yaml_load') @mock.patch('yardstick.network_services.yang_model.open') - def test__read_config(self, mock_open, mock_safe_load): + @mock.patch('yardstick.network_services.yang_model.yaml_load') + def test__read_config(self, mock_safe_load, *args): cfg = "yang.yaml" y = YangModel(cfg) mock_safe_load.return_value = expected = {'key1': 'value1', 'key2': 'value2'} -- 2.16.6