def test_changing_path_temporary_flag(tmpdir):

    with patch("gns3server.modules.project.Project.is_local", return_value=True):
        p = Project(temporary=True)
        assert os.path.exists(p.path)
        original_path = p.path
        assert os.path.exists(os.path.join(p.path, ".gns3_temporary"))

        p.path = str(tmpdir)
Esempio n. 2
0
def test_changing_path_temporary_flag(tmpdir):

    with patch("gns3server.modules.project.Project.is_local",
               return_value=True):
        p = Project(temporary=True)
        assert os.path.exists(p.path)
        original_path = p.path
        assert os.path.exists(os.path.join(p.path, ".gns3_temporary"))

        p.path = str(tmpdir)
Esempio n. 3
0
def test_changing_path_temporary_flag(tmpdir):

    with patch("gns3server.modules.project.Project.is_local",
               return_value=True):
        p = Project(temporary=True)
        assert os.path.exists(p.path)
        assert os.path.exists(os.path.join(p.path, ".gns3_temporary"))
        p.temporary = False
        assert not os.path.exists(os.path.join(p.path, ".gns3_temporary"))

        with open(str(tmpdir / ".gns3_temporary"), "w+") as f:
            f.write("1")

        p.path = str(tmpdir)
        assert not os.path.exists(os.path.join(str(tmpdir), ".gns3_temporary"))
Esempio n. 4
0
def test_changing_path_with_quote_not_allowed(tmpdir):
    with patch("gns3server.modules.project.Project.is_local",
               return_value=True):
        with pytest.raises(aiohttp.web.HTTPForbidden):
            p = Project()
            p.path = str(tmpdir / "project\"53")
Esempio n. 5
0
def test_changing_path_not_allowed(tmpdir):
    with patch("gns3server.modules.project.Project.is_local", return_value=False):
        with pytest.raises(aiohttp.web.HTTPForbidden):
            p = Project()
            p.path = str(tmpdir)