Skip to content

Commit

Permalink
[pylibs] unit test YAML save/load extended with node position checks.
Browse files Browse the repository at this point in the history
  • Loading branch information
EskoDijk committed Sep 25, 2024
1 parent 32e3d0f commit f1bc1b8
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions pylibs/unittests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -777,12 +777,12 @@ def testLoadYamlTopology(self):
def testSaveYamlTopology(self):
ns: OTNS = self.ns
self.assertEqual(0, len(ns.nodes()))
ns.add('router')
ns.add('router', x=100, y=100)
ns.go(10)
ns.add('router')
ns.add('router', version='')
ns.add('router')
ns.add('ssed')
ns.add('router', x=200, y=100)
ns.add('router', version='', x=300, y=100)
ns.add('router', x=400, y=100)
ns.add('med', x=400, y=160)
ns.go(25)
self.assertEqual(5, len(ns.nodes()))
self.assertFormPartitions(1)
Expand All @@ -795,8 +795,18 @@ def testSaveYamlTopology(self):

ns.load('tmp/unittest_save_topology.yaml')
self.assertEqual(5, len(ns.nodes()))
nodes_info = ns.nodes()
for n in range(1, 5):
self.assertEqual(n * 100, nodes_info[n]['x'])
self.assertEqual(100, nodes_info[n]['y'])
self.assertEqual(0, nodes_info[n]['z'])
self.assertEqual('router', nodes_info[n]['type'])
self.assertEqual(160, nodes_info[5]['y'])
self.assertEqual('med', nodes_info[5]['type'])
self.assertFormPartitionsIgnoreOrphans(0)
ns.go(125)
self.assertFormPartitions(1)
self.assertFormPartitionsIgnoreOrphans(1)

def testRealtimeMode(self):
self.tearDown()
Expand Down

0 comments on commit f1bc1b8

Please sign in to comment.