Add "duration" parameter to test case definition
[yardstick.git] / yardstick / tests / unit / benchmark / scenarios / networking / test_vnf_generic.py
index c7a29f2..bb1a7aa 100644 (file)
@@ -20,11 +20,11 @@ import mock
 import unittest
 
 from yardstick import tests
+from yardstick.common import exceptions
 from yardstick.common import utils
 from yardstick.network_services.collector.subscriber import Collector
 from yardstick.network_services.traffic_profile import base
 from yardstick.network_services.vnf_generic import vnfdgen
-from yardstick.error import IncorrectConfig
 from yardstick.network_services.vnf_generic.vnf.base import GenericTrafficGen
 from yardstick.network_services.vnf_generic.vnf.base import GenericVNF
 
@@ -355,7 +355,7 @@ class TestNetworkServiceTestCase(unittest.TestCase):
         return file_path
 
     def test___init__(self):
-        assert self.topology
+        self.assertIsNotNone(self.topology)
 
     def test__get_ip_flow_range_string(self):
         self.scenario_cfg["traffic_options"]["flow"] = \
@@ -423,7 +423,7 @@ class TestNetworkServiceTestCase(unittest.TestCase):
         with mock.patch.dict(sys.modules, tests.STL_MOCKS):
             self.assertIsNotNone(self.s.get_vnf_impl(vnfd))
 
-        with self.assertRaises(vnf_generic.IncorrectConfig) as raised:
+        with self.assertRaises(exceptions.IncorrectConfig) as raised:
             self.s.get_vnf_impl('NonExistentClass')
 
         exc_str = str(raised.exception)
@@ -465,7 +465,7 @@ class TestNetworkServiceTestCase(unittest.TestCase):
 
         cfg_patch = mock.patch.object(self.s, 'context_cfg', cfg)
         with cfg_patch:
-            with self.assertRaises(IncorrectConfig):
+            with self.assertRaises(exceptions.IncorrectConfig):
                 self.s.map_topology_to_infrastructure()
 
     def test_map_topology_to_infrastructure_config_invalid(self):
@@ -482,7 +482,7 @@ class TestNetworkServiceTestCase(unittest.TestCase):
 
         config_patch = mock.patch.object(self.s, 'context_cfg', cfg)
         with config_patch:
-            with self.assertRaises(IncorrectConfig):
+            with self.assertRaises(exceptions.IncorrectConfig):
                 self.s.map_topology_to_infrastructure()
 
     def test__resolve_topology_invalid_config(self):
@@ -496,7 +496,7 @@ class TestNetworkServiceTestCase(unittest.TestCase):
             for interface in self.tg__1['interfaces'].values():
                 del interface['local_mac']
 
-            with self.assertRaises(vnf_generic.IncorrectConfig) as raised:
+            with self.assertRaises(exceptions.IncorrectConfig) as raised:
                 self.s._resolve_topology()
 
             self.assertIn('not found', str(raised.exception))
@@ -509,7 +509,7 @@ class TestNetworkServiceTestCase(unittest.TestCase):
             self.s.topology["vld"][0]['vnfd-connection-point-ref'].append(
                 self.s.topology["vld"][0]['vnfd-connection-point-ref'][0])
 
-            with self.assertRaises(vnf_generic.IncorrectConfig) as raised:
+            with self.assertRaises(exceptions.IncorrectConfig) as raised:
                 self.s._resolve_topology()
 
             self.assertIn('wrong endpoint count', str(raised.exception))
@@ -518,7 +518,7 @@ class TestNetworkServiceTestCase(unittest.TestCase):
             self.s.topology["vld"][0]['vnfd-connection-point-ref'] = \
                 self.s.topology["vld"][0]['vnfd-connection-point-ref'][:1]
 
-            with self.assertRaises(vnf_generic.IncorrectConfig) as raised:
+            with self.assertRaises(exceptions.IncorrectConfig) as raised:
                 self.s._resolve_topology()
 
             self.assertIn('wrong endpoint count', str(raised.exception))
@@ -565,7 +565,7 @@ class TestNetworkServiceTestCase(unittest.TestCase):
             self.s.load_vnf_models = mock.Mock(return_value=self.s.vnfs)
             self.s._fill_traffic_profile = \
                 mock.Mock(return_value=TRAFFIC_PROFILE)
-            self.assertEqual(None, self.s.setup())
+            self.assertIsNone(self.s.setup())
 
     def test_setup_exception(self):
         with mock.patch("yardstick.ssh.SSH") as ssh:
@@ -628,7 +628,8 @@ class TestNetworkServiceTestCase(unittest.TestCase):
                  'extra_args': {'arg1': 'value1', 'arg2': 'value2'},
                  'flow': {'flow': {}},
                  'imix': {'imix': {'64B': 100}},
-                 'uplink': {}}
+                 'uplink': {},
+                 'duration': 30}
             )
             mock_tprofile_get.assert_called_once_with(fake_vnfd)