summaryrefslogtreecommitdiffstats
path: root/tests/unit
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/__init__.py8
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_ixia.py22
2 files changed, 21 insertions, 9 deletions
diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py
index 5935abbac..95b2b8a4e 100644
--- a/tests/unit/__init__.py
+++ b/tests/unit/__init__.py
@@ -12,9 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from yardstick import tests
+import sys
+
+import mock
+from yardstick import tests
# NOTE(ralonsoh): to be removed. Replace all occurrences of
# tests.unit.STL_MOCKS with yardstick.tests.STL_MOCKS
STL_MOCKS = tests.STL_MOCKS
+
+mock_stl = mock.patch.dict(sys.modules, tests.STL_MOCKS)
+mock_stl.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 04cd9e858..146c6c96a 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
@@ -30,7 +30,8 @@ NAME = "tg__1"
class TestIxiaResourceHelper(unittest.TestCase):
def setUp(self):
- self._mock_IxNextgen = mock.patch.object(tg_rfc2544_ixia, 'IxNextgen')
+ self._mock_IxNextgen = mock.patch.object(tg_rfc2544_ixia,
+ 'IxNextgen')
self.mock_IxNextgen = self._mock_IxNextgen.start()
self.addCleanup(self._stop_mocks)
@@ -54,13 +55,19 @@ class TestIxiaResourceHelper(unittest.TestCase):
ixia_resource_helper.stop_collect()
self.assertEqual(mock_client.ix_stop_traffic.call_count, 1)
- # NOTE(ralonsoh): to be updated in next patchset
- def test__initialise_client(self):
- pass
-
- # NOTE(ralonsoh): to be updated in next patchset
def test_run_traffic(self):
- pass
+ mock_tprofile = mock.Mock()
+ mock_tprofile.get_drop_percentage.return_value = True, 'fake_samples'
+ ixia_rhelper = tg_rfc2544_ixia.IxiaResourceHelper(mock.Mock())
+ ixia_rhelper.rfc_helper = mock.Mock()
+ ixia_rhelper.vnfd_helper = mock.Mock()
+ ixia_rhelper.vnfd_helper.port_pairs.all_ports = []
+ with mock.patch.object(ixia_rhelper, 'generate_samples'), \
+ mock.patch.object(ixia_rhelper, '_build_ports'), \
+ mock.patch.object(ixia_rhelper, '_initialize_client'):
+ ixia_rhelper.run_traffic(mock_tprofile)
+
+ self.assertEqual('fake_samples', ixia_rhelper._queue.get())
@mock.patch("yardstick.network_services.vnf_generic.vnf.tg_rfc2544_ixia.IxNextgen")
@@ -248,7 +255,6 @@ class TestIXIATrafficGen(unittest.TestCase):
sut = tg_rfc2544_ixia.IxiaTrafficGen('vnf1', vnfd)
sut._check_status()
- @mock.patch("yardstick.network_services.vnf_generic.vnf.tg_rfc2544_ixia.time")
@mock.patch("yardstick.ssh.SSH")
def test_traffic_runner(self, mock_ssh, *args):
mock_traffic_profile = mock.Mock(autospec=tp_base.TrafficProfile)