Skip to content

Commit f313124

Browse files
committed
Compare dict.
1 parent 0b829b8 commit f313124

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

src/sonic-config-engine/tests/test_multinpu_cfggen.py

+23-10
Original file line numberDiff line numberDiff line change
@@ -305,22 +305,35 @@ def test_device_asic_metadata(self):
305305
def test_global_asic_acl(self):
306306
argument = "-m {} -p {} --var-json \"ACL_TABLE\"".format(self.sample_graph, self.sample_port_config)
307307
output = json.loads(self.run_script(argument))
308-
self.assertDictEqual(output, {\
309-
u'EVERFLOW': {u'policy_desc': u'EVERFLOW', u'type': u'MIRROR', u'ports': [u'PortChannel0002', u'PortChannel0008', u'Ethernet8', u'Ethernet12', u'Ethernet24', u'Ethernet28'], u'stage': u'ingress'},
310-
u'SNMP_ACL': {u'services': [u'SNMP'], u'type': u'CTRLPLANE', u'policy_desc': u'SNMP_ACL', u'stage': u'ingress'},
311-
u'SSH_ONLY': {u'services': [u'SSH'], u'type': u'CTRLPLANE', u'policy_desc': u'SSH_ONLY', u'stage': u'ingress'},
312-
u'DATAACL': {u'policy_desc': u'DATAACL', u'type': u'L3', u'ports': [u'PortChannel0002', u'PortChannel0008'], u'stage': u'ingress'},
313-
u'EVERFLOWV6': {u'policy_desc': u'EVERFLOWV6', u'type': u'MIRRORV6', u'ports': [u'PortChannel0002', u'PortChannel0008', u'Ethernet8', u'Ethernet12', u'Ethernet24', u'Ethernet28'], u'stage': u'ingress'}})
308+
exp = {\
309+
'SNMP_ACL': {'policy_desc': 'SNMP_ACL', 'type': 'CTRLPLANE', 'stage': 'ingress', 'services': ['SNMP']},
310+
'EVERFLOW': {'policy_desc': 'EVERFLOW', 'stage': 'ingress', 'ports': ['PortChannel0002', 'PortChannel0008', 'Ethernet8', 'Ethernet12', 'Ethernet24', 'Ethernet28'], 'type': 'MIRROR'},
311+
'EVERFLOWV6': {'policy_desc': 'EVERFLOWV6', 'stage': 'ingress', 'ports': ['PortChannel0002', 'PortChannel0008', 'Ethernet8', 'Ethernet12', 'Ethernet24', 'Ethernet28'], 'type': 'MIRRORV6'},
312+
'SSH_ONLY': {'policy_desc': 'SSH_ONLY', 'type': 'CTRLPLANE', 'stage': 'ingress', 'services': ['SSH']},
313+
'DATAACL': {'policy_desc': 'DATAACL', 'stage': 'ingress', 'ports': ['PortChannel0002', 'PortChannel0008'], 'type': 'L3'}}
314+
for k, v in output.items():
315+
if 'ports' in v and len(v['ports']):
316+
v['ports'].sort()
317+
for k, v in exp.items():
318+
if 'ports' in v and len(v['ports']):
319+
v['ports'].sort()
320+
self.assertDictEqual(output, exp)
314321

315322
def test_global_asic_acl1(self):
316323
argument = "-m {} -p {} --var-json \"ACL_TABLE\"".format(self.sample_graph1, self.sample_port_config)
317324
self.maxDiff = None
318325
output = json.loads(self.run_script(argument))
319326
exp = {\
320-
u'EVERFLOW': {u'stage': u'ingress', u'type': u'MIRROR', u'policy_desc': u'EVERFLOW', u'ports': [u'Ethernet0', u'Ethernet4', u'Ethernet8', u'Ethernet12', u'Ethernet16', u'Ethernet20', u'Ethernet24', u'Ethernet28']},
321-
u'SNMP_ACL': {u'services': [u'SNMP'], u'stage': u'ingress', u'type': u'CTRLPLANE', u'policy_desc': u'SNMP_ACL'},
322-
u'SSH_ONLY': {u'services': [u'SSH'], u'stage': u'ingress', u'type': u'CTRLPLANE', u'policy_desc': u'SSH_ONLY'},
323-
u'EVERFLOWV6': {u'stage': u'ingress', u'type': u'MIRRORV6', u'policy_desc': u'EVERFLOWV6', u'ports': [u'Ethernet0', u'Ethernet4', u'Ethernet8', u'Ethernet12', u'Ethernet16', u'Ethernet20', u'Ethernet24', u'Ethernet28']}}
327+
'SNMP_ACL': {'policy_desc': 'SNMP_ACL', 'type': 'CTRLPLANE', 'stage': 'ingress', 'services': ['SNMP']},
328+
'EVERFLOW': {'policy_desc': 'EVERFLOW', 'stage': 'ingress', 'ports': ['Ethernet0', 'Ethernet4', 'Ethernet8', 'Ethernet12', 'Ethernet16', 'Ethernet20', 'Ethernet24', 'Ethernet28'], 'type': 'MIRROR'},
329+
'EVERFLOWV6': {'policy_desc': 'EVERFLOWV6', 'stage': 'ingress', 'ports': ['Ethernet0', 'Ethernet4', 'Ethernet8', 'Ethernet12', 'Ethernet16', 'Ethernet20', 'Ethernet24', 'Ethernet28'], 'type': 'MIRRORV6'},
330+
'SSH_ONLY': {'policy_desc': 'SSH_ONLY', 'type': 'CTRLPLANE', 'stage': 'ingress', 'services': ['SSH']}}
331+
for k, v in output.items():
332+
if 'ports' in v and len(v['ports']):
333+
v['ports'].sort()
334+
for k, v in exp.items():
335+
if 'ports' in v and len(v['ports']):
336+
v['ports'].sort()
324337
self.assertDictEqual(output, exp)
325338

326339
def test_front_end_asic_acl(self):

0 commit comments

Comments
 (0)