当前位置: 首页>>代码示例>>Python>>正文


Python netdiff.diff函数代码示例

本文整理汇总了Python中netdiff.diff函数的典型用法代码示例。如果您正苦于以下问题:Python diff函数的具体用法?Python diff怎么用?Python diff使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了diff函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_no_changes

 def test_no_changes(self):
     old = NetJsonParser(links2)
     new = NetJsonParser(links2)
     result = diff(old, new)
     self.assertIsInstance(result, dict)
     self.assertIsNone(result['added'])
     self.assertIsNone(result['removed'])
开发者ID:gabri94,项目名称:netdiff,代码行数:7,代码来源:test_netjson.py

示例2: test_no_changes

 def test_no_changes(self):
     old = CnmlParser(cnml1)
     new = CnmlParser(cnml1)
     result = diff(old, new)
     self.assertIsInstance(result, dict)
     self.assertIsNone(result['added'])
     self.assertIsNone(result['removed'])
开发者ID:leonardomaccari,项目名称:netdiff,代码行数:7,代码来源:test_cnml.py

示例3: test_simple_diff

 def test_simple_diff(self):
     old = OlsrParser(links3)
     new = OlsrParser(links5)
     result = diff(old, new)
     self.assertIsNone(result['changed'])
     # ensure there are differences
     self.assertEqual(len(result['added']['links']), 3)
     self.assertEqual(len(result['removed']['links']), 1)
     self.assertEqual(len(result['added']['nodes']), 2)
     self.assertEqual(len(result['removed']['nodes']), 1)
     # ensure 3 links added
     self._test_expected_links(
         graph=result['added'],
         expected_links=[
             ('10.150.0.3', '10.150.0.7'),
             ('10.150.0.3', '10.150.0.6'),
             ('10.150.0.7', '10.150.0.6'),
         ]
     )
     self._test_expected_links(
         graph=result['removed'],
         expected_links=[('10.150.0.5', '10.150.0.4')]
     )
     added_nodes = [node['id'] for node in result['added']['nodes']]
     self.assertIn('10.150.0.6', added_nodes)
     self.assertIn('10.150.0.7', added_nodes)
     self.assertIn('10.150.0.5', result['removed']['nodes'][0].values())
开发者ID:gabri94,项目名称:netdiff,代码行数:27,代码来源:test_olsr_txtinfo.py

示例4: test_no_changes

 def test_no_changes(self):
     old = BatmanParser(iulinet)
     new = BatmanParser(iulinet)
     result = diff(old, new)
     self.assertIsInstance(result, dict)
     self.assertIsNone(result['added'])
     self.assertIsNone(result['removed'])
开发者ID:cl4u2,项目名称:netdiff,代码行数:7,代码来源:test_batman.py

示例5: test_no_changes

 def test_no_changes(self):
     old = Bmx6Parser(topo)
     new = Bmx6Parser(topo)
     result = diff(old, new)
     self.assertIsInstance(result, dict)
     self.assertIsNone(result['added'])
     self.assertIsNone(result['removed'])
开发者ID:ninuxorg,项目名称:netdiff,代码行数:7,代码来源:test_bmx6.py

示例6: test_added_1_link

 def test_added_1_link(self):
     old = CnmlParser(cnml1)
     new = CnmlParser(cnml2)
     result = diff(old, new)
     self.assertIsNone(result['removed'])
     # ensure there are differences
     self.assertEqual(len(result['added']['links']), 1)
     # ensure 1 link added
     self.assertIn('10.228.172.97', result['added']['links'][0].values())
     self.assertIn('10.228.172.101', result['added']['links'][0].values())
开发者ID:leonardomaccari,项目名称:netdiff,代码行数:10,代码来源:test_cnml.py

示例7: diff

 def diff(self, data=None):
     """ shortcut to netdiff.diff """
     # if we get an instance of ``self.parser_class`` it means
     # ``self.get_topology_data`` has already been executed by ``receive``
     if isinstance(data, self.parser_class):
         latest = data
     else:
         latest = self.get_topology_data(data)
     current = NetJsonParser(self.json(dict=True, omit_down=True))
     return diff(current, latest)
开发者ID:interop-dev,项目名称:django-netjsongraph,代码行数:10,代码来源:topology.py

示例8: test_no_changes

 def test_no_changes(self):
     old = OlsrParser(links2)
     new = OlsrParser(links2)
     result = diff(old, new)
     self.assertTrue(type(result) is dict)
     self.assertTrue(type(result['added']) is list)
     self.assertTrue(type(result['removed']) is list)
     # ensure there are no differences
     self.assertEqual(len(result['added']), 0)
     self.assertEqual(len(result['removed']), 0)
开发者ID:PabloCastellano,项目名称:netdiff,代码行数:10,代码来源:tests.py

