- return CollectionExecute(created_collections[uuid])
-
- def collection_getstub(created_collections, uuid):
- for v in viewvalues(created_collections):
- if uuid in (v["uuid"], v["portable_data_hash"]):
- return CollectionExecute(v)
-
- created_collections = {
- "99999999999999999999999999999998+99": {
- "uuid": "",
- "portable_data_hash": "99999999999999999999999999999998+99",
- "manifest_text": ". 99999999999999999999999999999998+99 0:0:file1.txt"
- },
- "99999999999999999999999999999997+99": {
- "uuid": "",
- "portable_data_hash": "99999999999999999999999999999997+99",
- "manifest_text": ". 99999999999999999999999999999997+99 0:0:file1.txt"
- },
- "99999999999999999999999999999994+99": {
- "uuid": "",
- "portable_data_hash": "99999999999999999999999999999994+99",
- "manifest_text": ". 99999999999999999999999999999994+99 0:0:expect_arvworkflow.cwl"
- },
- "zzzzz-4zz18-zzzzzzzzzzzzzd3": {
- "uuid": "zzzzz-4zz18-zzzzzzzzzzzzzd3",
- "portable_data_hash": "999999999999999999999999999999d3+99",
- "manifest_text": ""
- },
- "zzzzz-4zz18-zzzzzzzzzzzzzd4": {
- "uuid": "zzzzz-4zz18-zzzzzzzzzzzzzd4",
- "portable_data_hash": "999999999999999999999999999999d4+99",
- "manifest_text": ""
- },
- "zzzzz-4zz18-zzzzzzzzzzzzzd5": {
- "uuid": "zzzzz-4zz18-zzzzzzzzzzzzzd5",
- "portable_data_hash": "999999999999999999999999999999d5+99",
- "manifest_text": ""
- },
- "zzzzz-4zz18-zzzzzzzzzzzzzd6": {
- "uuid": "zzzzz-4zz18-zzzzzzzzzzzzzd6",
- "portable_data_hash": "999999999999999999999999999999d6+99",
- "manifest_text": ""
- }
- }
- stubs.api.collections().create.side_effect = functools.partial(collection_createstub, created_collections)
- stubs.api.collections().get.side_effect = functools.partial(collection_getstub, created_collections)
-
- stubs.expect_job_uuid = "zzzzz-8i9sb-zzzzzzzzzzzzzzz"
- stubs.api.jobs().create().execute.return_value = {
- "uuid": stubs.expect_job_uuid,
- "state": "Queued",
- }
-
- stubs.expect_container_request_uuid = "zzzzz-xvhdp-zzzzzzzzzzzzzzz"
- stubs.api.container_requests().create().execute.return_value = {
- "uuid": stubs.expect_container_request_uuid,
- "container_uuid": "zzzzz-dz642-zzzzzzzzzzzzzzz",
- "state": "Queued"
- }
-
- stubs.expect_pipeline_template_uuid = "zzzzz-d1hrv-zzzzzzzzzzzzzzz"
- stubs.api.pipeline_templates().create().execute.return_value = {
- "uuid": stubs.expect_pipeline_template_uuid,
- }
- stubs.expect_job_spec = {
- 'runtime_constraints': {
- 'docker_image': '999999999999999999999999999999d3+99',
- 'min_ram_mb_per_node': 1024
- },
- 'script_parameters': {
- 'x': {
- 'basename': 'blorp.txt',
- 'location': 'keep:169f39d466a5438ac4a90e779bf750c7+53/blorp.txt',
- 'class': 'File'
+ stubs.api.config()["StorageClasses"].items.return_value = {
+ "default": {
+ "Default": True
+ }
+ }.items()
+
+ class CollectionExecute(object):
+ def __init__(self, exe):
+ self.exe = exe
+ def execute(self, num_retries=None):
+ return self.exe
+
+ def collection_createstub(created_collections, body, ensure_unique_name=None):
+ mt = body["manifest_text"].encode('utf-8')
+ uuid = "zzzzz-4zz18-zzzzzzzzzzzzzx%d" % len(created_collections)
+ pdh = "%s+%i" % (hashlib.md5(mt).hexdigest(), len(mt))
+ created_collections[uuid] = {
+ "uuid": uuid,
+ "portable_data_hash": pdh,
+ "manifest_text": mt.decode('utf-8')
+ }
+ return CollectionExecute(created_collections[uuid])
+
+ def collection_getstub(created_collections, uuid):
+ for v in viewvalues(created_collections):
+ if uuid in (v["uuid"], v["portable_data_hash"]):
+ return CollectionExecute(v)
+
+ created_collections = {
+ "99999999999999999999999999999998+99": {
+ "uuid": "",
+ "portable_data_hash": "99999999999999999999999999999998+99",
+ "manifest_text": ". 99999999999999999999999999999998+99 0:0:file1.txt"