Fix order of arguments in assertEqual

Some tests used incorrect order assertEqual(observed, expected).
The correct order expected by testtools
is assertEqual(expected, observed).

Closes bug: #1259292

Change-Id: If670c54ee7f6dae2911c1165619dcad4dca6c06d
changes/25/361025/3
SongmingYan 6 years ago committed by Songming Yan
parent bed0bba8b4
commit f7d95a4045
  1. 6
      networking_sfc/tests/unit/services/flowclassifier/test_plugin.py
  2. 206
      networking_sfc/tests/unit/services/sfc/agent/test_agent.py
  3. 22
      networking_sfc/tests/unit/services/sfc/common/test_ovs_ext_lib.py
  4. 18
      networking_sfc/tests/unit/services/sfc/test_plugin.py

@ -179,7 +179,7 @@ class FlowClassifierPluginTestCase(
updated_flow_classifier = copy.copy(original_flow_classifier)
updated_flow_classifier['name'] = 'test2'
res = req.get_response(self.ext_api)
self.assertEqual(res.status_int, 500)
self.assertEqual(500, res.status_int)
driver_manager = self.fake_driver_manager
driver_manager.update_flow_classifier.assert_called_once_with(
mock.ANY
@ -203,7 +203,7 @@ class FlowClassifierPluginTestCase(
'flow_classifiers', fc['flow_classifier']['id']
)
res = req.get_response(self.ext_api)
self.assertEqual(res.status_int, 204)
self.assertEqual(204, res.status_int)
driver_manager = self.fake_driver_manager
driver_manager.delete_flow_classifier.assert_called_once_with(
mock.ANY
@ -232,7 +232,7 @@ class FlowClassifierPluginTestCase(
'flow_classifiers', fc['flow_classifier']['id']
)
res = req.get_response(self.ext_api)
self.assertEqual(res.status_int, 500)
self.assertEqual(500, res.status_int)
driver_manager = self.fake_driver_manager
driver_manager.delete_flow_classifier.assert_called_once_with(
mock.ANY

@ -447,14 +447,16 @@ class OVSSfcAgentTestCase(ovs_test_base.OVSOFCtlTestBase):
}
)
self.assertEqual(
self.executed_cmds, [
]
[],
self.executed_cmds
)
self.assertEqual(
self.added_flows, self.default_flow_rules + []
self.default_flow_rules + [],
self.added_flows
)
self.assertEqual(
self.group_mapping, {}
{},
self.group_mapping
)
def test_update_flow_rules_sf_node_empty_next_hops(self):
@ -486,11 +488,11 @@ class OVSSfcAgentTestCase(ovs_test_base.OVSOFCtlTestBase):
}
)
self.assertEqual(
self.executed_cmds, [
]
[],
self.executed_cmds
)
self.assertEqual(
self.added_flows, self.default_flow_rules + [{
self.default_flow_rules + [{
'actions': 'strip_vlan, pop_mpls:0x0800,output:6',
'dl_dst': '00:01:02:03:05:07',
'dl_type': 34887,
@ -498,10 +500,12 @@ class OVSSfcAgentTestCase(ovs_test_base.OVSOFCtlTestBase):
'mpls_label': 65791,
'priority': 1,
'table': 10
}]
}],
self.added_flows
)
self.assertEqual(
self.group_mapping, {}
{},
self.group_mapping
)
def test_update_flow_rules_src_node_empty_next_hops(self):
@ -528,14 +532,16 @@ class OVSSfcAgentTestCase(ovs_test_base.OVSOFCtlTestBase):
}
)
self.assertEqual(
self.executed_cmds, [
]
[],
self.executed_cmds
)
self.assertEqual(
self.added_flows, self.default_flow_rules + []
self.default_flow_rules + [],
self.added_flows
)
self.assertEqual(
self.group_mapping, {}
{},
self.group_mapping
)
def test_update_flow_rules_src_node_empty_next_hops_add_fcs_del_fcs(self):
@ -583,11 +589,11 @@ class OVSSfcAgentTestCase(ovs_test_base.OVSOFCtlTestBase):
}
)
self.assertEqual(
self.executed_cmds, [
]
[],
self.executed_cmds
)
self.assertEqual(
self.added_flows, self.default_flow_rules + [{
self.default_flow_rules + [{
'actions': 'normal',
'dl_type': 2048,
'in_port': 42,
@ -598,10 +604,11 @@ class OVSSfcAgentTestCase(ovs_test_base.OVSOFCtlTestBase):
'table': 0,
'tp_dst': '0x64/0xffff',
'tp_src': '0x64/0xffff'
}]
}],
self.added_flows
)
self.assertEqual(
self.deleted_flows, self.default_delete_flow_rules + [{
self.default_delete_flow_rules + [{
'dl_type': 2048,
'in_port': 42,
'nw_dst': u'10.200.0.0/16',
@ -610,10 +617,12 @@ class OVSSfcAgentTestCase(ovs_test_base.OVSOFCtlTestBase):
'table': 0,
'tp_dst': '0x64/0xffff',
'tp_src': '0x64/0xffff'
}]
}],
self.deleted_flows
)
self.assertEqual(
self.group_mapping, {}
{},
self.group_mapping
)
def test_update_flow_rules_sf_node_empty_next_hops_add_fcs_del_fcs(self):
@ -666,11 +675,11 @@ class OVSSfcAgentTestCase(ovs_test_base.OVSOFCtlTestBase):
}
)
self.assertEqual(
self.executed_cmds, [
]
[],
self.executed_cmds
)
self.assertEqual(
self.added_flows, self.default_flow_rules + [{
self.default_flow_rules + [{
'actions': 'normal',
'dl_type': 2048,
'in_port': 42,
@ -689,10 +698,11 @@ class OVSSfcAgentTestCase(ovs_test_base.OVSOFCtlTestBase):
'mpls_label': 65792,
'priority': 1,
'table': 10
}]
}],
self.added_flows
)
self.assertEqual(
self.deleted_flows, self.default_delete_flow_rules + [{
self.default_delete_flow_rules + [{
'dl_type': 2048,
'in_port': 42,
'nw_dst': u'10.200.0.0/16',
@ -701,10 +711,12 @@ class OVSSfcAgentTestCase(ovs_test_base.OVSOFCtlTestBase):
'table': 0,
'tp_dst': '0x64/0xffff',
'tp_src': '0x64/0xffff'
}]
}],
self.deleted_flows
)
self.assertEqual(
self.group_mapping, {}
{},
self.group_mapping
)
def test_update_flow_rules_src_node_next_hops_add_fcs(self):
@ -756,11 +768,11 @@ class OVSSfcAgentTestCase(ovs_test_base.OVSOFCtlTestBase):
}
)
self.assertEqual(
self.executed_cmds, [
]
[],
self.executed_cmds
)
self.assertEqual(
self.added_flows, self.default_flow_rules + [{
self.default_flow_rules + [{
'actions': (
'push_mpls:0x8847,set_mpls_label:65791,set_mpls_ttl:255,'
'mod_vlan_vid:0,,output:2'),
@ -779,10 +791,11 @@ class OVSSfcAgentTestCase(ovs_test_base.OVSOFCtlTestBase):
'table': 0,
'tp_dst': '0x64/0xffff',
'tp_src': '0x64/0xffff'
}]
}],
self.added_flows
)
self.assertEqual(
self.group_mapping, {
{
1: {
'buckets': (
'bucket=weight=1, '
@ -792,7 +805,8 @@ class OVSSfcAgentTestCase(ovs_test_base.OVSOFCtlTestBase):
'group_id': 1,
'type': 'select'
}
}
},
self.group_mapping
)
def test_update_flow_rules_src_node_next_hops_same_host_add_fcs(self):
@ -844,11 +858,11 @@ class OVSSfcAgentTestCase(ovs_test_base.OVSOFCtlTestBase):
}
)
self.assertEqual(
self.executed_cmds, [
]
[],
self.executed_cmds
)
self.assertEqual(
self.added_flows, self.default_flow_rules + [{
self.default_flow_rules + [{
'actions': (
'push_mpls:0x8847,set_mpls_label:65791,set_mpls_ttl:255,'
'mod_vlan_vid:0,,resubmit(,10)'),
@ -867,10 +881,11 @@ class OVSSfcAgentTestCase(ovs_test_base.OVSOFCtlTestBase):
'table': 0,
'tp_dst': '0x64/0xffff',
'tp_src': '0x64/0xffff'
}]
}],
self.added_flows
)
self.assertEqual(
self.group_mapping, {
{
1: {
'buckets': (
'bucket=weight=1, '
@ -880,7 +895,8 @@ class OVSSfcAgentTestCase(ovs_test_base.OVSOFCtlTestBase):
'group_id': 1,
'type': 'select'
}
}
},
self.group_mapping
)
def test_update_flow_rules_sf_node_next_hops_add_fcs(self):
@ -938,11 +954,11 @@ class OVSSfcAgentTestCase(ovs_test_base.OVSOFCtlTestBase):
}
)
self.assertEqual(
self.executed_cmds, [
]
[],
self.executed_cmds
)
self.assertEqual(
self.added_flows, self.default_flow_rules + [{
self.default_flow_rules + [{
'actions': (
'push_mpls:0x8847,set_mpls_label:65791,set_mpls_ttl:255,'
'mod_vlan_vid:0,,output:2'),
@ -969,10 +985,11 @@ class OVSSfcAgentTestCase(ovs_test_base.OVSOFCtlTestBase):
'mpls_label': 65792,
'priority': 1,
'table': 10
}]
}],
self.added_flows
)
self.assertEqual(
self.group_mapping, {
{
1: {
'buckets': (
'bucket=weight=1, '
@ -982,7 +999,8 @@ class OVSSfcAgentTestCase(ovs_test_base.OVSOFCtlTestBase):
'group_id': 1,
'type': 'select'
}
}
},
self.group_mapping
)
def test_update_flow_rules_sf_node_next_hops_same_host_add_fcs(self):
@ -1040,11 +1058,11 @@ class OVSSfcAgentTestCase(ovs_test_base.OVSOFCtlTestBase):
}
)
self.assertEqual(
self.executed_cmds, [
]
[],
self.executed_cmds
)
self.assertEqual(
self.added_flows, self.default_flow_rules + [{
self.default_flow_rules + [{
'actions': (
'push_mpls:0x8847,set_mpls_label:65791,set_mpls_ttl:255,'
'mod_vlan_vid:0,,resubmit(,10)'),
@ -1071,10 +1089,11 @@ class OVSSfcAgentTestCase(ovs_test_base.OVSOFCtlTestBase):
'mpls_label': 65792,
'priority': 1,
'table': 10
}]
}],
self.added_flows
)
self.assertEqual(
self.group_mapping, {
{
1: {
'buckets': (
'bucket=weight=1, '
@ -1084,7 +1103,8 @@ class OVSSfcAgentTestCase(ovs_test_base.OVSOFCtlTestBase):
'group_id': 1,
'type': 'select'
}
}
},
self.group_mapping
)
def test_delete_flow_rules_sf_node_empty_del_fcs(self):
@ -1116,21 +1136,23 @@ class OVSSfcAgentTestCase(ovs_test_base.OVSOFCtlTestBase):
}
)
self.assertEqual(
self.executed_cmds, [
]
[],
self.executed_cmds
)
self.assertEqual(
self.deleted_flows, self.default_delete_flow_rules + [{
self.default_delete_flow_rules + [{
'dl_dst': '00:01:02:03:05:07',
'dl_type': 34887,
'mpls_label': 65791,
'table': 10
}]
}],
self.deleted_flows
)
self.assertEqual(
self.deleted_groups, [
[
"all"
]
],
self.deleted_groups
)
def test_delete_flow_rules_src_node_empty_del_fcs(self):
@ -1162,16 +1184,18 @@ class OVSSfcAgentTestCase(ovs_test_base.OVSOFCtlTestBase):
}
)
self.assertEqual(
self.executed_cmds, [
]
[],
self.executed_cmds
)
self.assertEqual(
self.deleted_flows, self.default_delete_flow_rules + []
self.default_delete_flow_rules + [],
self.deleted_flows
)
self.assertEqual(
self.deleted_groups, [
[
"all"
]
],
self.deleted_groups
)
def test_delete_flow_rules_sf_node_del_fcs(self):
@ -1213,11 +1237,11 @@ class OVSSfcAgentTestCase(ovs_test_base.OVSOFCtlTestBase):
}
)
self.assertEqual(
self.executed_cmds, [
]
[],
self.executed_cmds
)
self.assertEqual(
self.deleted_flows, self.default_delete_flow_rules + [{
self.default_delete_flow_rules + [{
'dl_type': 2048,
'in_port': 42,
'nw_dst': u'10.200.0.0/16',
@ -1231,12 +1255,14 @@ class OVSSfcAgentTestCase(ovs_test_base.OVSOFCtlTestBase):
'dl_type': 34887,
'mpls_label': 65791,
'table': 10
}]
}],
self.deleted_flows
)
self.assertEqual(
self.deleted_groups, [
[
"all"
]
],
self.deleted_groups
)
def test_delete_flow_rules_src_node_del_fcs(self):
@ -1278,11 +1304,11 @@ class OVSSfcAgentTestCase(ovs_test_base.OVSOFCtlTestBase):
}
)
self.assertEqual(
self.executed_cmds, [
]
[],
self.executed_cmds
)
self.assertEqual(
self.deleted_flows, self.default_delete_flow_rules + [{
self.default_delete_flow_rules + [{
'dl_type': 2048,
'in_port': 42,
'nw_dst': u'10.200.0.0/16',
@ -1291,12 +1317,14 @@ class OVSSfcAgentTestCase(ovs_test_base.OVSOFCtlTestBase):
'table': 0,
'tp_dst': '0x64/0xffff',
'tp_src': '0x64/0xffff'
}]
}],
self.deleted_flows
)
self.assertEqual(
self.deleted_groups, [
[
"all"
]
],
self.deleted_groups
)
def test_delete_flow_rules_src_node_next_hops_del_fcs(self):
@ -1348,11 +1376,11 @@ class OVSSfcAgentTestCase(ovs_test_base.OVSOFCtlTestBase):
}
)
self.assertEqual(
self.executed_cmds, [
]
[],
self.executed_cmds
)
self.assertEqual(
self.deleted_flows, self.default_delete_flow_rules + [{
self.default_delete_flow_rules + [{
'dl_type': 2048,
'in_port': 42,
'nw_dst': u'10.200.0.0/16',
@ -1364,10 +1392,12 @@ class OVSSfcAgentTestCase(ovs_test_base.OVSOFCtlTestBase):
}, {
'dl_dst': '12:34:56:78:cf:23',
'table': 5
}]
}],
self.deleted_flows
)
self.assertEqual(
self.deleted_groups, ['all', 1]
['all', 1],
self.deleted_groups
)
def test_delete_flow_rules_sf_node_next_hops_del_fcs(self):
@ -1419,11 +1449,11 @@ class OVSSfcAgentTestCase(ovs_test_base.OVSOFCtlTestBase):
}
)
self.assertEqual(
self.executed_cmds, [
]
[],
self.executed_cmds
)
self.assertEqual(
self.deleted_flows, self.default_delete_flow_rules + [{
self.default_delete_flow_rules + [{
'dl_type': 2048,
'in_port': 42,
'nw_dst': u'10.200.0.0/16',
@ -1440,17 +1470,18 @@ class OVSSfcAgentTestCase(ovs_test_base.OVSOFCtlTestBase):
'dl_type': 34887,
'mpls_label': 65792,
'table': 10
}]
}],
self.deleted_flows
)
self.assertEqual(
self.deleted_groups, ['all', 1]
['all', 1],
self.deleted_groups
)
def test_init_agent_empty_flowrules(self):
self.node_flowrules = []
self.init_agent()
self.assertEqual(
self.added_flows,
[{
'actions': 'resubmit(,10)',
'dl_type': 34887,
@ -1460,6 +1491,7 @@ class OVSSfcAgentTestCase(ovs_test_base.OVSOFCtlTestBase):
'actions': 'drop',
'priority': 0,
'table': 10
}]
}],
self.added_flows
)
self.assertEqual(self.group_mapping, {})
self.assertEqual({}, self.group_mapping)

