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"
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"
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"
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", "resources_type": "local"}') 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", "resources_type": "local"} assert topology._project.filesDir() == str(tmpdir / "test") assert topology._project.name() == "test" assert topology._project.type() == "local"