19973: Merge branch 'main'
[arvados.git] / sdk / cwl / tests / test_set_output_prop.py
1 # Copyright (C) The Arvados Authors. All rights reserved.
2 #
3 # SPDX-License-Identifier: Apache-2.0
4
5 import arvados
6 import subprocess
7
8 api = arvados.api()
9
10 def test_execute():
11     group = api.groups().create(body={"group": {"name": "test-17004-project", "group_class": "project"}}, ensure_unique_name=True).execute()
12     try:
13         contents = api.groups().contents(uuid=group["uuid"]).execute()
14         if len(contents["items"]) != 0:
15             raise Exception("Expected 0 items")
16
17         cmd = ["arvados-cwl-runner", "--project-uuid", group["uuid"], "17004-output-props.cwl", "--inp", "scripts/download_all_data.sh"]
18         print(" ".join(cmd))
19         subprocess.check_output(cmd)
20
21         contents = api.groups().contents(uuid=group["uuid"]).execute()
22
23         found = False
24         for c in contents["items"]:
25             if (c["kind"] == "arvados#collection" and
26                 c["properties"].get("type") == "output" and
27                 c["properties"].get("foo") == "bar" and
28                 c["properties"].get("baz") == "download_all_data.sh"):
29                 found = True
30         if not found:
31             raise Exception("Didn't find collection with properties")
32
33     finally:
34         api.groups().delete(uuid=group["uuid"]).execute()
35
36 if __name__ == '__main__':
37     test_execute()