diff options
Diffstat (limited to 'tests/unit/network_services')
24 files changed, 77 insertions, 1389 deletions
diff --git a/tests/unit/network_services/helpers/test_samplevnf_helper.py b/tests/unit/network_services/helpers/test_samplevnf_helper.py index b89668577..608f31747 100644 --- a/tests/unit/network_services/helpers/test_samplevnf_helper.py +++ b/tests/unit/network_services/helpers/test_samplevnf_helper.py @@ -198,6 +198,8 @@ class TestMultiPortConfig(unittest.TestCase): opnfv_vnf.get_ports_gateway6 = mock.Mock(return_value=u'1.1.1.1') opnfv_vnf.get_netmask_gateway6 = mock.Mock(return_value=u'255.255.255.0') opnfv_vnf.txrx_pipeline = '' + opnfv_vnf.vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] + opnfv_vnf.interfaces = opnfv_vnf.vnfd['vdu'][0]['external-interface'] opnfv_vnf.rules = '' self.assertIsNotNone(opnfv_vnf.generate_rule_config()) opnfv_vnf.rules = 'new' diff --git a/tests/unit/network_services/traffic_profile/test_fixed.py b/tests/unit/network_services/traffic_profile/test_fixed.py index 8b44719a1..84843178e 100644 --- a/tests/unit/network_services/traffic_profile/test_fixed.py +++ b/tests/unit/network_services/traffic_profile/test_fixed.py @@ -16,68 +16,11 @@ # from __future__ import absolute_import + import unittest import mock -STL_MOCKS = { - 'stl': mock.MagicMock(), - 'stl.trex_stl_lib': mock.MagicMock(), - 'stl.trex_stl_lib.base64': mock.MagicMock(), - 'stl.trex_stl_lib.binascii': mock.MagicMock(), - 'stl.trex_stl_lib.collections': mock.MagicMock(), - 'stl.trex_stl_lib.copy': mock.MagicMock(), - 'stl.trex_stl_lib.datetime': mock.MagicMock(), - 'stl.trex_stl_lib.functools': mock.MagicMock(), - 'stl.trex_stl_lib.imp': mock.MagicMock(), - 'stl.trex_stl_lib.inspect': mock.MagicMock(), - 'stl.trex_stl_lib.json': mock.MagicMock(), - 'stl.trex_stl_lib.linecache': mock.MagicMock(), - 'stl.trex_stl_lib.math': mock.MagicMock(), - 'stl.trex_stl_lib.os': mock.MagicMock(), - 'stl.trex_stl_lib.platform': mock.MagicMock(), - 'stl.trex_stl_lib.pprint': mock.MagicMock(), - 'stl.trex_stl_lib.random': mock.MagicMock(), - 'stl.trex_stl_lib.re': mock.MagicMock(), - 'stl.trex_stl_lib.scapy': mock.MagicMock(), - 'stl.trex_stl_lib.socket': mock.MagicMock(), - 'stl.trex_stl_lib.string': mock.MagicMock(), - 'stl.trex_stl_lib.struct': mock.MagicMock(), - 'stl.trex_stl_lib.sys': mock.MagicMock(), - 'stl.trex_stl_lib.threading': mock.MagicMock(), - 'stl.trex_stl_lib.time': mock.MagicMock(), - 'stl.trex_stl_lib.traceback': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_async_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_exceptions': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_ext': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_jsonrpc_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_packet_builder_interface': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_packet_builder_scapy': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_port': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_stats': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_streams': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_types': mock.MagicMock(), - 'stl.trex_stl_lib.types': mock.MagicMock(), - 'stl.trex_stl_lib.utils': mock.MagicMock(), - 'stl.trex_stl_lib.utils.argparse': mock.MagicMock(), - 'stl.trex_stl_lib.utils.collections': mock.MagicMock(), - 'stl.trex_stl_lib.utils.common': mock.MagicMock(), - 'stl.trex_stl_lib.utils.json': mock.MagicMock(), - 'stl.trex_stl_lib.utils.os': mock.MagicMock(), - 'stl.trex_stl_lib.utils.parsing_opts': mock.MagicMock(), - 'stl.trex_stl_lib.utils.pwd': mock.MagicMock(), - 'stl.trex_stl_lib.utils.random': mock.MagicMock(), - 'stl.trex_stl_lib.utils.re': mock.MagicMock(), - 'stl.trex_stl_lib.utils.string': mock.MagicMock(), - 'stl.trex_stl_lib.utils.sys': mock.MagicMock(), - 'stl.trex_stl_lib.utils.text_opts': mock.MagicMock(), - 'stl.trex_stl_lib.utils.text_tables': mock.MagicMock(), - 'stl.trex_stl_lib.utils.texttable': mock.MagicMock(), - 'stl.trex_stl_lib.warnings': mock.MagicMock(), - 'stl.trex_stl_lib.yaml': mock.MagicMock(), - 'stl.trex_stl_lib.zlib': mock.MagicMock(), - 'stl.trex_stl_lib.zmq': mock.MagicMock(), -} +from tests.unit import STL_MOCKS STLClient = mock.MagicMock() stl_patch = mock.patch.dict("sys.modules", STL_MOCKS) diff --git a/tests/unit/network_services/traffic_profile/test_ixia_rfc2544.py b/tests/unit/network_services/traffic_profile/test_ixia_rfc2544.py index 6dba64af9..b2cb9dfea 100644 --- a/tests/unit/network_services/traffic_profile/test_ixia_rfc2544.py +++ b/tests/unit/network_services/traffic_profile/test_ixia_rfc2544.py @@ -20,65 +20,7 @@ from __future__ import division import unittest import mock -STL_MOCKS = { - 'stl': mock.MagicMock(), - 'stl.trex_stl_lib': mock.MagicMock(), - 'stl.trex_stl_lib.base64': mock.MagicMock(), - 'stl.trex_stl_lib.binascii': mock.MagicMock(), - 'stl.trex_stl_lib.collections': mock.MagicMock(), - 'stl.trex_stl_lib.copy': mock.MagicMock(), - 'stl.trex_stl_lib.datetime': mock.MagicMock(), - 'stl.trex_stl_lib.functools': mock.MagicMock(), - 'stl.trex_stl_lib.imp': mock.MagicMock(), - 'stl.trex_stl_lib.inspect': mock.MagicMock(), - 'stl.trex_stl_lib.json': mock.MagicMock(), - 'stl.trex_stl_lib.linecache': mock.MagicMock(), - 'stl.trex_stl_lib.math': mock.MagicMock(), - 'stl.trex_stl_lib.os': mock.MagicMock(), - 'stl.trex_stl_lib.platform': mock.MagicMock(), - 'stl.trex_stl_lib.pprint': mock.MagicMock(), - 'stl.trex_stl_lib.random': mock.MagicMock(), - 'stl.trex_stl_lib.re': mock.MagicMock(), - 'stl.trex_stl_lib.scapy': mock.MagicMock(), - 'stl.trex_stl_lib.socket': mock.MagicMock(), - 'stl.trex_stl_lib.string': mock.MagicMock(), - 'stl.trex_stl_lib.struct': mock.MagicMock(), - 'stl.trex_stl_lib.sys': mock.MagicMock(), - 'stl.trex_stl_lib.threading': mock.MagicMock(), - 'stl.trex_stl_lib.time': mock.MagicMock(), - 'stl.trex_stl_lib.traceback': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_async_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_exceptions': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_ext': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_jsonrpc_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_packet_builder_interface': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_packet_builder_scapy': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_port': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_stats': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_streams': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_types': mock.MagicMock(), - 'stl.trex_stl_lib.types': mock.MagicMock(), - 'stl.trex_stl_lib.utils': mock.MagicMock(), - 'stl.trex_stl_lib.utils.argparse': mock.MagicMock(), - 'stl.trex_stl_lib.utils.collections': mock.MagicMock(), - 'stl.trex_stl_lib.utils.common': mock.MagicMock(), - 'stl.trex_stl_lib.utils.json': mock.MagicMock(), - 'stl.trex_stl_lib.utils.os': mock.MagicMock(), - 'stl.trex_stl_lib.utils.parsing_opts': mock.MagicMock(), - 'stl.trex_stl_lib.utils.pwd': mock.MagicMock(), - 'stl.trex_stl_lib.utils.random': mock.MagicMock(), - 'stl.trex_stl_lib.utils.re': mock.MagicMock(), - 'stl.trex_stl_lib.utils.string': mock.MagicMock(), - 'stl.trex_stl_lib.utils.sys': mock.MagicMock(), - 'stl.trex_stl_lib.utils.text_opts': mock.MagicMock(), - 'stl.trex_stl_lib.utils.text_tables': mock.MagicMock(), - 'stl.trex_stl_lib.utils.texttable': mock.MagicMock(), - 'stl.trex_stl_lib.warnings': mock.MagicMock(), - 'stl.trex_stl_lib.yaml': mock.MagicMock(), - 'stl.trex_stl_lib.zlib': mock.MagicMock(), - 'stl.trex_stl_lib.zmq': mock.MagicMock(), -} +from tests.unit import STL_MOCKS STLClient = mock.MagicMock() stl_patch = mock.patch.dict("sys.modules", STL_MOCKS) diff --git a/tests/unit/network_services/traffic_profile/test_prox_acl.py b/tests/unit/network_services/traffic_profile/test_prox_acl.py index 252c655da..be172f26b 100644 --- a/tests/unit/network_services/traffic_profile/test_prox_acl.py +++ b/tests/unit/network_services/traffic_profile/test_prox_acl.py @@ -14,69 +14,11 @@ # from __future__ import absolute_import -import unittest +import unittest import mock -STL_MOCKS = { - 'stl': mock.MagicMock(), - 'stl.trex_stl_lib': mock.MagicMock(), - 'stl.trex_stl_lib.base64': mock.MagicMock(), - 'stl.trex_stl_lib.binascii': mock.MagicMock(), - 'stl.trex_stl_lib.collections': mock.MagicMock(), - 'stl.trex_stl_lib.copy': mock.MagicMock(), - 'stl.trex_stl_lib.datetime': mock.MagicMock(), - 'stl.trex_stl_lib.functools': mock.MagicMock(), - 'stl.trex_stl_lib.imp': mock.MagicMock(), - 'stl.trex_stl_lib.inspect': mock.MagicMock(), - 'stl.trex_stl_lib.json': mock.MagicMock(), - 'stl.trex_stl_lib.linecache': mock.MagicMock(), - 'stl.trex_stl_lib.math': mock.MagicMock(), - 'stl.trex_stl_lib.os': mock.MagicMock(), - 'stl.trex_stl_lib.platform': mock.MagicMock(), - 'stl.trex_stl_lib.pprint': mock.MagicMock(), - 'stl.trex_stl_lib.random': mock.MagicMock(), - 'stl.trex_stl_lib.re': mock.MagicMock(), - 'stl.trex_stl_lib.scapy': mock.MagicMock(), - 'stl.trex_stl_lib.socket': mock.MagicMock(), - 'stl.trex_stl_lib.string': mock.MagicMock(), - 'stl.trex_stl_lib.struct': mock.MagicMock(), - 'stl.trex_stl_lib.sys': mock.MagicMock(), - 'stl.trex_stl_lib.threading': mock.MagicMock(), - 'stl.trex_stl_lib.time': mock.MagicMock(), - 'stl.trex_stl_lib.traceback': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_async_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_exceptions': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_ext': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_jsonrpc_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_packet_builder_interface': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_packet_builder_scapy': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_port': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_stats': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_streams': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_types': mock.MagicMock(), - 'stl.trex_stl_lib.types': mock.MagicMock(), - 'stl.trex_stl_lib.utils': mock.MagicMock(), - 'stl.trex_stl_lib.utils.argparse': mock.MagicMock(), - 'stl.trex_stl_lib.utils.collections': mock.MagicMock(), - 'stl.trex_stl_lib.utils.common': mock.MagicMock(), - 'stl.trex_stl_lib.utils.json': mock.MagicMock(), - 'stl.trex_stl_lib.utils.os': mock.MagicMock(), - 'stl.trex_stl_lib.utils.parsing_opts': mock.MagicMock(), - 'stl.trex_stl_lib.utils.pwd': mock.MagicMock(), - 'stl.trex_stl_lib.utils.random': mock.MagicMock(), - 'stl.trex_stl_lib.utils.re': mock.MagicMock(), - 'stl.trex_stl_lib.utils.string': mock.MagicMock(), - 'stl.trex_stl_lib.utils.sys': mock.MagicMock(), - 'stl.trex_stl_lib.utils.text_opts': mock.MagicMock(), - 'stl.trex_stl_lib.utils.text_tables': mock.MagicMock(), - 'stl.trex_stl_lib.utils.texttable': mock.MagicMock(), - 'stl.trex_stl_lib.warnings': mock.MagicMock(), - 'stl.trex_stl_lib.yaml': mock.MagicMock(), - 'stl.trex_stl_lib.zlib': mock.MagicMock(), - 'stl.trex_stl_lib.zmq': mock.MagicMock(), -} +from tests.unit import STL_MOCKS STLClient = mock.MagicMock() stl_patch = mock.patch.dict("sys.modules", STL_MOCKS) diff --git a/tests/unit/network_services/traffic_profile/test_prox_binsearch.py b/tests/unit/network_services/traffic_profile/test_prox_binsearch.py index 74e6121a7..72b86709c 100644 --- a/tests/unit/network_services/traffic_profile/test_prox_binsearch.py +++ b/tests/unit/network_services/traffic_profile/test_prox_binsearch.py @@ -14,69 +14,11 @@ # from __future__ import absolute_import -import unittest +import unittest import mock -STL_MOCKS = { - 'stl': mock.MagicMock(), - 'stl.trex_stl_lib': mock.MagicMock(), - 'stl.trex_stl_lib.base64': mock.MagicMock(), - 'stl.trex_stl_lib.binascii': mock.MagicMock(), - 'stl.trex_stl_lib.collections': mock.MagicMock(), - 'stl.trex_stl_lib.copy': mock.MagicMock(), - 'stl.trex_stl_lib.datetime': mock.MagicMock(), - 'stl.trex_stl_lib.functools': mock.MagicMock(), - 'stl.trex_stl_lib.imp': mock.MagicMock(), - 'stl.trex_stl_lib.inspect': mock.MagicMock(), - 'stl.trex_stl_lib.json': mock.MagicMock(), - 'stl.trex_stl_lib.linecache': mock.MagicMock(), - 'stl.trex_stl_lib.math': mock.MagicMock(), - 'stl.trex_stl_lib.os': mock.MagicMock(), - 'stl.trex_stl_lib.platform': mock.MagicMock(), - 'stl.trex_stl_lib.pprint': mock.MagicMock(), - 'stl.trex_stl_lib.random': mock.MagicMock(), - 'stl.trex_stl_lib.re': mock.MagicMock(), - 'stl.trex_stl_lib.scapy': mock.MagicMock(), - 'stl.trex_stl_lib.socket': mock.MagicMock(), - 'stl.trex_stl_lib.string': mock.MagicMock(), - 'stl.trex_stl_lib.struct': mock.MagicMock(), - 'stl.trex_stl_lib.sys': mock.MagicMock(), - 'stl.trex_stl_lib.threading': mock.MagicMock(), - 'stl.trex_stl_lib.time': mock.MagicMock(), - 'stl.trex_stl_lib.traceback': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_async_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_exceptions': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_ext': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_jsonrpc_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_packet_builder_interface': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_packet_builder_scapy': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_port': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_stats': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_streams': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_types': mock.MagicMock(), - 'stl.trex_stl_lib.types': mock.MagicMock(), - 'stl.trex_stl_lib.utils': mock.MagicMock(), - 'stl.trex_stl_lib.utils.argparse': mock.MagicMock(), - 'stl.trex_stl_lib.utils.collections': mock.MagicMock(), - 'stl.trex_stl_lib.utils.common': mock.MagicMock(), - 'stl.trex_stl_lib.utils.json': mock.MagicMock(), - 'stl.trex_stl_lib.utils.os': mock.MagicMock(), - 'stl.trex_stl_lib.utils.parsing_opts': mock.MagicMock(), - 'stl.trex_stl_lib.utils.pwd': mock.MagicMock(), - 'stl.trex_stl_lib.utils.random': mock.MagicMock(), - 'stl.trex_stl_lib.utils.re': mock.MagicMock(), - 'stl.trex_stl_lib.utils.string': mock.MagicMock(), - 'stl.trex_stl_lib.utils.sys': mock.MagicMock(), - 'stl.trex_stl_lib.utils.text_opts': mock.MagicMock(), - 'stl.trex_stl_lib.utils.text_tables': mock.MagicMock(), - 'stl.trex_stl_lib.utils.texttable': mock.MagicMock(), - 'stl.trex_stl_lib.warnings': mock.MagicMock(), - 'stl.trex_stl_lib.yaml': mock.MagicMock(), - 'stl.trex_stl_lib.zlib': mock.MagicMock(), - 'stl.trex_stl_lib.zmq': mock.MagicMock(), -} +from tests.unit import STL_MOCKS STLClient = mock.MagicMock() stl_patch = mock.patch.dict("sys.modules", STL_MOCKS) diff --git a/tests/unit/network_services/traffic_profile/test_prox_profile.py b/tests/unit/network_services/traffic_profile/test_prox_profile.py index a2ad0333f..14223da0f 100644 --- a/tests/unit/network_services/traffic_profile/test_prox_profile.py +++ b/tests/unit/network_services/traffic_profile/test_prox_profile.py @@ -14,69 +14,11 @@ # from __future__ import absolute_import -import unittest +import unittest import mock -STL_MOCKS = { - 'stl': mock.MagicMock(), - 'stl.trex_stl_lib': mock.MagicMock(), - 'stl.trex_stl_lib.base64': mock.MagicMock(), - 'stl.trex_stl_lib.binascii': mock.MagicMock(), - 'stl.trex_stl_lib.collections': mock.MagicMock(), - 'stl.trex_stl_lib.copy': mock.MagicMock(), - 'stl.trex_stl_lib.datetime': mock.MagicMock(), - 'stl.trex_stl_lib.functools': mock.MagicMock(), - 'stl.trex_stl_lib.imp': mock.MagicMock(), - 'stl.trex_stl_lib.inspect': mock.MagicMock(), - 'stl.trex_stl_lib.json': mock.MagicMock(), - 'stl.trex_stl_lib.linecache': mock.MagicMock(), - 'stl.trex_stl_lib.math': mock.MagicMock(), - 'stl.trex_stl_lib.os': mock.MagicMock(), - 'stl.trex_stl_lib.platform': mock.MagicMock(), - 'stl.trex_stl_lib.pprint': mock.MagicMock(), - 'stl.trex_stl_lib.random': mock.MagicMock(), - 'stl.trex_stl_lib.re': mock.MagicMock(), - 'stl.trex_stl_lib.scapy': mock.MagicMock(), - 'stl.trex_stl_lib.socket': mock.MagicMock(), - 'stl.trex_stl_lib.string': mock.MagicMock(), - 'stl.trex_stl_lib.struct': mock.MagicMock(), - 'stl.trex_stl_lib.sys': mock.MagicMock(), - 'stl.trex_stl_lib.threading': mock.MagicMock(), - 'stl.trex_stl_lib.time': mock.MagicMock(), - 'stl.trex_stl_lib.traceback': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_async_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_exceptions': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_ext': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_jsonrpc_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_packet_builder_interface': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_packet_builder_scapy': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_port': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_stats': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_streams': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_types': mock.MagicMock(), - 'stl.trex_stl_lib.types': mock.MagicMock(), - 'stl.trex_stl_lib.utils': mock.MagicMock(), - 'stl.trex_stl_lib.utils.argparse': mock.MagicMock(), - 'stl.trex_stl_lib.utils.collections': mock.MagicMock(), - 'stl.trex_stl_lib.utils.common': mock.MagicMock(), - 'stl.trex_stl_lib.utils.json': mock.MagicMock(), - 'stl.trex_stl_lib.utils.os': mock.MagicMock(), - 'stl.trex_stl_lib.utils.parsing_opts': mock.MagicMock(), - 'stl.trex_stl_lib.utils.pwd': mock.MagicMock(), - 'stl.trex_stl_lib.utils.random': mock.MagicMock(), - 'stl.trex_stl_lib.utils.re': mock.MagicMock(), - 'stl.trex_stl_lib.utils.string': mock.MagicMock(), - 'stl.trex_stl_lib.utils.sys': mock.MagicMock(), - 'stl.trex_stl_lib.utils.text_opts': mock.MagicMock(), - 'stl.trex_stl_lib.utils.text_tables': mock.MagicMock(), - 'stl.trex_stl_lib.utils.texttable': mock.MagicMock(), - 'stl.trex_stl_lib.warnings': mock.MagicMock(), - 'stl.trex_stl_lib.yaml': mock.MagicMock(), - 'stl.trex_stl_lib.zlib': mock.MagicMock(), - 'stl.trex_stl_lib.zmq': mock.MagicMock(), -} +from tests.unit import STL_MOCKS STLClient = mock.MagicMock() stl_patch = mock.patch.dict("sys.modules", STL_MOCKS) diff --git a/tests/unit/network_services/traffic_profile/test_prox_ramp.py b/tests/unit/network_services/traffic_profile/test_prox_ramp.py index 19e6ff8cb..357298759 100644 --- a/tests/unit/network_services/traffic_profile/test_prox_ramp.py +++ b/tests/unit/network_services/traffic_profile/test_prox_ramp.py @@ -14,69 +14,11 @@ # from __future__ import absolute_import -import unittest +import unittest import mock -STL_MOCKS = { - 'stl': mock.MagicMock(), - 'stl.trex_stl_lib': mock.MagicMock(), - 'stl.trex_stl_lib.base64': mock.MagicMock(), - 'stl.trex_stl_lib.binascii': mock.MagicMock(), - 'stl.trex_stl_lib.collections': mock.MagicMock(), - 'stl.trex_stl_lib.copy': mock.MagicMock(), - 'stl.trex_stl_lib.datetime': mock.MagicMock(), - 'stl.trex_stl_lib.functools': mock.MagicMock(), - 'stl.trex_stl_lib.imp': mock.MagicMock(), - 'stl.trex_stl_lib.inspect': mock.MagicMock(), - 'stl.trex_stl_lib.json': mock.MagicMock(), - 'stl.trex_stl_lib.linecache': mock.MagicMock(), - 'stl.trex_stl_lib.math': mock.MagicMock(), - 'stl.trex_stl_lib.os': mock.MagicMock(), - 'stl.trex_stl_lib.platform': mock.MagicMock(), - 'stl.trex_stl_lib.pprint': mock.MagicMock(), - 'stl.trex_stl_lib.random': mock.MagicMock(), - 'stl.trex_stl_lib.re': mock.MagicMock(), - 'stl.trex_stl_lib.scapy': mock.MagicMock(), - 'stl.trex_stl_lib.socket': mock.MagicMock(), - 'stl.trex_stl_lib.string': mock.MagicMock(), - 'stl.trex_stl_lib.struct': mock.MagicMock(), - 'stl.trex_stl_lib.sys': mock.MagicMock(), - 'stl.trex_stl_lib.threading': mock.MagicMock(), - 'stl.trex_stl_lib.time': mock.MagicMock(), - 'stl.trex_stl_lib.traceback': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_async_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_exceptions': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_ext': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_jsonrpc_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_packet_builder_interface': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_packet_builder_scapy': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_port': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_stats': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_streams': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_types': mock.MagicMock(), - 'stl.trex_stl_lib.types': mock.MagicMock(), - 'stl.trex_stl_lib.utils': mock.MagicMock(), - 'stl.trex_stl_lib.utils.argparse': mock.MagicMock(), - 'stl.trex_stl_lib.utils.collections': mock.MagicMock(), - 'stl.trex_stl_lib.utils.common': mock.MagicMock(), - 'stl.trex_stl_lib.utils.json': mock.MagicMock(), - 'stl.trex_stl_lib.utils.os': mock.MagicMock(), - 'stl.trex_stl_lib.utils.parsing_opts': mock.MagicMock(), - 'stl.trex_stl_lib.utils.pwd': mock.MagicMock(), - 'stl.trex_stl_lib.utils.random': mock.MagicMock(), - 'stl.trex_stl_lib.utils.re': mock.MagicMock(), - 'stl.trex_stl_lib.utils.string': mock.MagicMock(), - 'stl.trex_stl_lib.utils.sys': mock.MagicMock(), - 'stl.trex_stl_lib.utils.text_opts': mock.MagicMock(), - 'stl.trex_stl_lib.utils.text_tables': mock.MagicMock(), - 'stl.trex_stl_lib.utils.texttable': mock.MagicMock(), - 'stl.trex_stl_lib.warnings': mock.MagicMock(), - 'stl.trex_stl_lib.yaml': mock.MagicMock(), - 'stl.trex_stl_lib.zlib': mock.MagicMock(), - 'stl.trex_stl_lib.zmq': mock.MagicMock(), -} +from tests.unit import STL_MOCKS STLClient = mock.MagicMock() stl_patch = mock.patch.dict("sys.modules", STL_MOCKS) diff --git a/tests/unit/network_services/traffic_profile/test_rfc2544.py b/tests/unit/network_services/traffic_profile/test_rfc2544.py index dcaf43dc5..aef0b93de 100644 --- a/tests/unit/network_services/traffic_profile/test_rfc2544.py +++ b/tests/unit/network_services/traffic_profile/test_rfc2544.py @@ -17,68 +17,12 @@ from __future__ import absolute_import from __future__ import division + import unittest import mock -STL_MOCKS = { - 'stl': mock.MagicMock(), - 'stl.trex_stl_lib': mock.MagicMock(), - 'stl.trex_stl_lib.base64': mock.MagicMock(), - 'stl.trex_stl_lib.binascii': mock.MagicMock(), - 'stl.trex_stl_lib.collections': mock.MagicMock(), - 'stl.trex_stl_lib.copy': mock.MagicMock(), - 'stl.trex_stl_lib.datetime': mock.MagicMock(), - 'stl.trex_stl_lib.functools': mock.MagicMock(), - 'stl.trex_stl_lib.imp': mock.MagicMock(), - 'stl.trex_stl_lib.inspect': mock.MagicMock(), - 'stl.trex_stl_lib.json': mock.MagicMock(), - 'stl.trex_stl_lib.linecache': mock.MagicMock(), - 'stl.trex_stl_lib.math': mock.MagicMock(), - 'stl.trex_stl_lib.os': mock.MagicMock(), - 'stl.trex_stl_lib.platform': mock.MagicMock(), - 'stl.trex_stl_lib.pprint': mock.MagicMock(), - 'stl.trex_stl_lib.random': mock.MagicMock(), - 'stl.trex_stl_lib.re': mock.MagicMock(), - 'stl.trex_stl_lib.scapy': mock.MagicMock(), - 'stl.trex_stl_lib.socket': mock.MagicMock(), - 'stl.trex_stl_lib.string': mock.MagicMock(), - 'stl.trex_stl_lib.struct': mock.MagicMock(), - 'stl.trex_stl_lib.sys': mock.MagicMock(), - 'stl.trex_stl_lib.threading': mock.MagicMock(), - 'stl.trex_stl_lib.time': mock.MagicMock(), - 'stl.trex_stl_lib.traceback': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_async_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_exceptions': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_ext': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_jsonrpc_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_packet_builder_interface': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_packet_builder_scapy': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_port': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_stats': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_streams': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_types': mock.MagicMock(), - 'stl.trex_stl_lib.types': mock.MagicMock(), - 'stl.trex_stl_lib.utils': mock.MagicMock(), - 'stl.trex_stl_lib.utils.argparse': mock.MagicMock(), - 'stl.trex_stl_lib.utils.collections': mock.MagicMock(), - 'stl.trex_stl_lib.utils.common': mock.MagicMock(), - 'stl.trex_stl_lib.utils.json': mock.MagicMock(), - 'stl.trex_stl_lib.utils.os': mock.MagicMock(), - 'stl.trex_stl_lib.utils.parsing_opts': mock.MagicMock(), - 'stl.trex_stl_lib.utils.pwd': mock.MagicMock(), - 'stl.trex_stl_lib.utils.random': mock.MagicMock(), - 'stl.trex_stl_lib.utils.re': mock.MagicMock(), - 'stl.trex_stl_lib.utils.string': mock.MagicMock(), - 'stl.trex_stl_lib.utils.sys': mock.MagicMock(), - 'stl.trex_stl_lib.utils.text_opts': mock.MagicMock(), - 'stl.trex_stl_lib.utils.text_tables': mock.MagicMock(), - 'stl.trex_stl_lib.utils.texttable': mock.MagicMock(), - 'stl.trex_stl_lib.warnings': mock.MagicMock(), - 'stl.trex_stl_lib.yaml': mock.MagicMock(), - 'stl.trex_stl_lib.zlib': mock.MagicMock(), - 'stl.trex_stl_lib.zmq': mock.MagicMock(), -} +from tests.unit import STL_MOCKS + STLClient = mock.MagicMock() stl_patch = mock.patch.dict("sys.modules", STL_MOCKS) @@ -115,9 +59,9 @@ class TestRFC2544Profile(unittest.TestCase): 'outer_l3v4': {'dstip4': '1.1.1.1-1.15.255.255', 'proto': 'udp', 'srcip4': '90.90.1.1-90.105.255.255', - 'dscp': 0, 'ttl': 32}, + 'dscp': 0, 'ttl': 32, 'count': 1}, 'outer_l4': {'srcport': '2001', - 'dsrport': '1234'}}}, + 'dsrport': '1234', 'count': 1}}}, 'private_1': {'ipv4': {'outer_l2': {'framesize': {'64B': '100', '1518B': '0', @@ -127,9 +71,9 @@ class TestRFC2544Profile(unittest.TestCase): 'outer_l3v4': {'dstip4': '9.9.1.1-90.105.255.255', 'proto': 'udp', 'srcip4': '1.1.1.1-1.15.255.255', - 'dscp': 0, 'ttl': 32}, + 'dscp': 0, 'ttl': 32, 'count': 1}, 'outer_l4': {'dstport': '2001', - 'srcport': '1234'}}}, + 'srcport': '1234', 'count': 1}}}, 'schema': 'isb:traffic_profile:0.1'} def test___init__(self): diff --git a/tests/unit/network_services/traffic_profile/test_traffic_profile.py b/tests/unit/network_services/traffic_profile/test_traffic_profile.py index fd769e6e0..9a78c36a3 100644 --- a/tests/unit/network_services/traffic_profile/test_traffic_profile.py +++ b/tests/unit/network_services/traffic_profile/test_traffic_profile.py @@ -16,69 +16,12 @@ # from __future__ import absolute_import -import unittest +import unittest import mock -STL_MOCKS = { - 'stl': mock.MagicMock(), - 'stl.trex_stl_lib': mock.MagicMock(), - 'stl.trex_stl_lib.base64': mock.MagicMock(), - 'stl.trex_stl_lib.binascii': mock.MagicMock(), - 'stl.trex_stl_lib.collections': mock.MagicMock(), - 'stl.trex_stl_lib.copy': mock.MagicMock(), - 'stl.trex_stl_lib.datetime': mock.MagicMock(), - 'stl.trex_stl_lib.functools': mock.MagicMock(), - 'stl.trex_stl_lib.imp': mock.MagicMock(), - 'stl.trex_stl_lib.inspect': mock.MagicMock(), - 'stl.trex_stl_lib.json': mock.MagicMock(), - 'stl.trex_stl_lib.linecache': mock.MagicMock(), - 'stl.trex_stl_lib.math': mock.MagicMock(), - 'stl.trex_stl_lib.os': mock.MagicMock(), - 'stl.trex_stl_lib.platform': mock.MagicMock(), - 'stl.trex_stl_lib.pprint': mock.MagicMock(), - 'stl.trex_stl_lib.random': mock.MagicMock(), - 'stl.trex_stl_lib.re': mock.MagicMock(), - 'stl.trex_stl_lib.scapy': mock.MagicMock(), - 'stl.trex_stl_lib.socket': mock.MagicMock(), - 'stl.trex_stl_lib.string': mock.MagicMock(), - 'stl.trex_stl_lib.struct': mock.MagicMock(), - 'stl.trex_stl_lib.sys': mock.MagicMock(), - 'stl.trex_stl_lib.threading': mock.MagicMock(), - 'stl.trex_stl_lib.time': mock.MagicMock(), - 'stl.trex_stl_lib.traceback': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_async_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_exceptions': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_ext': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_jsonrpc_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_packet_builder_interface': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_packet_builder_scapy': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_port': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_stats': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_streams': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_types': mock.MagicMock(), - 'stl.trex_stl_lib.types': mock.MagicMock(), - 'stl.trex_stl_lib.utils': mock.MagicMock(), - 'stl.trex_stl_lib.utils.argparse': mock.MagicMock(), - 'stl.trex_stl_lib.utils.collections': mock.MagicMock(), - 'stl.trex_stl_lib.utils.common': mock.MagicMock(), - 'stl.trex_stl_lib.utils.json': mock.MagicMock(), - 'stl.trex_stl_lib.utils.os': mock.MagicMock(), - 'stl.trex_stl_lib.utils.parsing_opts': mock.MagicMock(), - 'stl.trex_stl_lib.utils.pwd': mock.MagicMock(), - 'stl.trex_stl_lib.utils.random': mock.MagicMock(), - 'stl.trex_stl_lib.utils.re': mock.MagicMock(), - 'stl.trex_stl_lib.utils.string': mock.MagicMock(), - 'stl.trex_stl_lib.utils.sys': mock.MagicMock(), - 'stl.trex_stl_lib.utils.text_opts': mock.MagicMock(), - 'stl.trex_stl_lib.utils.text_tables': mock.MagicMock(), - 'stl.trex_stl_lib.utils.texttable': mock.MagicMock(), - 'stl.trex_stl_lib.warnings': mock.MagicMock(), - 'stl.trex_stl_lib.yaml': mock.MagicMock(), - 'stl.trex_stl_lib.zlib': mock.MagicMock(), - 'stl.trex_stl_lib.zmq': mock.MagicMock(), -} +from tests.unit import STL_MOCKS + STLClient = mock.MagicMock() stl_patch = mock.patch.dict("sys.modules", STL_MOCKS) @@ -117,9 +60,11 @@ class TestTrexProfile(unittest.TestCase): 'outer_l3v4': {'dstip4': '1.1.1.1-1.1.2.2', 'proto': 'udp', 'srcip4': '9.9.1.1-90.1.2.2', - 'dscp': 0, 'ttl': 32}, + 'dscp': 0, 'ttl': 32, + 'count': 1}, 'outer_l4': {'srcport': '2001', - 'dsrport': '1234'}}}, + 'dsrport': '1234', + 'count': 1}}}, 'private': {'ipv4': {'outer_l2': {'framesize': {'64B': '100', '1518B': '0', @@ -131,9 +76,10 @@ class TestTrexProfile(unittest.TestCase): 'outer_l3v4': {'dstip4': '9.9.1.1-90.105.255.255', 'proto': 'udp', 'srcip4': '1.1.1.1-1.15.255.255', - 'dscp': 0, 'ttl': 32}, + 'dscp': 0, 'ttl': 32, 'count': 1}, 'outer_l4': {'dstport': '2001', - 'srcport': '1234'}}}, + 'srcport': '1234', + 'count': 1}}}, 'schema': 'isb:traffic_profile:0.1'} PROFILE_v6 = {'description': 'Traffic profile to run RFC2544 latency', 'name': 'rfc2544', @@ -149,9 +95,11 @@ class TestTrexProfile(unittest.TestCase): 'outer_l3v4': {'dstip6': '0064:ff9b:0:0:0:0:9810:6414-0064:ff9b:0:0:0:0:9810:6420', 'proto': 'udp', 'srcip6': '0064:ff9b:0:0:0:0:9810:2814-0064:ff9b:0:0:0:0:9810:2820', - 'dscp': 0, 'ttl': 32}, + 'dscp': 0, 'ttl': 32, + 'count': 1}, 'outer_l4': {'srcport': '2001', - 'dsrport': '1234'}}}, + 'dsrport': '1234', + 'count': 1}}}, 'private': {'ipv6': {'outer_l2': {'framesize': {'64B': '100', '1518B': '0', @@ -163,9 +111,11 @@ class TestTrexProfile(unittest.TestCase): 'outer_l3v4': {'dstip6': '0064:ff9b:0:0:0:0:9810:2814-0064:ff9b:0:0:0:0:9810:2820', 'proto': 'udp', 'srcip6': '0064:ff9b:0:0:0:0:9810:6414-0064:ff9b:0:0:0:0:9810:6420', - 'dscp': 0, 'ttl': 32}, + 'dscp': 0, 'ttl': 32, + 'count': 1}, 'outer_l4': {'dstport': '2001', - 'srcport': '1234'}}}, + 'srcport': '1234', + 'count': 1}}}, 'schema': 'isb:traffic_profile:0.1'} def test___init__(self): diff --git a/tests/unit/network_services/vnf_generic/vnf/test_acl_vnf.py b/tests/unit/network_services/vnf_generic/vnf/test_acl_vnf.py index a63a59d48..7570067b9 100644 --- a/tests/unit/network_services/vnf_generic/vnf/test_acl_vnf.py +++ b/tests/unit/network_services/vnf_generic/vnf/test_acl_vnf.py @@ -16,70 +16,13 @@ # from __future__ import absolute_import + import unittest import mock import os +from tests.unit import STL_MOCKS -STL_MOCKS = { - 'stl': mock.MagicMock(), - 'stl.trex_stl_lib': mock.MagicMock(), - 'stl.trex_stl_lib.base64': mock.MagicMock(), - 'stl.trex_stl_lib.binascii': mock.MagicMock(), - 'stl.trex_stl_lib.collections': mock.MagicMock(), - 'stl.trex_stl_lib.copy': mock.MagicMock(), - 'stl.trex_stl_lib.datetime': mock.MagicMock(), - 'stl.trex_stl_lib.functools': mock.MagicMock(), - 'stl.trex_stl_lib.imp': mock.MagicMock(), - 'stl.trex_stl_lib.inspect': mock.MagicMock(), - 'stl.trex_stl_lib.json': mock.MagicMock(), - 'stl.trex_stl_lib.linecache': mock.MagicMock(), - 'stl.trex_stl_lib.math': mock.MagicMock(), - 'stl.trex_stl_lib.os': mock.MagicMock(), - 'stl.trex_stl_lib.platform': mock.MagicMock(), - 'stl.trex_stl_lib.pprint': mock.MagicMock(), - 'stl.trex_stl_lib.random': mock.MagicMock(), - 'stl.trex_stl_lib.re': mock.MagicMock(), - 'stl.trex_stl_lib.scapy': mock.MagicMock(), - 'stl.trex_stl_lib.socket': mock.MagicMock(), - 'stl.trex_stl_lib.string': mock.MagicMock(), - 'stl.trex_stl_lib.struct': mock.MagicMock(), - 'stl.trex_stl_lib.sys': mock.MagicMock(), - 'stl.trex_stl_lib.threading': mock.MagicMock(), - 'stl.trex_stl_lib.time': mock.MagicMock(), - 'stl.trex_stl_lib.traceback': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_async_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_exceptions': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_ext': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_jsonrpc_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_packet_builder_interface': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_packet_builder_scapy': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_port': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_stats': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_streams': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_types': mock.MagicMock(), - 'stl.trex_stl_lib.types': mock.MagicMock(), - 'stl.trex_stl_lib.utils': mock.MagicMock(), - 'stl.trex_stl_lib.utils.argparse': mock.MagicMock(), - 'stl.trex_stl_lib.utils.collections': mock.MagicMock(), - 'stl.trex_stl_lib.utils.common': mock.MagicMock(), - 'stl.trex_stl_lib.utils.json': mock.MagicMock(), - 'stl.trex_stl_lib.utils.os': mock.MagicMock(), - 'stl.trex_stl_lib.utils.parsing_opts': mock.MagicMock(), - 'stl.trex_stl_lib.utils.pwd': mock.MagicMock(), - 'stl.trex_stl_lib.utils.random': mock.MagicMock(), - 'stl.trex_stl_lib.utils.re': mock.MagicMock(), - 'stl.trex_stl_lib.utils.string': mock.MagicMock(), - 'stl.trex_stl_lib.utils.sys': mock.MagicMock(), - 'stl.trex_stl_lib.utils.text_opts': mock.MagicMock(), - 'stl.trex_stl_lib.utils.text_tables': mock.MagicMock(), - 'stl.trex_stl_lib.utils.texttable': mock.MagicMock(), - 'stl.trex_stl_lib.warnings': mock.MagicMock(), - 'stl.trex_stl_lib.yaml': mock.MagicMock(), - 'stl.trex_stl_lib.zlib': mock.MagicMock(), - 'stl.trex_stl_lib.zmq': mock.MagicMock(), -} STLClient = mock.MagicMock() stl_patch = mock.patch.dict("sys.modules", STL_MOCKS) diff --git a/tests/unit/network_services/vnf_generic/vnf/test_cgnapt_vnf.py b/tests/unit/network_services/vnf_generic/vnf/test_cgnapt_vnf.py index bf226d2c8..f214d66f6 100644 --- a/tests/unit/network_services/vnf_generic/vnf/test_cgnapt_vnf.py +++ b/tests/unit/network_services/vnf_generic/vnf/test_cgnapt_vnf.py @@ -19,68 +19,10 @@ from __future__ import absolute_import import os import unittest - import mock -STL_MOCKS = { - 'stl': mock.MagicMock(), - 'stl.trex_stl_lib': mock.MagicMock(), - 'stl.trex_stl_lib.base64': mock.MagicMock(), - 'stl.trex_stl_lib.binascii': mock.MagicMock(), - 'stl.trex_stl_lib.collections': mock.MagicMock(), - 'stl.trex_stl_lib.copy': mock.MagicMock(), - 'stl.trex_stl_lib.datetime': mock.MagicMock(), - 'stl.trex_stl_lib.functools': mock.MagicMock(), - 'stl.trex_stl_lib.imp': mock.MagicMock(), - 'stl.trex_stl_lib.inspect': mock.MagicMock(), - 'stl.trex_stl_lib.json': mock.MagicMock(), - 'stl.trex_stl_lib.linecache': mock.MagicMock(), - 'stl.trex_stl_lib.math': mock.MagicMock(), - 'stl.trex_stl_lib.os': mock.MagicMock(), - 'stl.trex_stl_lib.platform': mock.MagicMock(), - 'stl.trex_stl_lib.pprint': mock.MagicMock(), - 'stl.trex_stl_lib.random': mock.MagicMock(), - 'stl.trex_stl_lib.re': mock.MagicMock(), - 'stl.trex_stl_lib.scapy': mock.MagicMock(), - 'stl.trex_stl_lib.socket': mock.MagicMock(), - 'stl.trex_stl_lib.string': mock.MagicMock(), - 'stl.trex_stl_lib.struct': mock.MagicMock(), - 'stl.trex_stl_lib.sys': mock.MagicMock(), - 'stl.trex_stl_lib.threading': mock.MagicMock(), - 'stl.trex_stl_lib.time': mock.MagicMock(), - 'stl.trex_stl_lib.traceback': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_async_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_exceptions': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_ext': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_jsonrpc_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_packet_builder_interface': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_packet_builder_scapy': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_port': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_stats': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_streams': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_types': mock.MagicMock(), - 'stl.trex_stl_lib.types': mock.MagicMock(), - 'stl.trex_stl_lib.utils': mock.MagicMock(), - 'stl.trex_stl_lib.utils.argparse': mock.MagicMock(), - 'stl.trex_stl_lib.utils.collections': mock.MagicMock(), - 'stl.trex_stl_lib.utils.common': mock.MagicMock(), - 'stl.trex_stl_lib.utils.json': mock.MagicMock(), - 'stl.trex_stl_lib.utils.os': mock.MagicMock(), - 'stl.trex_stl_lib.utils.parsing_opts': mock.MagicMock(), - 'stl.trex_stl_lib.utils.pwd': mock.MagicMock(), - 'stl.trex_stl_lib.utils.random': mock.MagicMock(), - 'stl.trex_stl_lib.utils.re': mock.MagicMock(), - 'stl.trex_stl_lib.utils.string': mock.MagicMock(), - 'stl.trex_stl_lib.utils.sys': mock.MagicMock(), - 'stl.trex_stl_lib.utils.text_opts': mock.MagicMock(), - 'stl.trex_stl_lib.utils.text_tables': mock.MagicMock(), - 'stl.trex_stl_lib.utils.texttable': mock.MagicMock(), - 'stl.trex_stl_lib.warnings': mock.MagicMock(), - 'stl.trex_stl_lib.yaml': mock.MagicMock(), - 'stl.trex_stl_lib.zlib': mock.MagicMock(), - 'stl.trex_stl_lib.zmq': mock.MagicMock(), -} +from tests.unit import STL_MOCKS + STLClient = mock.MagicMock() stl_patch = mock.patch.dict("sys.modules", STL_MOCKS) diff --git a/tests/unit/network_services/vnf_generic/vnf/test_iniparser.py b/tests/unit/network_services/vnf_generic/vnf/test_iniparser.py index 53481ddd0..b74e5d9fd 100644 --- a/tests/unit/network_services/vnf_generic/vnf/test_iniparser.py +++ b/tests/unit/network_services/vnf_generic/vnf/test_iniparser.py @@ -14,70 +14,13 @@ # from __future__ import absolute_import + import unittest from contextlib import contextmanager - import mock -STL_MOCKS = { - 'stl': mock.MagicMock(), - 'stl.trex_stl_lib': mock.MagicMock(), - 'stl.trex_stl_lib.base64': mock.MagicMock(), - 'stl.trex_stl_lib.binascii': mock.MagicMock(), - 'stl.trex_stl_lib.collections': mock.MagicMock(), - 'stl.trex_stl_lib.copy': mock.MagicMock(), - 'stl.trex_stl_lib.datetime': mock.MagicMock(), - 'stl.trex_stl_lib.functools': mock.MagicMock(), - 'stl.trex_stl_lib.imp': mock.MagicMock(), - 'stl.trex_stl_lib.inspect': mock.MagicMock(), - 'stl.trex_stl_lib.json': mock.MagicMock(), - 'stl.trex_stl_lib.linecache': mock.MagicMock(), - 'stl.trex_stl_lib.math': mock.MagicMock(), - 'stl.trex_stl_lib.os': mock.MagicMock(), - 'stl.trex_stl_lib.platform': mock.MagicMock(), - 'stl.trex_stl_lib.pprint': mock.MagicMock(), - 'stl.trex_stl_lib.random': mock.MagicMock(), - 'stl.trex_stl_lib.re': mock.MagicMock(), - 'stl.trex_stl_lib.scapy': mock.MagicMock(), - 'stl.trex_stl_lib.socket': mock.MagicMock(), - 'stl.trex_stl_lib.string': mock.MagicMock(), - 'stl.trex_stl_lib.struct': mock.MagicMock(), - 'stl.trex_stl_lib.sys': mock.MagicMock(), - 'stl.trex_stl_lib.threading': mock.MagicMock(), - 'stl.trex_stl_lib.time': mock.MagicMock(), - 'stl.trex_stl_lib.traceback': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_async_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_exceptions': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_ext': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_jsonrpc_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_packet_builder_interface': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_packet_builder_scapy': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_port': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_stats': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_streams': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_types': mock.MagicMock(), - 'stl.trex_stl_lib.types': mock.MagicMock(), - 'stl.trex_stl_lib.utils': mock.MagicMock(), - 'stl.trex_stl_lib.utils.argparse': mock.MagicMock(), - 'stl.trex_stl_lib.utils.collections': mock.MagicMock(), - 'stl.trex_stl_lib.utils.common': mock.MagicMock(), - 'stl.trex_stl_lib.utils.json': mock.MagicMock(), - 'stl.trex_stl_lib.utils.os': mock.MagicMock(), - 'stl.trex_stl_lib.utils.parsing_opts': mock.MagicMock(), - 'stl.trex_stl_lib.utils.pwd': mock.MagicMock(), - 'stl.trex_stl_lib.utils.random': mock.MagicMock(), - 'stl.trex_stl_lib.utils.re': mock.MagicMock(), - 'stl.trex_stl_lib.utils.string': mock.MagicMock(), - 'stl.trex_stl_lib.utils.sys': mock.MagicMock(), - 'stl.trex_stl_lib.utils.text_opts': mock.MagicMock(), - 'stl.trex_stl_lib.utils.text_tables': mock.MagicMock(), - 'stl.trex_stl_lib.utils.texttable': mock.MagicMock(), - 'stl.trex_stl_lib.warnings': mock.MagicMock(), - 'stl.trex_stl_lib.yaml': mock.MagicMock(), - 'stl.trex_stl_lib.zlib': mock.MagicMock(), - 'stl.trex_stl_lib.zmq': mock.MagicMock(), -} +from tests.unit import STL_MOCKS + STLClient = mock.MagicMock() stl_patch = mock.patch.dict("sys.modules", STL_MOCKS) diff --git a/tests/unit/network_services/vnf_generic/vnf/test_prox_helpers.py b/tests/unit/network_services/vnf_generic/vnf/test_prox_helpers.py index 90ec3f374..98eccae4f 100644 --- a/tests/unit/network_services/vnf_generic/vnf/test_prox_helpers.py +++ b/tests/unit/network_services/vnf_generic/vnf/test_prox_helpers.py @@ -23,69 +23,10 @@ import unittest from collections import OrderedDict from itertools import repeat, chain from contextlib import contextmanager - import mock +from tests.unit import STL_MOCKS -STL_MOCKS = { - 'stl': mock.MagicMock(), - 'stl.trex_stl_lib': mock.MagicMock(), - 'stl.trex_stl_lib.base64': mock.MagicMock(), - 'stl.trex_stl_lib.binascii': mock.MagicMock(), - 'stl.trex_stl_lib.collections': mock.MagicMock(), - 'stl.trex_stl_lib.copy': mock.MagicMock(), - 'stl.trex_stl_lib.datetime': mock.MagicMock(), - 'stl.trex_stl_lib.functools': mock.MagicMock(), - 'stl.trex_stl_lib.imp': mock.MagicMock(), - 'stl.trex_stl_lib.inspect': mock.MagicMock(), - 'stl.trex_stl_lib.json': mock.MagicMock(), - 'stl.trex_stl_lib.linecache': mock.MagicMock(), - 'stl.trex_stl_lib.math': mock.MagicMock(), - 'stl.trex_stl_lib.os': mock.MagicMock(), - 'stl.trex_stl_lib.platform': mock.MagicMock(), - 'stl.trex_stl_lib.pprint': mock.MagicMock(), - 'stl.trex_stl_lib.random': mock.MagicMock(), - 'stl.trex_stl_lib.re': mock.MagicMock(), - 'stl.trex_stl_lib.scapy': mock.MagicMock(), - 'stl.trex_stl_lib.socket': mock.MagicMock(), - 'stl.trex_stl_lib.string': mock.MagicMock(), - 'stl.trex_stl_lib.struct': mock.MagicMock(), - 'stl.trex_stl_lib.sys': mock.MagicMock(), - 'stl.trex_stl_lib.threading': mock.MagicMock(), - 'stl.trex_stl_lib.time': mock.MagicMock(), - 'stl.trex_stl_lib.traceback': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_async_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_exceptions': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_ext': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_jsonrpc_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_packet_builder_interface': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_packet_builder_scapy': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_port': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_stats': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_streams': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_types': mock.MagicMock(), - 'stl.trex_stl_lib.types': mock.MagicMock(), - 'stl.trex_stl_lib.utils': mock.MagicMock(), - 'stl.trex_stl_lib.utils.argparse': mock.MagicMock(), - 'stl.trex_stl_lib.utils.collections': mock.MagicMock(), - 'stl.trex_stl_lib.utils.common': mock.MagicMock(), - 'stl.trex_stl_lib.utils.json': mock.MagicMock(), - 'stl.trex_stl_lib.utils.os': mock.MagicMock(), - 'stl.trex_stl_lib.utils.parsing_opts': mock.MagicMock(), - 'stl.trex_stl_lib.utils.pwd': mock.MagicMock(), - 'stl.trex_stl_lib.utils.random': mock.MagicMock(), - 'stl.trex_stl_lib.utils.re': mock.MagicMock(), - 'stl.trex_stl_lib.utils.string': mock.MagicMock(), - 'stl.trex_stl_lib.utils.sys': mock.MagicMock(), - 'stl.trex_stl_lib.utils.text_opts': mock.MagicMock(), - 'stl.trex_stl_lib.utils.text_tables': mock.MagicMock(), - 'stl.trex_stl_lib.utils.texttable': mock.MagicMock(), - 'stl.trex_stl_lib.warnings': mock.MagicMock(), - 'stl.trex_stl_lib.yaml': mock.MagicMock(), - 'stl.trex_stl_lib.zlib': mock.MagicMock(), - 'stl.trex_stl_lib.zmq': mock.MagicMock(), -} STLClient = mock.MagicMock() stl_patch = mock.patch.dict("sys.modules", STL_MOCKS) diff --git a/tests/unit/network_services/vnf_generic/vnf/test_prox_vnf.py b/tests/unit/network_services/vnf_generic/vnf/test_prox_vnf.py index 453100b90..c727cb7fb 100644 --- a/tests/unit/network_services/vnf_generic/vnf/test_prox_vnf.py +++ b/tests/unit/network_services/vnf_generic/vnf/test_prox_vnf.py @@ -19,71 +19,13 @@ from __future__ import absolute_import import os import unittest - import mock from copy import deepcopy -SSH_HELPER = 'yardstick.network_services.vnf_generic.vnf.sample_vnf.VnfSshHelper' +from tests.unit import STL_MOCKS -STL_MOCKS = { - 'stl': mock.MagicMock(), - 'stl.trex_stl_lib': mock.MagicMock(), - 'stl.trex_stl_lib.base64': mock.MagicMock(), - 'stl.trex_stl_lib.binascii': mock.MagicMock(), - 'stl.trex_stl_lib.collections': mock.MagicMock(), - 'stl.trex_stl_lib.copy': mock.MagicMock(), - 'stl.trex_stl_lib.datetime': mock.MagicMock(), - 'stl.trex_stl_lib.functools': mock.MagicMock(), - 'stl.trex_stl_lib.imp': mock.MagicMock(), - 'stl.trex_stl_lib.inspect': mock.MagicMock(), - 'stl.trex_stl_lib.json': mock.MagicMock(), - 'stl.trex_stl_lib.linecache': mock.MagicMock(), - 'stl.trex_stl_lib.math': mock.MagicMock(), - 'stl.trex_stl_lib.os': mock.MagicMock(), - 'stl.trex_stl_lib.platform': mock.MagicMock(), - 'stl.trex_stl_lib.pprint': mock.MagicMock(), - 'stl.trex_stl_lib.random': mock.MagicMock(), - 'stl.trex_stl_lib.re': mock.MagicMock(), - 'stl.trex_stl_lib.scapy': mock.MagicMock(), - 'stl.trex_stl_lib.socket': mock.MagicMock(), - 'stl.trex_stl_lib.string': mock.MagicMock(), - 'stl.trex_stl_lib.struct': mock.MagicMock(), - 'stl.trex_stl_lib.sys': mock.MagicMock(), - 'stl.trex_stl_lib.threading': mock.MagicMock(), - 'stl.trex_stl_lib.time': mock.MagicMock(), - 'stl.trex_stl_lib.traceback': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_async_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_exceptions': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_ext': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_jsonrpc_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_packet_builder_interface': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_packet_builder_scapy': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_port': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_stats': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_streams': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_types': mock.MagicMock(), - 'stl.trex_stl_lib.types': mock.MagicMock(), - 'stl.trex_stl_lib.utils': mock.MagicMock(), - 'stl.trex_stl_lib.utils.argparse': mock.MagicMock(), - 'stl.trex_stl_lib.utils.collections': mock.MagicMock(), - 'stl.trex_stl_lib.utils.common': mock.MagicMock(), - 'stl.trex_stl_lib.utils.json': mock.MagicMock(), - 'stl.trex_stl_lib.utils.os': mock.MagicMock(), - 'stl.trex_stl_lib.utils.parsing_opts': mock.MagicMock(), - 'stl.trex_stl_lib.utils.pwd': mock.MagicMock(), - 'stl.trex_stl_lib.utils.random': mock.MagicMock(), - 'stl.trex_stl_lib.utils.re': mock.MagicMock(), - 'stl.trex_stl_lib.utils.string': mock.MagicMock(), - 'stl.trex_stl_lib.utils.sys': mock.MagicMock(), - 'stl.trex_stl_lib.utils.text_opts': mock.MagicMock(), - 'stl.trex_stl_lib.utils.text_tables': mock.MagicMock(), - 'stl.trex_stl_lib.utils.texttable': mock.MagicMock(), - 'stl.trex_stl_lib.warnings': mock.MagicMock(), - 'stl.trex_stl_lib.yaml': mock.MagicMock(), - 'stl.trex_stl_lib.zlib': mock.MagicMock(), - 'stl.trex_stl_lib.zmq': mock.MagicMock(), -} + +SSH_HELPER = 'yardstick.network_services.vnf_generic.vnf.sample_vnf.VnfSshHelper' STLClient = mock.MagicMock() stl_patch = mock.patch.dict("sys.modules", STL_MOCKS) diff --git a/tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py b/tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py index 07a862a8e..455e44ec9 100644 --- a/tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py +++ b/tests/unit/network_services/vnf_generic/vnf/test_sample_vnf.py @@ -18,11 +18,13 @@ # Unittest for yardstick.network_services.vnf_generic.vnf.sample_vnf from __future__ import absolute_import + import unittest import mock from copy import deepcopy from tests.unit.network_services.vnf_generic.vnf.test_base import mock_ssh +from tests.unit import STL_MOCKS from yardstick.benchmark.contexts.base import Context from yardstick.network_services.nfvi.resource import ResourceProfile from yardstick.network_services.traffic_profile.base import TrafficProfile @@ -34,66 +36,6 @@ class MockError(BaseException): pass -STL_MOCKS = { - 'stl': mock.MagicMock(), - 'stl.trex_stl_lib': mock.MagicMock(), - 'stl.trex_stl_lib.base64': mock.MagicMock(), - 'stl.trex_stl_lib.binascii': mock.MagicMock(), - 'stl.trex_stl_lib.collections': mock.MagicMock(), - 'stl.trex_stl_lib.copy': mock.MagicMock(), - 'stl.trex_stl_lib.datetime': mock.MagicMock(), - 'stl.trex_stl_lib.functools': mock.MagicMock(), - 'stl.trex_stl_lib.imp': mock.MagicMock(), - 'stl.trex_stl_lib.inspect': mock.MagicMock(), - 'stl.trex_stl_lib.json': mock.MagicMock(), - 'stl.trex_stl_lib.linecache': mock.MagicMock(), - 'stl.trex_stl_lib.math': mock.MagicMock(), - 'stl.trex_stl_lib.os': mock.MagicMock(), - 'stl.trex_stl_lib.platform': mock.MagicMock(), - 'stl.trex_stl_lib.pprint': mock.MagicMock(), - 'stl.trex_stl_lib.random': mock.MagicMock(), - 'stl.trex_stl_lib.re': mock.MagicMock(), - 'stl.trex_stl_lib.scapy': mock.MagicMock(), - 'stl.trex_stl_lib.socket': mock.MagicMock(), - 'stl.trex_stl_lib.string': mock.MagicMock(), - 'stl.trex_stl_lib.struct': mock.MagicMock(), - 'stl.trex_stl_lib.sys': mock.MagicMock(), - 'stl.trex_stl_lib.threading': mock.MagicMock(), - 'stl.trex_stl_lib.time': mock.MagicMock(), - 'stl.trex_stl_lib.traceback': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_async_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_exceptions': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_ext': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_jsonrpc_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_packet_builder_interface': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_packet_builder_scapy': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_port': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_stats': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_streams': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_types': mock.MagicMock(), - 'stl.trex_stl_lib.types': mock.MagicMock(), - 'stl.trex_stl_lib.utils': mock.MagicMock(), - 'stl.trex_stl_lib.utils.argparse': mock.MagicMock(), - 'stl.trex_stl_lib.utils.collections': mock.MagicMock(), - 'stl.trex_stl_lib.utils.common': mock.MagicMock(), - 'stl.trex_stl_lib.utils.json': mock.MagicMock(), - 'stl.trex_stl_lib.utils.os': mock.MagicMock(), - 'stl.trex_stl_lib.utils.parsing_opts': mock.MagicMock(), - 'stl.trex_stl_lib.utils.pwd': mock.MagicMock(), - 'stl.trex_stl_lib.utils.random': mock.MagicMock(), - 'stl.trex_stl_lib.utils.re': mock.MagicMock(), - 'stl.trex_stl_lib.utils.string': mock.MagicMock(), - 'stl.trex_stl_lib.utils.sys': mock.MagicMock(), - 'stl.trex_stl_lib.utils.text_opts': mock.MagicMock(), - 'stl.trex_stl_lib.utils.text_tables': mock.MagicMock(), - 'stl.trex_stl_lib.utils.texttable': mock.MagicMock(), - 'stl.trex_stl_lib.warnings': mock.MagicMock(), - 'stl.trex_stl_lib.yaml': mock.MagicMock(), - 'stl.trex_stl_lib.zlib': mock.MagicMock(), - 'stl.trex_stl_lib.zmq': mock.MagicMock(), -} - STLClient = mock.MagicMock() stl_patch = mock.patch.dict("sys.modules", STL_MOCKS) stl_patch.start() diff --git a/tests/unit/network_services/vnf_generic/vnf/test_tg_ixload.py b/tests/unit/network_services/vnf_generic/vnf/test_tg_ixload.py index cda44127e..5c81aa886 100644 --- a/tests/unit/network_services/vnf_generic/vnf/test_tg_ixload.py +++ b/tests/unit/network_services/vnf_generic/vnf/test_tg_ixload.py @@ -16,69 +16,13 @@ # from __future__ import absolute_import + import unittest import mock import subprocess -STL_MOCKS = { - 'stl': mock.MagicMock(), - 'stl.trex_stl_lib': mock.MagicMock(), - 'stl.trex_stl_lib.base64': mock.MagicMock(), - 'stl.trex_stl_lib.binascii': mock.MagicMock(), - 'stl.trex_stl_lib.collections': mock.MagicMock(), - 'stl.trex_stl_lib.copy': mock.MagicMock(), - 'stl.trex_stl_lib.datetime': mock.MagicMock(), - 'stl.trex_stl_lib.functools': mock.MagicMock(), - 'stl.trex_stl_lib.imp': mock.MagicMock(), - 'stl.trex_stl_lib.inspect': mock.MagicMock(), - 'stl.trex_stl_lib.json': mock.MagicMock(), - 'stl.trex_stl_lib.linecache': mock.MagicMock(), - 'stl.trex_stl_lib.math': mock.MagicMock(), - 'stl.trex_stl_lib.os': mock.MagicMock(), - 'stl.trex_stl_lib.platform': mock.MagicMock(), - 'stl.trex_stl_lib.pprint': mock.MagicMock(), - 'stl.trex_stl_lib.random': mock.MagicMock(), - 'stl.trex_stl_lib.re': mock.MagicMock(), - 'stl.trex_stl_lib.scapy': mock.MagicMock(), - 'stl.trex_stl_lib.socket': mock.MagicMock(), - 'stl.trex_stl_lib.string': mock.MagicMock(), - 'stl.trex_stl_lib.struct': mock.MagicMock(), - 'stl.trex_stl_lib.sys': mock.MagicMock(), - 'stl.trex_stl_lib.threading': mock.MagicMock(), - 'stl.trex_stl_lib.time': mock.MagicMock(), - 'stl.trex_stl_lib.traceback': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_async_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_exceptions': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_ext': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_jsonrpc_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_packet_builder_interface': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_packet_builder_scapy': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_port': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_stats': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_streams': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_types': mock.MagicMock(), - 'stl.trex_stl_lib.types': mock.MagicMock(), - 'stl.trex_stl_lib.utils': mock.MagicMock(), - 'stl.trex_stl_lib.utils.argparse': mock.MagicMock(), - 'stl.trex_stl_lib.utils.collections': mock.MagicMock(), - 'stl.trex_stl_lib.utils.common': mock.MagicMock(), - 'stl.trex_stl_lib.utils.json': mock.MagicMock(), - 'stl.trex_stl_lib.utils.os': mock.MagicMock(), - 'stl.trex_stl_lib.utils.parsing_opts': mock.MagicMock(), - 'stl.trex_stl_lib.utils.pwd': mock.MagicMock(), - 'stl.trex_stl_lib.utils.random': mock.MagicMock(), - 'stl.trex_stl_lib.utils.re': mock.MagicMock(), - 'stl.trex_stl_lib.utils.string': mock.MagicMock(), - 'stl.trex_stl_lib.utils.sys': mock.MagicMock(), - 'stl.trex_stl_lib.utils.text_opts': mock.MagicMock(), - 'stl.trex_stl_lib.utils.text_tables': mock.MagicMock(), - 'stl.trex_stl_lib.utils.texttable': mock.MagicMock(), - 'stl.trex_stl_lib.warnings': mock.MagicMock(), - 'stl.trex_stl_lib.yaml': mock.MagicMock(), - 'stl.trex_stl_lib.zlib': mock.MagicMock(), - 'stl.trex_stl_lib.zmq': mock.MagicMock(), -} +from tests.unit import STL_MOCKS + STLClient = mock.MagicMock() stl_patch = mock.patch.dict("sys.modules", STL_MOCKS) diff --git a/tests/unit/network_services/vnf_generic/vnf/test_tg_ping.py b/tests/unit/network_services/vnf_generic/vnf/test_tg_ping.py index 949bfb3d4..45bbfaea3 100644 --- a/tests/unit/network_services/vnf_generic/vnf/test_tg_ping.py +++ b/tests/unit/network_services/vnf_generic/vnf/test_tg_ping.py @@ -16,74 +16,16 @@ # from __future__ import absolute_import + import unittest import mock from multiprocessing import Queue from tests.unit.network_services.vnf_generic.vnf.test_base import mock_ssh +from tests.unit import STL_MOCKS SSH_HELPER = "yardstick.network_services.vnf_generic.vnf.sample_vnf.VnfSshHelper" -STL_MOCKS = { - 'stl': mock.MagicMock(), - 'stl.trex_stl_lib': mock.MagicMock(), - 'stl.trex_stl_lib.base64': mock.MagicMock(), - 'stl.trex_stl_lib.binascii': mock.MagicMock(), - 'stl.trex_stl_lib.collections': mock.MagicMock(), - 'stl.trex_stl_lib.copy': mock.MagicMock(), - 'stl.trex_stl_lib.datetime': mock.MagicMock(), - 'stl.trex_stl_lib.functools': mock.MagicMock(), - 'stl.trex_stl_lib.imp': mock.MagicMock(), - 'stl.trex_stl_lib.inspect': mock.MagicMock(), - 'stl.trex_stl_lib.json': mock.MagicMock(), - 'stl.trex_stl_lib.linecache': mock.MagicMock(), - 'stl.trex_stl_lib.math': mock.MagicMock(), - 'stl.trex_stl_lib.os': mock.MagicMock(), - 'stl.trex_stl_lib.platform': mock.MagicMock(), - 'stl.trex_stl_lib.pprint': mock.MagicMock(), - 'stl.trex_stl_lib.random': mock.MagicMock(), - 'stl.trex_stl_lib.re': mock.MagicMock(), - 'stl.trex_stl_lib.scapy': mock.MagicMock(), - 'stl.trex_stl_lib.socket': mock.MagicMock(), - 'stl.trex_stl_lib.string': mock.MagicMock(), - 'stl.trex_stl_lib.struct': mock.MagicMock(), - 'stl.trex_stl_lib.sys': mock.MagicMock(), - 'stl.trex_stl_lib.threading': mock.MagicMock(), - 'stl.trex_stl_lib.time': mock.MagicMock(), - 'stl.trex_stl_lib.traceback': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_async_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_exceptions': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_ext': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_jsonrpc_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_packet_builder_interface': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_packet_builder_scapy': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_port': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_stats': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_streams': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_types': mock.MagicMock(), - 'stl.trex_stl_lib.types': mock.MagicMock(), - 'stl.trex_stl_lib.utils': mock.MagicMock(), - 'stl.trex_stl_lib.utils.argparse': mock.MagicMock(), - 'stl.trex_stl_lib.utils.collections': mock.MagicMock(), - 'stl.trex_stl_lib.utils.common': mock.MagicMock(), - 'stl.trex_stl_lib.utils.json': mock.MagicMock(), - 'stl.trex_stl_lib.utils.os': mock.MagicMock(), - 'stl.trex_stl_lib.utils.parsing_opts': mock.MagicMock(), - 'stl.trex_stl_lib.utils.pwd': mock.MagicMock(), - 'stl.trex_stl_lib.utils.random': mock.MagicMock(), - 'stl.trex_stl_lib.utils.re': mock.MagicMock(), - 'stl.trex_stl_lib.utils.string': mock.MagicMock(), - 'stl.trex_stl_lib.utils.sys': mock.MagicMock(), - 'stl.trex_stl_lib.utils.text_opts': mock.MagicMock(), - 'stl.trex_stl_lib.utils.text_tables': mock.MagicMock(), - 'stl.trex_stl_lib.utils.texttable': mock.MagicMock(), - 'stl.trex_stl_lib.warnings': mock.MagicMock(), - 'stl.trex_stl_lib.yaml': mock.MagicMock(), - 'stl.trex_stl_lib.zlib': mock.MagicMock(), - 'stl.trex_stl_lib.zmq': mock.MagicMock(), -} - STLClient = mock.MagicMock() stl_patch = mock.patch.dict("sys.modules", STL_MOCKS) stl_patch.start() diff --git a/tests/unit/network_services/vnf_generic/vnf/test_tg_prox.py b/tests/unit/network_services/vnf_generic/vnf/test_tg_prox.py index 1a01b9e15..12abadf98 100644 --- a/tests/unit/network_services/vnf_generic/vnf/test_tg_prox.py +++ b/tests/unit/network_services/vnf_generic/vnf/test_tg_prox.py @@ -14,76 +14,17 @@ # from __future__ import absolute_import + import unittest import mock from tests.unit.network_services.vnf_generic.vnf.test_base import mock_ssh +from tests.unit import STL_MOCKS SSH_HELPER = 'yardstick.network_services.vnf_generic.vnf.sample_vnf.VnfSshHelper' NAME = 'vnf__1' - -STL_MOCKS = { - 'stl': mock.MagicMock(), - 'stl.trex_stl_lib': mock.MagicMock(), - 'stl.trex_stl_lib.base64': mock.MagicMock(), - 'stl.trex_stl_lib.binascii': mock.MagicMock(), - 'stl.trex_stl_lib.collections': mock.MagicMock(), - 'stl.trex_stl_lib.copy': mock.MagicMock(), - 'stl.trex_stl_lib.datetime': mock.MagicMock(), - 'stl.trex_stl_lib.functools': mock.MagicMock(), - 'stl.trex_stl_lib.imp': mock.MagicMock(), - 'stl.trex_stl_lib.inspect': mock.MagicMock(), - 'stl.trex_stl_lib.json': mock.MagicMock(), - 'stl.trex_stl_lib.linecache': mock.MagicMock(), - 'stl.trex_stl_lib.math': mock.MagicMock(), - 'stl.trex_stl_lib.os': mock.MagicMock(), - 'stl.trex_stl_lib.platform': mock.MagicMock(), - 'stl.trex_stl_lib.pprint': mock.MagicMock(), - 'stl.trex_stl_lib.random': mock.MagicMock(), - 'stl.trex_stl_lib.re': mock.MagicMock(), - 'stl.trex_stl_lib.scapy': mock.MagicMock(), - 'stl.trex_stl_lib.socket': mock.MagicMock(), - 'stl.trex_stl_lib.string': mock.MagicMock(), - 'stl.trex_stl_lib.struct': mock.MagicMock(), - 'stl.trex_stl_lib.sys': mock.MagicMock(), - 'stl.trex_stl_lib.threading': mock.MagicMock(), - 'stl.trex_stl_lib.time': mock.MagicMock(), - 'stl.trex_stl_lib.traceback': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_async_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_exceptions': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_ext': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_jsonrpc_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_packet_builder_interface': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_packet_builder_scapy': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_port': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_stats': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_streams': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_types': mock.MagicMock(), - 'stl.trex_stl_lib.types': mock.MagicMock(), - 'stl.trex_stl_lib.utils': mock.MagicMock(), - 'stl.trex_stl_lib.utils.argparse': mock.MagicMock(), - 'stl.trex_stl_lib.utils.collections': mock.MagicMock(), - 'stl.trex_stl_lib.utils.common': mock.MagicMock(), - 'stl.trex_stl_lib.utils.json': mock.MagicMock(), - 'stl.trex_stl_lib.utils.os': mock.MagicMock(), - 'stl.trex_stl_lib.utils.parsing_opts': mock.MagicMock(), - 'stl.trex_stl_lib.utils.pwd': mock.MagicMock(), - 'stl.trex_stl_lib.utils.random': mock.MagicMock(), - 'stl.trex_stl_lib.utils.re': mock.MagicMock(), - 'stl.trex_stl_lib.utils.string': mock.MagicMock(), - 'stl.trex_stl_lib.utils.sys': mock.MagicMock(), - 'stl.trex_stl_lib.utils.text_opts': mock.MagicMock(), - 'stl.trex_stl_lib.utils.text_tables': mock.MagicMock(), - 'stl.trex_stl_lib.utils.texttable': mock.MagicMock(), - 'stl.trex_stl_lib.warnings': mock.MagicMock(), - 'stl.trex_stl_lib.yaml': mock.MagicMock(), - 'stl.trex_stl_lib.zlib': mock.MagicMock(), - 'stl.trex_stl_lib.zmq': mock.MagicMock(), -} - STLClient = mock.MagicMock() stl_patch = mock.patch.dict("sys.modules", STL_MOCKS) stl_patch.start() diff --git a/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py b/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py index 8f7f05772..ca8150cb2 100644 --- a/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py +++ b/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py @@ -16,68 +16,13 @@ # from __future__ import absolute_import + import os import unittest import mock -STL_MOCKS = { - 'stl': mock.MagicMock(), - 'stl.trex_stl_lib': mock.MagicMock(), - 'stl.trex_stl_lib.base64': mock.MagicMock(), - 'stl.trex_stl_lib.binascii': mock.MagicMock(), - 'stl.trex_stl_lib.collections': mock.MagicMock(), - 'stl.trex_stl_lib.copy': mock.MagicMock(), - 'stl.trex_stl_lib.datetime': mock.MagicMock(), - 'stl.trex_stl_lib.functools': mock.MagicMock(), - 'stl.trex_stl_lib.imp': mock.MagicMock(), - 'stl.trex_stl_lib.inspect': mock.MagicMock(), - 'stl.trex_stl_lib.json': mock.MagicMock(), - 'stl.trex_stl_lib.linecache': mock.MagicMock(), - 'stl.trex_stl_lib.math': mock.MagicMock(), - 'stl.trex_stl_lib.os': mock.MagicMock(), - 'stl.trex_stl_lib.platform': mock.MagicMock(), - 'stl.trex_stl_lib.pprint': mock.MagicMock(), - 'stl.trex_stl_lib.random': mock.MagicMock(), - 'stl.trex_stl_lib.re': mock.MagicMock(), - 'stl.trex_stl_lib.scapy': mock.MagicMock(), - 'stl.trex_stl_lib.socket': mock.MagicMock(), - 'stl.trex_stl_lib.string': mock.MagicMock(), - 'stl.trex_stl_lib.struct': mock.MagicMock(), - 'stl.trex_stl_lib.sys': mock.MagicMock(), - 'stl.trex_stl_lib.threading': mock.MagicMock(), - 'stl.trex_stl_lib.time': mock.MagicMock(), - 'stl.trex_stl_lib.traceback': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_async_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_exceptions': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_ext': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_jsonrpc_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_packet_builder_interface': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_packet_builder_scapy': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_port': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_stats': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_streams': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_types': mock.MagicMock(), - 'stl.trex_stl_lib.types': mock.MagicMock(), - 'stl.trex_stl_lib.utils': mock.MagicMock(), - 'stl.trex_stl_lib.utils.argparse': mock.MagicMock(), - 'stl.trex_stl_lib.utils.collections': mock.MagicMock(), - 'stl.trex_stl_lib.utils.common': mock.MagicMock(), - 'stl.trex_stl_lib.utils.json': mock.MagicMock(), - 'stl.trex_stl_lib.utils.os': mock.MagicMock(), - 'stl.trex_stl_lib.utils.parsing_opts': mock.MagicMock(), - 'stl.trex_stl_lib.utils.pwd': mock.MagicMock(), - 'stl.trex_stl_lib.utils.random': mock.MagicMock(), - 'stl.trex_stl_lib.utils.re': mock.MagicMock(), - 'stl.trex_stl_lib.utils.string': mock.MagicMock(), - 'stl.trex_stl_lib.utils.sys': mock.MagicMock(), - 'stl.trex_stl_lib.utils.text_opts': mock.MagicMock(), - 'stl.trex_stl_lib.utils.text_tables': mock.MagicMock(), - 'stl.trex_stl_lib.utils.texttable': mock.MagicMock(), - 'stl.trex_stl_lib.warnings': mock.MagicMock(), - 'stl.trex_stl_lib.yaml': mock.MagicMock(), - 'stl.trex_stl_lib.zlib': mock.MagicMock(), - 'stl.trex_stl_lib.zmq': mock.MagicMock(), -} + +from tests.unit import STL_MOCKS + STLClient = mock.MagicMock() stl_patch = mock.patch.dict("sys.modules", STL_MOCKS) diff --git a/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_trex.py b/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_trex.py index 7dc303852..ad8c6494e 100644 --- a/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_trex.py +++ b/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_trex.py @@ -16,70 +16,14 @@ # from __future__ import absolute_import + import unittest import mock -SSH_HELPER = "yardstick.ssh.SSH" +from tests.unit import STL_MOCKS -STL_MOCKS = { - 'stl': mock.MagicMock(), - 'stl.trex_stl_lib': mock.MagicMock(), - 'stl.trex_stl_lib.base64': mock.MagicMock(), - 'stl.trex_stl_lib.binascii': mock.MagicMock(), - 'stl.trex_stl_lib.collections': mock.MagicMock(), - 'stl.trex_stl_lib.copy': mock.MagicMock(), - 'stl.trex_stl_lib.datetime': mock.MagicMock(), - 'stl.trex_stl_lib.functools': mock.MagicMock(), - 'stl.trex_stl_lib.imp': mock.MagicMock(), - 'stl.trex_stl_lib.inspect': mock.MagicMock(), - 'stl.trex_stl_lib.json': mock.MagicMock(), - 'stl.trex_stl_lib.linecache': mock.MagicMock(), - 'stl.trex_stl_lib.math': mock.MagicMock(), - 'stl.trex_stl_lib.os': mock.MagicMock(), - 'stl.trex_stl_lib.platform': mock.MagicMock(), - 'stl.trex_stl_lib.pprint': mock.MagicMock(), - 'stl.trex_stl_lib.random': mock.MagicMock(), - 'stl.trex_stl_lib.re': mock.MagicMock(), - 'stl.trex_stl_lib.scapy': mock.MagicMock(), - 'stl.trex_stl_lib.socket': mock.MagicMock(), - 'stl.trex_stl_lib.string': mock.MagicMock(), - 'stl.trex_stl_lib.struct': mock.MagicMock(), - 'stl.trex_stl_lib.sys': mock.MagicMock(), - 'stl.trex_stl_lib.threading': mock.MagicMock(), - 'stl.trex_stl_lib.time': mock.MagicMock(), - 'stl.trex_stl_lib.traceback': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_async_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_exceptions': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_ext': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_jsonrpc_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_packet_builder_interface': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_packet_builder_scapy': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_port': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_stats': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_streams': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_types': mock.MagicMock(), - 'stl.trex_stl_lib.types': mock.MagicMock(), - 'stl.trex_stl_lib.utils': mock.MagicMock(), - 'stl.trex_stl_lib.utils.argparse': mock.MagicMock(), - 'stl.trex_stl_lib.utils.collections': mock.MagicMock(), - 'stl.trex_stl_lib.utils.common': mock.MagicMock(), - 'stl.trex_stl_lib.utils.json': mock.MagicMock(), - 'stl.trex_stl_lib.utils.os': mock.MagicMock(), - 'stl.trex_stl_lib.utils.parsing_opts': mock.MagicMock(), - 'stl.trex_stl_lib.utils.pwd': mock.MagicMock(), - 'stl.trex_stl_lib.utils.random': mock.MagicMock(), - 'stl.trex_stl_lib.utils.re': mock.MagicMock(), - 'stl.trex_stl_lib.utils.string': mock.MagicMock(), - 'stl.trex_stl_lib.utils.sys': mock.MagicMock(), - 'stl.trex_stl_lib.utils.text_opts': mock.MagicMock(), - 'stl.trex_stl_lib.utils.text_tables': mock.MagicMock(), - 'stl.trex_stl_lib.utils.texttable': mock.MagicMock(), - 'stl.trex_stl_lib.warnings': mock.MagicMock(), - 'stl.trex_stl_lib.yaml': mock.MagicMock(), - 'stl.trex_stl_lib.zlib': mock.MagicMock(), - 'stl.trex_stl_lib.zmq': mock.MagicMock(), -} + +SSH_HELPER = "yardstick.ssh.SSH" STLClient = mock.MagicMock() stl_patch = mock.patch.dict("sys.modules", STL_MOCKS) @@ -289,7 +233,7 @@ class TestTrexTrafficGenRFC(unittest.TestCase): def test_collect_kpi(self, ssh): mock_ssh(ssh) trex_traffic_gen = TrexTrafficGenRFC('vnf1', self.VNFD_0) - self.assertIsNone(trex_traffic_gen.collect_kpi()) + self.assertEqual(trex_traffic_gen.collect_kpi(), {}) @mock.patch(SSH_HELPER) def test_listen_traffic(self, ssh): diff --git a/tests/unit/network_services/vnf_generic/vnf/test_tg_trex.py b/tests/unit/network_services/vnf_generic/vnf/test_tg_trex.py index 6fb5d080f..65370dfa5 100644 --- a/tests/unit/network_services/vnf_generic/vnf/test_tg_trex.py +++ b/tests/unit/network_services/vnf_generic/vnf/test_tg_trex.py @@ -16,74 +16,16 @@ # from __future__ import absolute_import + import unittest import mock from tests.unit.network_services.vnf_generic.vnf.test_base import mock_ssh +from tests.unit import STL_MOCKS NAME = 'vnf_1' -STL_MOCKS = { - 'stl': mock.MagicMock(), - 'stl.trex_stl_lib': mock.MagicMock(), - 'stl.trex_stl_lib.base64': mock.MagicMock(), - 'stl.trex_stl_lib.binascii': mock.MagicMock(), - 'stl.trex_stl_lib.collections': mock.MagicMock(), - 'stl.trex_stl_lib.copy': mock.MagicMock(), - 'stl.trex_stl_lib.datetime': mock.MagicMock(), - 'stl.trex_stl_lib.functools': mock.MagicMock(), - 'stl.trex_stl_lib.imp': mock.MagicMock(), - 'stl.trex_stl_lib.inspect': mock.MagicMock(), - 'stl.trex_stl_lib.json': mock.MagicMock(), - 'stl.trex_stl_lib.linecache': mock.MagicMock(), - 'stl.trex_stl_lib.math': mock.MagicMock(), - 'stl.trex_stl_lib.os': mock.MagicMock(), - 'stl.trex_stl_lib.platform': mock.MagicMock(), - 'stl.trex_stl_lib.pprint': mock.MagicMock(), - 'stl.trex_stl_lib.random': mock.MagicMock(), - 'stl.trex_stl_lib.re': mock.MagicMock(), - 'stl.trex_stl_lib.scapy': mock.MagicMock(), - 'stl.trex_stl_lib.socket': mock.MagicMock(), - 'stl.trex_stl_lib.string': mock.MagicMock(), - 'stl.trex_stl_lib.struct': mock.MagicMock(), - 'stl.trex_stl_lib.sys': mock.MagicMock(), - 'stl.trex_stl_lib.threading': mock.MagicMock(), - 'stl.trex_stl_lib.time': mock.MagicMock(), - 'stl.trex_stl_lib.traceback': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_async_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_exceptions': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_ext': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_jsonrpc_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_packet_builder_interface': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_packet_builder_scapy': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_port': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_stats': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_streams': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_types': mock.MagicMock(), - 'stl.trex_stl_lib.types': mock.MagicMock(), - 'stl.trex_stl_lib.utils': mock.MagicMock(), - 'stl.trex_stl_lib.utils.argparse': mock.MagicMock(), - 'stl.trex_stl_lib.utils.collections': mock.MagicMock(), - 'stl.trex_stl_lib.utils.common': mock.MagicMock(), - 'stl.trex_stl_lib.utils.json': mock.MagicMock(), - 'stl.trex_stl_lib.utils.os': mock.MagicMock(), - 'stl.trex_stl_lib.utils.parsing_opts': mock.MagicMock(), - 'stl.trex_stl_lib.utils.pwd': mock.MagicMock(), - 'stl.trex_stl_lib.utils.random': mock.MagicMock(), - 'stl.trex_stl_lib.utils.re': mock.MagicMock(), - 'stl.trex_stl_lib.utils.string': mock.MagicMock(), - 'stl.trex_stl_lib.utils.sys': mock.MagicMock(), - 'stl.trex_stl_lib.utils.text_opts': mock.MagicMock(), - 'stl.trex_stl_lib.utils.text_tables': mock.MagicMock(), - 'stl.trex_stl_lib.utils.texttable': mock.MagicMock(), - 'stl.trex_stl_lib.warnings': mock.MagicMock(), - 'stl.trex_stl_lib.yaml': mock.MagicMock(), - 'stl.trex_stl_lib.zlib': mock.MagicMock(), - 'stl.trex_stl_lib.zmq': mock.MagicMock(), -} - STLClient = mock.MagicMock() stl_patch = mock.patch.dict("sys.modules", STL_MOCKS) stl_patch.start() diff --git a/tests/unit/network_services/vnf_generic/vnf/test_udp_replay.py b/tests/unit/network_services/vnf_generic/vnf/test_udp_replay.py index 08bf06b74..f0d75d57b 100644 --- a/tests/unit/network_services/vnf_generic/vnf/test_udp_replay.py +++ b/tests/unit/network_services/vnf_generic/vnf/test_udp_replay.py @@ -16,70 +16,13 @@ # from __future__ import absolute_import + import unittest import mock import os +from tests.unit import STL_MOCKS -STL_MOCKS = { - 'stl': mock.MagicMock(), - 'stl.trex_stl_lib': mock.MagicMock(), - 'stl.trex_stl_lib.base64': mock.MagicMock(), - 'stl.trex_stl_lib.binascii': mock.MagicMock(), - 'stl.trex_stl_lib.collections': mock.MagicMock(), - 'stl.trex_stl_lib.copy': mock.MagicMock(), - 'stl.trex_stl_lib.datetime': mock.MagicMock(), - 'stl.trex_stl_lib.functools': mock.MagicMock(), - 'stl.trex_stl_lib.imp': mock.MagicMock(), - 'stl.trex_stl_lib.inspect': mock.MagicMock(), - 'stl.trex_stl_lib.json': mock.MagicMock(), - 'stl.trex_stl_lib.linecache': mock.MagicMock(), - 'stl.trex_stl_lib.math': mock.MagicMock(), - 'stl.trex_stl_lib.os': mock.MagicMock(), - 'stl.trex_stl_lib.platform': mock.MagicMock(), - 'stl.trex_stl_lib.pprint': mock.MagicMock(), - 'stl.trex_stl_lib.random': mock.MagicMock(), - 'stl.trex_stl_lib.re': mock.MagicMock(), - 'stl.trex_stl_lib.scapy': mock.MagicMock(), - 'stl.trex_stl_lib.socket': mock.MagicMock(), - 'stl.trex_stl_lib.string': mock.MagicMock(), - 'stl.trex_stl_lib.struct': mock.MagicMock(), - 'stl.trex_stl_lib.sys': mock.MagicMock(), - 'stl.trex_stl_lib.threading': mock.MagicMock(), - 'stl.trex_stl_lib.time': mock.MagicMock(), - 'stl.trex_stl_lib.traceback': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_async_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_exceptions': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_ext': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_jsonrpc_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_packet_builder_interface': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_packet_builder_scapy': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_port': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_stats': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_streams': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_types': mock.MagicMock(), - 'stl.trex_stl_lib.types': mock.MagicMock(), - 'stl.trex_stl_lib.utils': mock.MagicMock(), - 'stl.trex_stl_lib.utils.argparse': mock.MagicMock(), - 'stl.trex_stl_lib.utils.collections': mock.MagicMock(), - 'stl.trex_stl_lib.utils.common': mock.MagicMock(), - 'stl.trex_stl_lib.utils.json': mock.MagicMock(), - 'stl.trex_stl_lib.utils.os': mock.MagicMock(), - 'stl.trex_stl_lib.utils.parsing_opts': mock.MagicMock(), - 'stl.trex_stl_lib.utils.pwd': mock.MagicMock(), - 'stl.trex_stl_lib.utils.random': mock.MagicMock(), - 'stl.trex_stl_lib.utils.re': mock.MagicMock(), - 'stl.trex_stl_lib.utils.string': mock.MagicMock(), - 'stl.trex_stl_lib.utils.sys': mock.MagicMock(), - 'stl.trex_stl_lib.utils.text_opts': mock.MagicMock(), - 'stl.trex_stl_lib.utils.text_tables': mock.MagicMock(), - 'stl.trex_stl_lib.utils.texttable': mock.MagicMock(), - 'stl.trex_stl_lib.warnings': mock.MagicMock(), - 'stl.trex_stl_lib.yaml': mock.MagicMock(), - 'stl.trex_stl_lib.zlib': mock.MagicMock(), - 'stl.trex_stl_lib.zmq': mock.MagicMock(), -} STLClient = mock.MagicMock() stl_patch = mock.patch.dict("sys.modules", STL_MOCKS) diff --git a/tests/unit/network_services/vnf_generic/vnf/test_vfw_vnf.py b/tests/unit/network_services/vnf_generic/vnf/test_vfw_vnf.py index d817b164c..7dae89f40 100644 --- a/tests/unit/network_services/vnf_generic/vnf/test_vfw_vnf.py +++ b/tests/unit/network_services/vnf_generic/vnf/test_vfw_vnf.py @@ -16,69 +16,13 @@ # from __future__ import absolute_import + import unittest import mock import os -STL_MOCKS = { - 'stl': mock.MagicMock(), - 'stl.trex_stl_lib': mock.MagicMock(), - 'stl.trex_stl_lib.base64': mock.MagicMock(), - 'stl.trex_stl_lib.binascii': mock.MagicMock(), - 'stl.trex_stl_lib.collections': mock.MagicMock(), - 'stl.trex_stl_lib.copy': mock.MagicMock(), - 'stl.trex_stl_lib.datetime': mock.MagicMock(), - 'stl.trex_stl_lib.functools': mock.MagicMock(), - 'stl.trex_stl_lib.imp': mock.MagicMock(), - 'stl.trex_stl_lib.inspect': mock.MagicMock(), - 'stl.trex_stl_lib.json': mock.MagicMock(), - 'stl.trex_stl_lib.linecache': mock.MagicMock(), - 'stl.trex_stl_lib.math': mock.MagicMock(), - 'stl.trex_stl_lib.os': mock.MagicMock(), - 'stl.trex_stl_lib.platform': mock.MagicMock(), - 'stl.trex_stl_lib.pprint': mock.MagicMock(), - 'stl.trex_stl_lib.random': mock.MagicMock(), - 'stl.trex_stl_lib.re': mock.MagicMock(), - 'stl.trex_stl_lib.scapy': mock.MagicMock(), - 'stl.trex_stl_lib.socket': mock.MagicMock(), - 'stl.trex_stl_lib.string': mock.MagicMock(), - 'stl.trex_stl_lib.struct': mock.MagicMock(), - 'stl.trex_stl_lib.sys': mock.MagicMock(), - 'stl.trex_stl_lib.threading': mock.MagicMock(), - 'stl.trex_stl_lib.time': mock.MagicMock(), - 'stl.trex_stl_lib.traceback': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_async_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_exceptions': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_ext': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_jsonrpc_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_packet_builder_interface': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_packet_builder_scapy': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_port': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_stats': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_streams': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_types': mock.MagicMock(), - 'stl.trex_stl_lib.types': mock.MagicMock(), - 'stl.trex_stl_lib.utils': mock.MagicMock(), - 'stl.trex_stl_lib.utils.argparse': mock.MagicMock(), - 'stl.trex_stl_lib.utils.collections': mock.MagicMock(), - 'stl.trex_stl_lib.utils.common': mock.MagicMock(), - 'stl.trex_stl_lib.utils.json': mock.MagicMock(), - 'stl.trex_stl_lib.utils.os': mock.MagicMock(), - 'stl.trex_stl_lib.utils.parsing_opts': mock.MagicMock(), - 'stl.trex_stl_lib.utils.pwd': mock.MagicMock(), - 'stl.trex_stl_lib.utils.random': mock.MagicMock(), - 'stl.trex_stl_lib.utils.re': mock.MagicMock(), - 'stl.trex_stl_lib.utils.string': mock.MagicMock(), - 'stl.trex_stl_lib.utils.sys': mock.MagicMock(), - 'stl.trex_stl_lib.utils.text_opts': mock.MagicMock(), - 'stl.trex_stl_lib.utils.text_tables': mock.MagicMock(), - 'stl.trex_stl_lib.utils.texttable': mock.MagicMock(), - 'stl.trex_stl_lib.warnings': mock.MagicMock(), - 'stl.trex_stl_lib.yaml': mock.MagicMock(), - 'stl.trex_stl_lib.zlib': mock.MagicMock(), - 'stl.trex_stl_lib.zmq': mock.MagicMock(), -} +from tests.unit import STL_MOCKS + STLClient = mock.MagicMock() stl_patch = mock.patch.dict("sys.modules", STL_MOCKS) diff --git a/tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py b/tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py index 80b4a5108..5e66390e3 100644 --- a/tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py +++ b/tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py @@ -16,77 +16,18 @@ # from __future__ import absolute_import +import six.moves.configparser as configparser import os import unittest - -import six.moves.configparser as configparser import mock from multiprocessing import Process, Queue +from tests.unit import STL_MOCKS from yardstick.network_services.vnf_generic.vnf.base import QueueFileWrapper -SSH_HELPER = 'yardstick.network_services.vnf_generic.vnf.sample_vnf.VnfSshHelper' -STL_MOCKS = { - 'stl': mock.MagicMock(), - 'stl.trex_stl_lib': mock.MagicMock(), - 'stl.trex_stl_lib.base64': mock.MagicMock(), - 'stl.trex_stl_lib.binascii': mock.MagicMock(), - 'stl.trex_stl_lib.collections': mock.MagicMock(), - 'stl.trex_stl_lib.copy': mock.MagicMock(), - 'stl.trex_stl_lib.datetime': mock.MagicMock(), - 'stl.trex_stl_lib.functools': mock.MagicMock(), - 'stl.trex_stl_lib.imp': mock.MagicMock(), - 'stl.trex_stl_lib.inspect': mock.MagicMock(), - 'stl.trex_stl_lib.json': mock.MagicMock(), - 'stl.trex_stl_lib.linecache': mock.MagicMock(), - 'stl.trex_stl_lib.math': mock.MagicMock(), - 'stl.trex_stl_lib.os': mock.MagicMock(), - 'stl.trex_stl_lib.platform': mock.MagicMock(), - 'stl.trex_stl_lib.pprint': mock.MagicMock(), - 'stl.trex_stl_lib.random': mock.MagicMock(), - 'stl.trex_stl_lib.re': mock.MagicMock(), - 'stl.trex_stl_lib.scapy': mock.MagicMock(), - 'stl.trex_stl_lib.socket': mock.MagicMock(), - 'stl.trex_stl_lib.string': mock.MagicMock(), - 'stl.trex_stl_lib.struct': mock.MagicMock(), - 'stl.trex_stl_lib.sys': mock.MagicMock(), - 'stl.trex_stl_lib.threading': mock.MagicMock(), - 'stl.trex_stl_lib.time': mock.MagicMock(), - 'stl.trex_stl_lib.traceback': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_async_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_exceptions': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_ext': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_jsonrpc_client': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_packet_builder_interface': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_packet_builder_scapy': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_port': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_stats': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_streams': mock.MagicMock(), - 'stl.trex_stl_lib.trex_stl_types': mock.MagicMock(), - 'stl.trex_stl_lib.types': mock.MagicMock(), - 'stl.trex_stl_lib.utils': mock.MagicMock(), - 'stl.trex_stl_lib.utils.argparse': mock.MagicMock(), - 'stl.trex_stl_lib.utils.collections': mock.MagicMock(), - 'stl.trex_stl_lib.utils.common': mock.MagicMock(), - 'stl.trex_stl_lib.utils.json': mock.MagicMock(), - 'stl.trex_stl_lib.utils.os': mock.MagicMock(), - 'stl.trex_stl_lib.utils.parsing_opts': mock.MagicMock(), - 'stl.trex_stl_lib.utils.pwd': mock.MagicMock(), - 'stl.trex_stl_lib.utils.random': mock.MagicMock(), - 'stl.trex_stl_lib.utils.re': mock.MagicMock(), - 'stl.trex_stl_lib.utils.string': mock.MagicMock(), - 'stl.trex_stl_lib.utils.sys': mock.MagicMock(), - 'stl.trex_stl_lib.utils.text_opts': mock.MagicMock(), - 'stl.trex_stl_lib.utils.text_tables': mock.MagicMock(), - 'stl.trex_stl_lib.utils.texttable': mock.MagicMock(), - 'stl.trex_stl_lib.warnings': mock.MagicMock(), - 'stl.trex_stl_lib.yaml': mock.MagicMock(), - 'stl.trex_stl_lib.zlib': mock.MagicMock(), - 'stl.trex_stl_lib.zmq': mock.MagicMock(), -} +SSH_HELPER = 'yardstick.network_services.vnf_generic.vnf.sample_vnf.VnfSshHelper' STLClient = mock.MagicMock() stl_patch = mock.patch.dict("sys.modules", STL_MOCKS) |