2727
2828
2929@pytest .mark .parametrize ("revision" , ["" , "HEAD" , "HEAD^" , "HEAD^..HEAD" ])
30- def test_graph_export_validation (runner , project , directory_tree , run , revision ):
30+ def test_graph_export_validation (runner , project , directory_tree , run , revision , cache_test_project ):
3131 """Test graph validation when exporting."""
32- assert 0 == runner .invoke (cli , ["dataset" , "add" , "--copy" , "-c" , "my-data" , str (directory_tree )]).exit_code
32+ if not cache_test_project .setup ():
33+ assert 0 == runner .invoke (cli , ["dataset" , "add" , "--copy" , "-c" , "my-data" , str (directory_tree )]).exit_code
3334
34- file1 = project .path / DATA_DIR / "my-data" / directory_tree .name / "file1"
35- file2 = project .path / DATA_DIR / "my-data" / directory_tree .name / "dir1" / "file2"
36- assert 0 == run (["run" , "head" , str (file1 )], stdout = "out1" )
37- assert 0 == run (["run" , "tail" , str (file2 )], stdout = "out2" )
35+ file1 = project .path / DATA_DIR / "my-data" / directory_tree .name / "file1"
36+ file2 = project .path / DATA_DIR / "my-data" / directory_tree .name / "dir1" / "file2"
37+ assert 0 == run (["run" , "head" , str (file1 )], stdout = "out1" )
38+ assert 0 == run (["run" , "tail" , str (file2 )], stdout = "out2" )
39+ cache_test_project .save ()
3840
3941 result = runner .invoke (cli , ["graph" , "export" , "--format" , "json-ld" , "--strict" , "--revision" , revision ])
4042
@@ -57,12 +59,14 @@ def test_graph_export_validation(runner, project, directory_tree, run, revision)
5759
5860@pytest .mark .serial
5961@pytest .mark .shelled
60- def test_graph_export_strict_run (runner , project , run_shell ):
62+ def test_graph_export_strict_run (runner , project , run_shell , cache_test_project ):
6163 """Test graph export output of run command."""
62- # Run a shell command with pipe.
63- assert run_shell ('renku run --name run1 echo "my input string" > my_output_file' )[1 ] is None
64- assert run_shell ("renku run --name run2 cp my_output_file my_output_file2" )[1 ] is None
65- assert run_shell ("renku workflow compose my-composite-plan run1 run2" )[1 ] is None
64+ if not cache_test_project .setup ():
65+ # Run a shell command with pipe.
66+ assert run_shell ('renku run --name run1 echo "my input string" > my_output_file' )[1 ] is None
67+ assert run_shell ("renku run --name run2 cp my_output_file my_output_file2" )[1 ] is None
68+ assert run_shell ("renku workflow compose my-composite-plan run1 run2" )[1 ] is None
69+ cache_test_project .save ()
6670
6771 # Assert created output file.
6872 result = runner .invoke (cli , ["graph" , "export" , "--full" , "--strict" , "--format=json-ld" ])
@@ -80,21 +84,25 @@ def test_graph_export_strict_run(runner, project, run_shell):
8084 assert 0 == result .exit_code , format_result_exception (result )
8185
8286
83- def test_graph_export_strict_dataset (tmpdir , runner , project , subdirectory ):
87+ def test_graph_export_strict_dataset (tmpdir , runner , project , subdirectory , cache_test_project ):
8488 """Test output of graph export for dataset add."""
85- result = runner .invoke (cli , ["dataset" , "create" , "my-dataset" ])
86- assert 0 == result .exit_code , format_result_exception (result )
87- paths = []
88- test_paths = []
89- for i in range (3 ):
90- new_file = tmpdir .join (f"file_{ i } " )
91- new_file .write (str (i ))
92- paths .append (str (new_file ))
93- test_paths .append (os .path .relpath (str (new_file ), str (project .path )))
94-
95- # add data
96- result = runner .invoke (cli , ["dataset" , "add" , "--copy" , "my-dataset" ] + paths )
97- assert 0 == result .exit_code , format_result_exception (result )
89+ if not cache_test_project .setup ():
90+ result = runner .invoke (cli , ["dataset" , "create" , "my-dataset" ])
91+ assert 0 == result .exit_code , format_result_exception (result )
92+ paths = []
93+ test_paths = []
94+ for i in range (3 ):
95+ new_file = tmpdir .join (f"file_{ i } " )
96+ new_file .write (str (i ))
97+ paths .append (str (new_file ))
98+ test_paths .append (os .path .relpath (str (new_file ), str (project .path )))
99+
100+ # add data
101+ result = runner .invoke (cli , ["dataset" , "add" , "--copy" , "my-dataset" ] + paths )
102+ assert 0 == result .exit_code , format_result_exception (result )
103+ cache_test_project .save ()
104+ else :
105+ test_paths = [f"../file_{ i } " for i in range (3 )]
98106
99107 result = runner .invoke (cli , ["graph" , "export" , "--strict" , "--format=json-ld" , "--revision" , "HEAD" ])
100108 assert 0 == result .exit_code , format_result_exception (result )
0 commit comments