Merge "[docs] Rename image tc014_pod_frase{e,}r.png"
[yardstick.git] / yardstick / tests / unit / network_services / libs / ixia_libs / test_ixnet_api.py
index 66fed81..c80cbbe 100644 (file)
@@ -592,6 +592,26 @@ class TestIxNextgen(unittest.TestCase):
             mock.call(port_statistics, self.ixnet_gen.PORT_STATS_NAME_MAP),
             mock.call(flow_statistics, self.ixnet_gen.LATENCY_NAME_MAP)])
 
+    def test__set_flow_tracking(self):
+        self.ixnet_gen._ixnet.getList.return_value = ['traffic_item']
+        self.ixnet_gen._set_flow_tracking(track_by=['vlanVlanId0'])
+        self.ixnet_gen.ixnet.setAttribute.assert_called_once_with(
+            'traffic_item/tracking', '-trackBy', ['vlanVlanId0'])
+        self.assertEqual(self.ixnet.commit.call_count, 1)
+
+    def test__set_egress_flow_tracking(self):
+        self.ixnet_gen._ixnet.getList.side_effect = [['traffic_item'],
+                                                     ['encapsulation']]
+        self.ixnet_gen._set_egress_flow_tracking(encapsulation='Ethernet',
+                                                 offset='IPv4 TOS Precedence')
+        self.ixnet_gen.ixnet.setAttribute.assert_any_call(
+            'traffic_item', '-egressEnabled', True)
+        self.ixnet_gen.ixnet.setAttribute.assert_any_call(
+            'encapsulation', '-encapsulation', 'Ethernet')
+        self.ixnet_gen.ixnet.setAttribute.assert_any_call(
+            'encapsulation', '-offset', 'IPv4 TOS Precedence')
+        self.assertEqual(self.ixnet.commit.call_count, 2)
+
     def test__update_ipv4_address(self):
         with mock.patch.object(self.ixnet_gen, '_get_field_in_stack_item',
                                return_value='field_desc'):
@@ -717,6 +737,24 @@ class TestIxNextgen(unittest.TestCase):
         self.ixnet.getList.assert_called_once()
         self.assertEqual(3, self.ixnet_gen._ixnet.execute.call_count)
 
+    def test__get_protocol_status(self):
+        self.ixnet.getAttribute.return_value = ['up']
+        self.ixnet_gen._get_protocol_status('ipv4')
+        self.ixnet.getAttribute.assert_called_once_with('ipv4',
+                                                        '-sessionStatus')
+
+    @mock.patch.object(ixnet_api.IxNextgen, '_get_protocol_status')
+    def test_is_protocols_running(self, mock_ixnextgen_get_protocol_status):
+        mock_ixnextgen_get_protocol_status.return_value = 'up'
+        result = self.ixnet_gen.is_protocols_running(['ethernet', 'ipv4'])
+        self.assertTrue(result)
+
+    @mock.patch.object(ixnet_api.IxNextgen, '_get_protocol_status')
+    def test_is_protocols_stopped(self, mock_ixnextgen_get_protocol_status):
+        mock_ixnextgen_get_protocol_status.return_value = 'down'
+        result = self.ixnet_gen.is_protocols_running(['ethernet', 'ipv4'])
+        self.assertFalse(result)
+
     def test_start_protocols(self):
         self.ixnet_gen.start_protocols()
         self.ixnet.execute.assert_called_once_with('startAllProtocols')