# SPDX-License-Identifier: Apache-2.0
import arvados
+import arvados.collection
import subprocess
api = arvados.api()
+workflow_content = """# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: Apache-2.0
+
+cwlVersion: v1.2
+class: CommandLineTool
+baseCommand: echo
+inputs:
+ message:
+ type: File
+ inputBinding:
+ position: 1
+ default:
+ class: File
+ location: keep:d7514270f356df848477718d58308cc4+94/b
+
+outputs: []
+"""
+
+expect_file = "19070-copy-deps.cwl"
+
+def check_workflow_content(uuid):
+ c = arvados.collection.Collection(uuid)
+ try:
+ with c.open(expect_file) as f:
+ content = f.read()
+ match = (content == workflow_content)
+ return match
+ except:
+ return False
+
def check_contents(group, wf_uuid):
contents = api.groups().contents(uuid=group["uuid"]).execute()
if len(contents["items"]) != 4:
found = False
for c in contents["items"]:
- if c["kind"] == "arvados#collection" and c["portable_data_hash"] == "73b7a68c78205e793a5eb9520326d3ae+61":
+ if c["kind"] == "arvados#collection" and check_workflow_content(c["portable_data_hash"]):
found = True
if not found:
- raise Exception("Couldn't find collection containing workflow")
+ raise Exception("Couldn't find collection containing expected "+expect_file)
-def test_create():
+def check_create():
group = api.groups().create(body={"group": {"name": "test-19070-project-1", "group_class": "project"}}, ensure_unique_name=True).execute()
try:
contents = api.groups().contents(uuid=group["uuid"]).execute()
api.groups().delete(uuid=group["uuid"]).execute()
-def test_update():
+def check_update():
group = api.groups().create(body={"group": {"name": "test-19070-project-2", "group_class": "project"}}, ensure_unique_name=True).execute()
try:
contents = api.groups().contents(uuid=group["uuid"]).execute()
found = False
for c in contents["items"]:
- if c["kind"] == "arvados#collection" and c["portable_data_hash"] == "73b7a68c78205e793a5eb9520326d3ae+61":
+ if c["kind"] == "arvados#collection" and check_workflow_content(c["portable_data_hash"]):
found = True
if not found:
- raise Exception("Couldn't find collection containing workflow")
+ raise Exception("Couldn't find collection containing expected "+expect_file)
# Updating by default will copy missing items
cmd = ["arvados-cwl-runner", "--disable-git", "--update-workflow", wf_uuid, "19070-copy-deps.cwl"]
api.groups().delete(uuid=group["uuid"]).execute()
-def test_execute():
+def check_execute():
group = api.groups().create(body={"group": {"name": "test-19070-project-3", "group_class": "project"}}, ensure_unique_name=True).execute()
try:
contents = api.groups().contents(uuid=group["uuid"]).execute()
api.groups().delete(uuid=group["uuid"]).execute()
if __name__ == '__main__':
- test_create()
- test_update()
- test_execute()
+ check_create()
+ check_update()
+ check_execute()