示例9: test_added_1_link

 def test_added_1_link(self):
     old = OlsrParser(links2)
     new = OlsrParser(links3)
     result = diff(old, new)
     # ensure there are differences
     self.assertEqual(len(result['added']), 1)
     self.assertEqual(len(result['removed']), 0)
     # ensure 1 link added
     self.assertIn('10.150.0.5', result['added'][0])
     self.assertIn('10.150.0.4', result['added'][0])
开发者ID:PabloCastellano,项目名称:netdiff,代码行数:10,代码来源:tests.py

示例10: test_removed_1_link

 def test_removed_1_link(self):
     old = CnmlParser(cnml2)
     new = CnmlParser(cnml1)
     result = diff(old, new)
     self.assertIsInstance(result, dict)
     self.assertIsNone(result['added'])
     self.assertTrue(type(result['removed']['links']) is list)
     # ensure there are differences
     self.assertEqual(len(result['removed']['links']), 1)
     # ensure 1 link removed
     self.assertIn('10.228.172.97', result['removed']['links'][0].values())
     self.assertIn('10.228.172.101', result['removed']['links'][0].values())
开发者ID:leonardomaccari,项目名称:netdiff,代码行数:12,代码来源:test_cnml.py

示例11: test_added_1_link

 def test_added_1_link(self):
     old = NetJsonParser(links2)
     new = NetJsonParser(links3)
     result = diff(old, new)
     self.assertIsNone(result['removed'])
     # ensure there are no differences
     self.assertEqual(len(result['added']['links']), 1)
     self.assertEqual(len(result['added']['nodes']), 1)
     # ensure correct link added
     self.assertIn('10.150.0.5', result['added']['links'][0].values())
     self.assertIn('10.150.0.4', result['added']['links'][0].values())
     # ensure correct node added
     self.assertIn('10.150.0.5', result['added']['nodes'][0].values())
开发者ID:leonardomaccari,项目名称:netdiff,代码行数:13,代码来源:test_netjson.py

示例12: test_removed_1_link

 def test_removed_1_link(self):
     old = OlsrParser(links3)
     new = OlsrParser(links2)
     result = diff(old, new)
     self.assertTrue(type(result) is dict)
     self.assertTrue(type(result['added']) is list)
     self.assertTrue(type(result['removed']) is list)
     # ensure there are differences
     self.assertEqual(len(result['added']), 0)
     self.assertEqual(len(result['removed']), 1)
     # ensure 1 link removed
     self.assertIn('10.150.0.5', result['removed'][0])
     self.assertIn('10.150.0.4', result['removed'][0])
开发者ID:PabloCastellano,项目名称:netdiff,代码行数:13,代码来源:tests.py

示例13: test_cost_changes_1

 def test_cost_changes_1(self):
     old = OlsrParser(links2)
     new = OlsrParser(links2_cost)
     result = diff(old, new)
     self.assertIsNone(result['added'])
     self.assertIsNone(result['removed'])
     self.assertIsInstance(result['changed'], dict)
     self.assertEqual(len(result['changed']['nodes']), 0)
     links = result['changed']['links']
     self.assertTrue(type(links) is list)
     self.assertEqual(len(links), 2)
     # ensure results are correct
     self.assertTrue(1.302 in (links[0]['cost'], links[1]['cost']))
     self.assertTrue(1.023 in (links[0]['cost'], links[1]['cost']))
开发者ID:gabri94,项目名称:netdiff,代码行数:14,代码来源:test_olsr_txtinfo.py

示例14: test_label_diff_added

 def test_label_diff_added(self):
     old = OpenvpnParser({})
     new = OpenvpnParser(links5_tap)
     result = diff(old, new)
     labels = []
     for node in result['added']['nodes']:
         if 'label' in node:
             labels.append(node['label'])
     self.assertEqual(len(labels), 5)
     self.assertIn('nodeA', labels)
     self.assertIn('nodeB', labels)
     self.assertIn('nodeC', labels)
     self.assertIn('nodeD', labels)
     self.assertIn('nodeE', labels)
开发者ID:ninuxorg,项目名称:netdiff,代码行数:14,代码来源:test_openvpn.py

示例15: test_cost_changes_2

 def test_cost_changes_2(self):
     old = OlsrParser(links5)
     new = OlsrParser(links5_cost)
     result = diff(old, new)
     self.assertIsNone(result['added'])
     self.assertIsNone(result['removed'])
     self.assertIsInstance(result['changed'], dict)
     self.assertEqual(len(result['changed']['nodes']), 0)
     links = result['changed']['links']
     self.assertEqual(len(links), 4)
     weights = [link['weight'] for link in links]
     self.assertIn(1.0, weights)
     self.assertIn(2.0, weights)
     self.assertIn(1.50390625, weights)
     self.assertIn(3.515625, weights)
开发者ID:cl4u2,项目名称:netdiff,代码行数:15,代码来源:test_olsr.py


注:本文中的netdiff.diff函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。