Ejemplo n.º 1
0
def test_vm_working_directory(tmpdir, vm):
    with patch("gns3server.modules.project.Project.is_local",
               return_value=True):
        p = Project(location=str(tmpdir))
        assert p.vm_working_directory(vm) == os.path.join(
            str(tmpdir), p.id, 'project-files', vm.module_name, vm.id)
        assert os.path.exists(p.vm_working_directory(vm))
Ejemplo n.º 2
0
def test_commit_permission_issue(manager, loop):
    project = Project()
    vm = VPCSVM("test", "00010203-0405-0607-0809-0a0b0c0d0e0f", project, manager)
    project.add_vm(vm)
    directory = project.vm_working_directory(vm)
    project.mark_vm_for_destruction(vm)
    assert len(project._vms_to_destroy) == 1
    assert os.path.exists(directory)
    os.chmod(directory, 0)
    with pytest.raises(aiohttp.web.HTTPInternalServerError):
        loop.run_until_complete(asyncio.async(project.commit()))
    os.chmod(directory, 700)
Ejemplo n.º 3
0
def test_commit(manager, loop):
    project = Project()
    vm = VPCSVM("test", "00010203-0405-0607-0809-0a0b0c0d0e0f", project, manager)
    project.add_vm(vm)
    directory = project.vm_working_directory(vm)
    project.mark_vm_for_destruction(vm)
    assert len(project._vms_to_destroy) == 1
    assert os.path.exists(directory)
    loop.run_until_complete(asyncio.async(project.commit()))
    assert len(project._vms_to_destroy) == 0
    assert os.path.exists(directory) is False
    assert len(project.vms) == 0
Ejemplo n.º 4
0
def test_commit(manager, loop):
    project = Project()
    vm = VPCSVM("test", "00010203-0405-0607-0809-0a0b0c0d0e0f", project,
                manager)
    project.add_vm(vm)
    directory = project.vm_working_directory(vm)
    project.mark_vm_for_destruction(vm)
    assert len(project._vms_to_destroy) == 1
    assert os.path.exists(directory)
    loop.run_until_complete(asyncio. async (project.commit()))
    assert len(project._vms_to_destroy) == 0
    assert os.path.exists(directory) is False
    assert len(project.vms) == 0
Ejemplo n.º 5
0
def test_commit_permission_issue(manager, loop):
    project = Project()
    vm = VPCSVM("test", "00010203-0405-0607-0809-0a0b0c0d0e0f", project,
                manager)
    project.add_vm(vm)
    directory = project.vm_working_directory(vm)
    project.mark_vm_for_destruction(vm)
    assert len(project._vms_to_destroy) == 1
    assert os.path.exists(directory)
    os.chmod(directory, 0)
    with pytest.raises(aiohttp.web.HTTPInternalServerError):
        loop.run_until_complete(asyncio. async (project.commit()))
    os.chmod(directory, 700)
Ejemplo n.º 6
0
def test_commit_permission_issue(manager, loop):
    """
    GNS3 will fix the permission and continue to delete
    """
    project = Project()
    vm = VPCSVM("test", "00010203-0405-0607-0809-0a0b0c0d0e0f", project, manager)
    project.add_vm(vm)
    directory = project.vm_working_directory(vm)
    project.mark_vm_for_destruction(vm)
    assert len(project._vms_to_destroy) == 1
    assert os.path.exists(directory)
    os.chmod(directory, 0)
    loop.run_until_complete(asyncio.async(project.commit()))
Ejemplo n.º 7
0
def test_commit_permission_issue(manager, loop):
    """
    GNS3 will fix the permission and continue to delete
    """
    project = Project()
    vm = VPCSVM("test", "00010203-0405-0607-0809-0a0b0c0d0e0f", project,
                manager)
    project.add_vm(vm)
    directory = project.vm_working_directory(vm)
    project.mark_vm_for_destruction(vm)
    assert len(project._vms_to_destroy) == 1
    assert os.path.exists(directory)
    os.chmod(directory, 0)
    loop.run_until_complete(asyncio. async (project.commit()))
Ejemplo n.º 8
0
def test_vm_working_directory(tmpdir, vm):
    with patch("gns3server.modules.project.Project.is_local", return_value=True):
        p = Project(location=str(tmpdir))
        assert p.vm_working_directory(vm) == os.path.join(str(tmpdir), p.id, 'project-files', vm.module_name, vm.id)
        assert os.path.exists(p.vm_working_directory(vm))