Skip to content

Commit a128b19

Browse files
committed
[tests] Fixed NetJSON label test #3
Closes #3
1 parent c22d913 commit a128b19

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

tests/static/netjson-2-links.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"local_addresses": [
1111
"192.168.1.3"
1212
],
13-
"label": "nodeA",
13+
"label": "nodeA",
1414
"properties": {
1515
"hostname": "router.3nnx"
1616
}
@@ -20,7 +20,7 @@
2020
"local_addresses": [
2121
"192.168.1.2"
2222
],
23-
"label": "nodeB",
23+
"label": "nodeB",
2424
"properties": {
2525
"hostname": "router2.nnx"
2626
}

tests/test_netjson.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,17 @@ def test_json_dict(self):
121121
self.assertIn('hostname', data['nodes'][0]['properties'])
122122
# ensure local_addresses is present
123123
self.assertIn('local_addresses', data['nodes'][0])
124-
# ensure label is present when present in source
125-
self.assertIn('label', data['nodes'][0])
126-
# ensure label is absent when absent in source
127-
self.assertNotIn('label', data['nodes'][2])
128124
# ensure additional link properties are present
129125
self.assertIn('properties', data['links'][0])
130126
self.assertIn('custom_property', data['links'][0]['properties'])
127+
# check presence of labels, we need to find 2
128+
labels = []
129+
for node in data['nodes']:
130+
if 'label' in node:
131+
labels.append(node['label'])
132+
self.assertEqual(len(labels), 2)
133+
self.assertIn('nodeA', labels)
134+
self.assertIn('nodeB', labels)
131135

132136
def test_json_string(self):
133137
p = NetJsonParser(links2)

0 commit comments

Comments
 (0)