@ -28,7 +28,7 @@ class GetPortMaskTestCase(base.BaseTestCase):
def test_single_port(self):
masks = ovs_ext_lib.get_port_mask(100, 100)
self.assertEqual(masks, ['0x64/0xffff'])
self.assertEqual(['0x64/0xffff'], masks)
def test_invalid_min_port(self):
self.assertRaises(
@ -53,23 +53,23 @@ class GetPortMaskTestCase(base.BaseTestCase):
def test_one_port_mask(self):
masks = ovs_ext_lib.get_port_mask(100, 101)
self.assertEqual(masks, ['0x64/0xfffe'])
self.assertEqual(['0x64/0xfffe'], masks)
masks = ovs_ext_lib.get_port_mask(100, 103)
self.assertEqual(masks, ['0x64/0xfffc'])
self.assertEqual(['0x64/0xfffc'], masks)
masks = ovs_ext_lib.get_port_mask(32768, 65535)
self.assertEqual(masks, ['0x8000/0x8000'])
self.assertEqual(['0x8000/0x8000'], masks)
def test_multi_port_masks(self):
masks = ovs_ext_lib.get_port_mask(101, 102)
self.assertEqual(masks, ['0x65/0xffff', '0x66/0xffff'])
self.assertEqual(['0x65/0xffff', '0x66/0xffff'], masks)
masks = ovs_ext_lib.get_port_mask(101, 104)
self.assertEqual(
masks,
['0x65/0xffff', '0x66/0xfffe', '0x68/0xffff']
['0x65/0xffff', '0x66/0xfffe', '0x68/0xffff'],
masks
)
masks = ovs_ext_lib.get_port_mask(1, 65535)
self.assertEqual(
masks, [
[
'0x1/0xffff',
'0x2/0xfffe',
'0x4/0xfffc',
@ -86,9 +86,11 @@ class GetPortMaskTestCase(base.BaseTestCase):
'0x2000/0xe000',
'0x4000/0xc000',
'0x8000/0x8000'
]
],
masks
)
masks = ovs_ext_lib.get_port_mask(32767, 65535)
self.assertEqual(
masks, ['0x7fff/0xffff', '0x8000/0x8000']
['0x7fff/0xffff', '0x8000/0x8000'],
masks
)

@ -127,7 +127,7 @@ class SfcPluginTestCase(test_sfc_db.SfcDbPluginTestCase):
updated_port_chain = copy.copy(original_port_chain)
updated_port_chain['name'] = 'test2'
res = req.get_response(self.ext_api)
self.assertEqual(res.status_int, 500)
self.assertEqual(500, res.status_int)
res = self._list('port_chains')
self.assertIn('port_chains', res)
self.assertItemsEqual(
@ -145,7 +145,7 @@ class SfcPluginTestCase(test_sfc_db.SfcDbPluginTestCase):
'port_chains', pc['port_chain']['id']
)
res = req.get_response(self.ext_api)
self.assertEqual(res.status_int, 204)
self.assertEqual(204, res.status_int)
driver_manager = self.fake_driver_manager
driver_manager.delete_port_chain.assert_called_once_with(
mock.ANY
@ -172,7 +172,7 @@ class SfcPluginTestCase(test_sfc_db.SfcDbPluginTestCase):
'port_chains', pc['port_chain']['id']
)
res = req.get_response(self.ext_api)
self.assertEqual(res.status_int, 500)
self.assertEqual(500, res.status_int)
self._test_list_resources('port_chain', [pc])
def test_create_port_pair_group_driver_manager_called(self):
@ -249,7 +249,7 @@ class SfcPluginTestCase(test_sfc_db.SfcDbPluginTestCase):
updated_port_pair_group = copy.copy(original_port_pair_group)
updated_port_pair_group['name'] = 'test2'
res = req.get_response(self.ext_api)
self.assertEqual(res.status_int, 500)
self.assertEqual(500, res.status_int)
res = self._list('port_pair_groups')
self.assertIn('port_pair_groups', res)
self.assertItemsEqual(
@ -265,7 +265,7 @@ class SfcPluginTestCase(test_sfc_db.SfcDbPluginTestCase):
'port_pair_groups', pc['port_pair_group']['id']
)
res = req.get_response(self.ext_api)
self.assertEqual(res.status_int, 204)
self.assertEqual(204, res.status_int)
driver_manager = self.fake_driver_manager
driver_manager.delete_port_pair_group.assert_called_once_with(
mock.ANY
@ -290,7 +290,7 @@ class SfcPluginTestCase(test_sfc_db.SfcDbPluginTestCase):
'port_pair_groups', pc['port_pair_group']['id']
)
res = req.get_response(self.ext_api)
self.assertEqual(res.status_int, 500)
self.assertEqual(500, res.status_int)
self._test_list_resources('port_pair_group', [pc])
def test_create_port_pair_driver_manager_called(self):
@ -407,7 +407,7 @@ class SfcPluginTestCase(test_sfc_db.SfcDbPluginTestCase):
updated_port_pair = copy.copy(original_port_pair)
updated_port_pair['name'] = 'test2'
res = req.get_response(self.ext_api)
self.assertEqual(res.status_int, 500)
self.assertEqual(500, res.status_int)
res = self._list('port_pairs')
self.assertIn('port_pairs', res)
self.assertItemsEqual(res['port_pairs'], [updated_port_pair])
@ -431,7 +431,7 @@ class SfcPluginTestCase(test_sfc_db.SfcDbPluginTestCase):
'port_pairs', pc['port_pair']['id']
)
res = req.get_response(self.ext_api)
self.assertEqual(res.status_int, 204)
self.assertEqual(204, res.status_int)
fake_driver_manager = self.fake_driver_manager
fake_driver_manager.delete_port_pair.assert_called_once_with(
mock.ANY
@ -464,5 +464,5 @@ class SfcPluginTestCase(test_sfc_db.SfcDbPluginTestCase):
'port_pairs', pc['port_pair']['id']
)
res = req.get_response(self.ext_api)
self.assertEqual(res.status_int, 500)
self.assertEqual(500, res.status_int)
self._test_list_resources('port_pair', [pc])

Loading…
Cancel
Save