本文整理汇总了Python中gns3.topology.Topology.loadFile方法的典型用法代码示例。如果您正苦于以下问题:Python Topology.loadFile方法的具体用法?Python Topology.loadFile怎么用?Python Topology.loadFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gns3.topology.Topology
的用法示例。
在下文中一共展示了Topology.loadFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_loadFile
# 需要导入模块: from gns3.topology import Topology [as 别名]
# 或者: from gns3.topology.Topology import loadFile [as 别名]
def test_loadFile(tmpdir):
topology = Topology()
topo = str(tmpdir / "test" / "test.gns3")
os.makedirs(str(tmpdir / "test"))
with open(topo, 'w+') as f:
f.write('{"name": "test", "type": "topology", "auto_start": false, "project_id": null, "topology": {}}')
with patch("gns3.topology.Topology._load") as mock:
project = Project()
topology.loadFile(topo, project)
assert mock.called
args, kwargs = mock.call_args
assert args[0] == {"name": "test", "auto_start": False, "project_id": None, "topology": {}, "type": "topology"}
assert topology._project.filesDir() == str(tmpdir / "test")
assert topology._project.name() == "test"
示例2: test_loadFile
# 需要导入模块: from gns3.topology import Topology [as 别名]
# 或者: from gns3.topology.Topology import loadFile [as 别名]
def test_loadFile(tmpdir):
topology = Topology()
topo = str(tmpdir / "test" / "test.gns3")
os.makedirs(str(tmpdir / "test"))
with open(topo, 'w+') as f:
f.write('{"name": "test"}')
with patch("gns3.topology.Topology._load") as mock:
project = Project()
topology.loadFile(topo, project)
assert mock.called
args, kwargs = mock.call_args
assert args[0] == {"name": "test"}
assert topology._project.filesDir() == str(tmpdir / "test")
assert topology._project.name() == "test"