diff options
Diffstat (limited to 'tests/frontend/workspace.py')
-rw-r--r-- | tests/frontend/workspace.py | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/frontend/workspace.py b/tests/frontend/workspace.py index 90b50613f..817cd9f17 100644 --- a/tests/frontend/workspace.py +++ b/tests/frontend/workspace.py @@ -125,6 +125,50 @@ def test_open_force(cli, tmpdir, datafiles, kind): @pytest.mark.datafiles(DATA_DIR) @pytest.mark.parametrize("kind", repo_kinds) +def test_open_force_open(cli, tmpdir, datafiles, kind): + element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, kind, False) + + # Assert the workspace dir exists + assert os.path.exists(workspace) + + # Now open the workspace again with --force, this should happily succeed + result = cli.run(project=project, args=[ + 'workspace', 'open', '--force', element_name, workspace + ]) + result.assert_success() + + +@pytest.mark.datafiles(DATA_DIR) +@pytest.mark.parametrize("kind", repo_kinds) +def test_open_force_different_workspace(cli, tmpdir, datafiles, kind): + element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, kind, False, "-alpha") + + # Assert the workspace dir exists + assert os.path.exists(workspace) + + tmpdir = os.path.join(str(tmpdir), "-beta") + shutil.move(os.path.join(workspace, 'usr', 'bin', 'hello'), os.path.join(workspace, 'usr', 'bin', 'hello1')) + element_name2, project2, workspace2 = open_workspace(cli, tmpdir, datafiles, kind, False, "-beta") + + # Assert the workspace dir exists + assert os.path.exists(workspace2) + + # Assert that workspace 1 contains the modified file + assert os.path.exists(os.path.join(workspace, 'usr', 'bin', 'hello1')) + + # Now open the workspace again with --force, this should happily succeed + result = cli.run(project=project, args=[ + 'workspace', 'open', '--force', element_name2, workspace + ]) + + # Assert that the file has been replaced + assert os.path.exists(os.path.join(workspace2, 'usr', 'bin', 'hello')) + + result.assert_success() + + +@pytest.mark.datafiles(DATA_DIR) +@pytest.mark.parametrize("kind", repo_kinds) def test_close(cli, tmpdir, datafiles, kind): element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, kind, False) |