|
24 | 24 | from tests.utils import format_result_exception
|
25 | 25 |
|
26 | 26 |
|
27 |
| -def test_mergetool(runner, project, directory_tree, run_shell, with_injection): |
| 27 | +def test_mergetool(runner, project, directory_tree, run_shell, with_injection, cache_test_project): |
28 | 28 | """Test that merge tool can merge renku metadata."""
|
29 |
| - result = runner.invoke(cli, ["mergetool", "install"]) |
| 29 | + if not cache_test_project.setup(): |
| 30 | + result = runner.invoke(cli, ["mergetool", "install"]) |
30 | 31 |
|
31 |
| - assert 0 == result.exit_code, format_result_exception(result) |
| 32 | + assert 0 == result.exit_code, format_result_exception(result) |
32 | 33 |
|
33 |
| - # create a common dataset |
34 |
| - result = runner.invoke( |
35 |
| - cli, ["dataset", "add", "--copy", "--create", "shared-dataset", str(directory_tree)], catch_exceptions=False |
36 |
| - ) |
37 |
| - assert 0 == result.exit_code, format_result_exception(result) |
| 34 | + # create a common dataset |
| 35 | + result = runner.invoke( |
| 36 | + cli, ["dataset", "add", "--copy", "--create", "shared-dataset", str(directory_tree)], catch_exceptions=False |
| 37 | + ) |
| 38 | + assert 0 == result.exit_code, format_result_exception(result) |
38 | 39 |
|
39 |
| - # Create a common workflow |
40 |
| - output = run_shell('renku run --name "shared-workflow" echo "a unique string" > my_output_file') |
| 40 | + # Create a common workflow |
| 41 | + output = run_shell('renku run --name "shared-workflow" echo "a unique string" > my_output_file') |
41 | 42 |
|
42 |
| - assert b"" == output[0] |
43 |
| - assert output[1] is None |
| 43 | + assert b"" == output[0] |
| 44 | + assert output[1] is None |
44 | 45 |
|
45 |
| - # switch to a new branch |
46 |
| - output = run_shell("git checkout -b remote-branch") |
| 46 | + # switch to a new branch |
| 47 | + output = run_shell("git checkout -b remote-branch") |
47 | 48 |
|
48 |
| - assert b"Switched to a new branch 'remote-branch'\n" == output[0] |
49 |
| - assert output[1] is None |
| 49 | + assert b"Switched to a new branch 'remote-branch'\n" == output[0] |
| 50 | + assert output[1] is None |
50 | 51 |
|
51 |
| - # edit the dataset |
52 |
| - result = runner.invoke(cli, ["dataset", "edit", "-d", "remote description", "shared-dataset"]) |
53 |
| - assert 0 == result.exit_code, format_result_exception(result) |
| 52 | + # edit the dataset |
| 53 | + result = runner.invoke(cli, ["dataset", "edit", "-d", "remote description", "shared-dataset"]) |
| 54 | + assert 0 == result.exit_code, format_result_exception(result) |
54 | 55 |
|
55 |
| - result = runner.invoke( |
56 |
| - cli, ["dataset", "add", "--copy", "--create", "remote-dataset", str(directory_tree)], catch_exceptions=False |
57 |
| - ) |
58 |
| - assert 0 == result.exit_code, format_result_exception(result) |
| 56 | + result = runner.invoke( |
| 57 | + cli, ["dataset", "add", "--copy", "--create", "remote-dataset", str(directory_tree)], catch_exceptions=False |
| 58 | + ) |
| 59 | + assert 0 == result.exit_code, format_result_exception(result) |
59 | 60 |
|
60 |
| - # Create a new workflow |
61 |
| - output = run_shell('renku run --name "remote-workflow" echo "a unique string" > remote_output_file') |
| 61 | + # Create a new workflow |
| 62 | + output = run_shell('renku run --name "remote-workflow" echo "a unique string" > remote_output_file') |
62 | 63 |
|
63 |
| - assert b"" == output[0] |
64 |
| - assert output[1] is None |
| 64 | + assert b"" == output[0] |
| 65 | + assert output[1] is None |
65 | 66 |
|
66 |
| - # Create a downstream workflow |
67 |
| - output = run_shell('renku run --name "remote-downstream-workflow" cp my_output_file my_remote_downstream') |
| 67 | + # Create a downstream workflow |
| 68 | + output = run_shell('renku run --name "remote-downstream-workflow" cp my_output_file my_remote_downstream') |
68 | 69 |
|
69 |
| - assert b"" == output[0] |
70 |
| - assert output[1] is None |
| 70 | + assert b"" == output[0] |
| 71 | + assert output[1] is None |
71 | 72 |
|
72 |
| - # Create another downstream workflow |
73 |
| - output = run_shell('renku run --name "remote-downstream-workflow2" cp remote_output_file my_remote_downstream2') |
| 73 | + # Create another downstream workflow |
| 74 | + output = run_shell('renku run --name "remote-downstream-workflow2" cp remote_output_file my_remote_downstream2') |
74 | 75 |
|
75 |
| - assert b"" == output[0] |
76 |
| - assert output[1] is None |
| 76 | + assert b"" == output[0] |
| 77 | + assert output[1] is None |
77 | 78 |
|
78 |
| - # Edit the project metadata |
79 |
| - result = runner.invoke(cli, ["project", "edit", "-k", "remote"]) |
| 79 | + # Edit the project metadata |
| 80 | + result = runner.invoke(cli, ["project", "edit", "-k", "remote"]) |
80 | 81 |
|
81 |
| - assert 0 == result.exit_code, format_result_exception(result) |
| 82 | + assert 0 == result.exit_code, format_result_exception(result) |
82 | 83 |
|
83 |
| - # Switch back to master |
84 |
| - output = run_shell("git checkout master") |
| 84 | + # Switch back to master |
| 85 | + output = run_shell("git checkout master") |
85 | 86 |
|
86 |
| - assert b"Switched to branch 'master'\n" == output[0] |
87 |
| - assert output[1] is None |
| 87 | + assert b"Switched to branch 'master'\n" == output[0] |
| 88 | + assert output[1] is None |
88 | 89 |
|
89 |
| - # Add a new dataset |
90 |
| - result = runner.invoke( |
91 |
| - cli, ["dataset", "add", "--copy", "--create", "local-dataset", str(directory_tree)], catch_exceptions=False |
92 |
| - ) |
93 |
| - assert 0 == result.exit_code, format_result_exception(result) |
| 90 | + # Add a new dataset |
| 91 | + result = runner.invoke( |
| 92 | + cli, ["dataset", "add", "--copy", "--create", "local-dataset", str(directory_tree)], catch_exceptions=False |
| 93 | + ) |
| 94 | + assert 0 == result.exit_code, format_result_exception(result) |
94 | 95 |
|
95 |
| - # Create a local workflow |
96 |
| - output = run_shell('renku run --name "local-workflow" echo "a unique string" > local_output_file') |
| 96 | + # Create a local workflow |
| 97 | + output = run_shell('renku run --name "local-workflow" echo "a unique string" > local_output_file') |
97 | 98 |
|
98 |
| - assert b"" == output[0] |
99 |
| - assert output[1] is None |
| 99 | + assert b"" == output[0] |
| 100 | + assert output[1] is None |
100 | 101 |
|
101 |
| - # Create a local downstream workflow |
102 |
| - output = run_shell('renku run --name "local-downstream-workflow" cp my_output_file my_local_downstream') |
| 102 | + # Create a local downstream workflow |
| 103 | + output = run_shell('renku run --name "local-downstream-workflow" cp my_output_file my_local_downstream') |
103 | 104 |
|
104 |
| - assert b"" == output[0] |
105 |
| - assert output[1] is None |
| 105 | + assert b"" == output[0] |
| 106 | + assert output[1] is None |
106 | 107 |
|
107 |
| - # Create another local downstream workflow |
108 |
| - output = run_shell('renku run --name "local-downstream-workflow2" cp local_output_file my_local_downstream2') |
| 108 | + # Create another local downstream workflow |
| 109 | + output = run_shell('renku run --name "local-downstream-workflow2" cp local_output_file my_local_downstream2') |
109 | 110 |
|
110 |
| - assert b"" == output[0] |
111 |
| - assert output[1] is None |
| 111 | + assert b"" == output[0] |
| 112 | + assert output[1] is None |
112 | 113 |
|
113 |
| - # Edit the project in master as well |
114 |
| - result = runner.invoke(cli, ["project", "edit", "-k", "local"]) |
| 114 | + # Edit the project in master as well |
| 115 | + result = runner.invoke(cli, ["project", "edit", "-k", "local"]) |
115 | 116 |
|
116 |
| - assert 0 == result.exit_code, format_result_exception(result) |
| 117 | + assert 0 == result.exit_code, format_result_exception(result) |
| 118 | + cache_test_project.save() |
117 | 119 |
|
118 | 120 | # Merge branches
|
119 | 121 | output = run_shell("git merge --no-edit remote-branch")
|
@@ -146,32 +148,34 @@ def test_mergetool(runner, project, directory_tree, run_shell, with_injection):
|
146 | 148 | assert "remote description" == shared_dataset.description
|
147 | 149 |
|
148 | 150 |
|
149 |
| -def test_mergetool_workflow_conflict(runner, project, run_shell, with_injection): |
| 151 | +def test_mergetool_workflow_conflict(runner, project, run_shell, with_injection, cache_test_project): |
150 | 152 | """Test that merge tool can merge conflicting workflows."""
|
151 |
| - result = runner.invoke(cli, ["mergetool", "install"]) |
| 153 | + if not cache_test_project.setup(): |
| 154 | + result = runner.invoke(cli, ["mergetool", "install"]) |
152 | 155 |
|
153 |
| - assert 0 == result.exit_code, format_result_exception(result) |
| 156 | + assert 0 == result.exit_code, format_result_exception(result) |
154 | 157 |
|
155 |
| - output = run_shell('renku run --name "shared-workflow" echo "a unique string" > my_output_file') |
| 158 | + output = run_shell('renku run --name "shared-workflow" echo "a unique string" > my_output_file') |
156 | 159 |
|
157 |
| - assert b"" == output[0] |
158 |
| - assert output[1] is None |
| 160 | + assert b"" == output[0] |
| 161 | + assert output[1] is None |
159 | 162 |
|
160 |
| - # Switch to a new branch and create some workflows |
161 |
| - output = run_shell("git checkout -b remote-branch") |
| 163 | + # Switch to a new branch and create some workflows |
| 164 | + output = run_shell("git checkout -b remote-branch") |
162 | 165 |
|
163 |
| - assert b"Switched to a new branch 'remote-branch'\n" == output[0] |
164 |
| - assert output[1] is None |
| 166 | + assert b"Switched to a new branch 'remote-branch'\n" == output[0] |
| 167 | + assert output[1] is None |
165 | 168 |
|
166 |
| - output = run_shell('renku run --name "remote-workflow" cp my_output_file out1') |
| 169 | + output = run_shell('renku run --name "remote-workflow" cp my_output_file out1') |
167 | 170 |
|
168 |
| - assert b"" == output[0] |
169 |
| - assert output[1] is None |
| 171 | + assert b"" == output[0] |
| 172 | + assert output[1] is None |
170 | 173 |
|
171 |
| - output = run_shell('renku run --name "common-name" cp my_output_file out2') |
| 174 | + output = run_shell('renku run --name "common-name" cp my_output_file out2') |
172 | 175 |
|
173 |
| - assert b"" == output[0] |
174 |
| - assert output[1] is None |
| 176 | + assert b"" == output[0] |
| 177 | + assert output[1] is None |
| 178 | + cache_test_project.save() |
175 | 179 |
|
176 | 180 | with with_injection():
|
177 | 181 | plan_gateway = PlanGateway()
|
@@ -237,30 +241,33 @@ def test_mergetool_workflow_conflict(runner, project, run_shell, with_injection)
|
237 | 241 | assert len(plans) == 4
|
238 | 242 |
|
239 | 243 |
|
240 |
| -def test_mergetool_workflow_complex_conflict(runner, project, run_shell, with_injection): |
| 244 | +def test_mergetool_workflow_complex_conflict(runner, project, run_shell, with_injection, cache_test_project): |
241 | 245 | """Test that merge tool can merge complex conflicts in workflows."""
|
242 |
| - result = runner.invoke(cli, ["mergetool", "install"]) |
| 246 | + if not cache_test_project.setup(): |
| 247 | + result = runner.invoke(cli, ["mergetool", "install"]) |
243 | 248 |
|
244 |
| - assert 0 == result.exit_code, format_result_exception(result) |
| 249 | + assert 0 == result.exit_code, format_result_exception(result) |
245 | 250 |
|
246 |
| - output = run_shell('renku run --name "shared-workflow" echo "a unique string" > my_output_file') |
| 251 | + output = run_shell('renku run --name "shared-workflow" echo "a unique string" > my_output_file') |
247 | 252 |
|
248 |
| - assert b"" == output[0] |
249 |
| - assert output[1] is None |
| 253 | + assert b"" == output[0] |
| 254 | + assert output[1] is None |
250 | 255 |
|
251 |
| - # Switch to a new branch and create some workflows |
252 |
| - output = run_shell("git checkout -b remote-branch") |
| 256 | + # Switch to a new branch and create some workflows |
| 257 | + output = run_shell("git checkout -b remote-branch") |
253 | 258 |
|
254 |
| - assert b"Switched to a new branch 'remote-branch'\n" == output[0] |
255 |
| - assert output[1] is None |
| 259 | + assert b"Switched to a new branch 'remote-branch'\n" == output[0] |
| 260 | + assert output[1] is None |
256 | 261 |
|
257 |
| - output = run_shell('renku run --name "intermediate-workflow" cp my_output_file intermediate') |
| 262 | + output = run_shell('renku run --name "intermediate-workflow" cp my_output_file intermediate') |
258 | 263 |
|
259 |
| - assert b"" == output[0] |
| 264 | + assert b"" == output[0] |
260 | 265 |
|
261 |
| - output = run_shell('renku run --name "final-workflow" cp intermediate final') |
| 266 | + output = run_shell('renku run --name "final-workflow" cp intermediate final') |
262 | 267 |
|
263 |
| - assert b"" == output[0] |
| 268 | + assert b"" == output[0] |
| 269 | + |
| 270 | + cache_test_project.save() |
264 | 271 |
|
265 | 272 | with with_injection():
|
266 | 273 | plan_gateway = PlanGateway()
|
|
0 commit comments