11 from .mock_discovery import get_rootDesc
13 class TestMakeOutput(unittest.TestCase):
15 self.api = mock.MagicMock()
16 self.api._rootDesc = get_rootDesc()
18 @mock.patch("arvados.collection.Collection")
19 @mock.patch("arvados.collection.CollectionReader")
20 def test_make_output_collection(self, reader, col):
21 keep_client = mock.MagicMock()
22 runner = arvados_cwl.ArvCwlRunner(self.api, keep_client=keep_client)
23 runner.project_uuid = 'zzzzz-j7d0g-zzzzzzzzzzzzzzz'
25 final = mock.MagicMock()
26 col.return_value = final
27 readermock = mock.MagicMock()
28 reader.return_value = readermock
30 final_uuid = final.manifest_locator()
31 num_retries = runner.num_retries
33 cwlout = StringIO.StringIO()
34 openmock = mock.MagicMock()
35 final.open.return_value = openmock
36 openmock.__enter__.return_value = cwlout
38 _, runner.final_output_collection = runner.make_output_collection("Test output", "tag0,tag1,tag2", {
41 "location": "keep:99999999999999999999999999999991+99/foo.txt",
47 "location": "keep:99999999999999999999999999999992+99/bar.txt",
48 "basename": "baz.txt",
53 final.copy.assert_has_calls([mock.call('bar.txt', 'baz.txt', overwrite=False, source_collection=readermock)])
54 final.copy.assert_has_calls([mock.call('foo.txt', 'foo.txt', overwrite=False, source_collection=readermock)])
55 final.save_new.assert_has_calls([mock.call(ensure_unique_name=True, name='Test output', owner_uuid='zzzzz-j7d0g-zzzzzzzzzzzzzzz')])
59 "location": "baz.txt",
64 "location": "foo.txt",
67 }""", cwlout.getvalue())
69 self.assertIs(final, runner.final_output_collection)
70 self.assertIs(final_uuid, runner.final_output_collection.manifest_locator())
71 self.api.links().create.assert_has_calls([mock.call(body={"head_uuid": final_uuid, "link_class": "tag", "name": "tag0"}), mock.call().execute(num_retries=num_retries)])
72 self.api.links().create.assert_has_calls([mock.call(body={"head_uuid": final_uuid, "link_class": "tag", "name": "tag1"}), mock.call().execute(num_retries=num_retries)])
73 self.api.links().create.assert_has_calls([mock.call(body={"head_uuid": final_uuid, "link_class": "tag", "name": "tag2"}), mock.call().execute(num_retries=num_retries)])