def test_validate_params(self): inputs = { "reads_tuple": [ { "input_reads_label": "reads file 1", "input_reads_obj": "rhodobacterium.art.q20.int.PE.reads", "input_reads_metadata": { "key1": "value1" }, }, { "input_reads_label": "reads file 2", "input_reads_obj": "rhodobacterium.art.q10.PE.reads", "input_reads_metadata": { "key2": "value2" }, }, ], "output_object": "MyReadsSet", "description": "New Reads Set", } app_id = "NarrativeTest/test_create_set" tag = "dev" prev_ws_id = os.environ.get("KB_WORKSPACE_ID") os.environ["KB_WORKSPACE_ID"] = self.public_ws sm = specmanager.SpecManager() spec = sm.get_spec(app_id, tag=tag) (params, ws_inputs) = app_util.validate_parameters(app_id, tag, sm.app_params(spec), inputs) self.assertDictEqual(params, inputs) self.assertIn("12345/8/1", ws_inputs) self.assertIn("12345/7/1", ws_inputs) if prev_ws_id is None: del os.environ["KB_WORKSPACE_ID"] else: os.environ["KB_WORKSPACE_ID"] = prev_ws_id
def test_input_mapping(self): self.maxDiff = None inputs = { "reads_tuple": [{ "input_reads_label": "reads file 1", "input_reads_obj": "rhodobacterium.art.q20.int.PE.reads", "input_reads_metadata": { "key1": "value1" } }, { "input_reads_label": "reads file 2", "input_reads_obj": "rhodobacterium.art.q10.PE.reads", "input_reads_metadata": { "key2": "value2" } }], "output_object": "MyReadsSet", "description": "New Reads Set" } app_id = "NarrativeTest/test_create_set" tag = "dev" ws_name = self.public_ws prev_ws_id = os.environ.get('KB_WORKSPACE_ID', None) os.environ['KB_WORKSPACE_ID'] = ws_name sm = specmanager.SpecManager() spec = sm.get_spec(app_id, tag=tag) spec_params = sm.app_params(spec) spec_params_map = dict((spec_params[i]['id'], spec_params[i]) for i in range(len(spec_params))) mapped_inputs = self.am._map_inputs( spec['behavior']['kb_service_input_mapping'], inputs, spec_params_map) expected = [{ u'output_object_name': 'MyReadsSet', u'data': { u'items': [{ u'label': 'reads file 1', u'metadata': { 'key1': 'value1' }, u'ref': '12345/7/1' }, { u'label': 'reads file 2', u'metadata': { 'key2': 'value2' }, u'ref': '12345/8/1' }], u'description': 'New Reads Set' }, u'workspace': ws_name }] self.assertDictEqual(expected[0], mapped_inputs[0]) ref_path = ws_name + '/MyReadsSet; ' + ws_name + "/rhodobacterium.art.q10.PE.reads" ret = app_util.transform_param_value("resolved-ref", ref_path, None) self.assertEqual(ret, ws_name + '/MyReadsSet;18836/5/1') if prev_ws_id is None: del (os.environ['KB_WORKSPACE_ID']) else: os.environ['KB_WORKSPACE_ID'] = prev_ws_id
def test_input_mapping(self): self.maxDiff = None inputs = { "reads_tuple": [ { "input_reads_label": "reads file 1", "input_reads_obj": "rhodobacterium.art.q20.int.PE.reads", "input_reads_metadata": { "key1": "value1" }, }, { "input_reads_label": "reads file 2", "input_reads_obj": "rhodobacterium.art.q10.PE.reads", "input_reads_metadata": { "key2": "value2" }, }, ], "output_object": "MyReadsSet", "description": "New Reads Set", } app_id = "NarrativeTest/test_create_set" tag = "dev" ws_name = self.public_ws prev_ws_id = os.environ.get("KB_WORKSPACE_ID", None) os.environ["KB_WORKSPACE_ID"] = ws_name sm = specmanager.SpecManager() spec = sm.get_spec(app_id, tag=tag) spec_params = sm.app_params(spec) spec_params_map = dict((spec_params[i]["id"], spec_params[i]) for i in range(len(spec_params))) mapped_inputs = self.am._map_inputs( spec["behavior"]["kb_service_input_mapping"], inputs, spec_params_map) expected = [{ "output_object_name": "MyReadsSet", "data": { "items": [ { "label": "reads file 1", "metadata": { "key1": "value1" }, "ref": "12345/7/1", }, { "label": "reads file 2", "metadata": { "key2": "value2" }, "ref": "12345/8/1", }, ], "description": "New Reads Set", }, "workspace": ws_name, }] self.assertDictEqual(expected[0], mapped_inputs[0]) ref_path = (ws_name + "/MyReadsSet; " + ws_name + "/rhodobacterium.art.q10.PE.reads") ret = app_util.transform_param_value("resolved-ref", ref_path, None) self.assertEqual(ret, ws_name + "/MyReadsSet;18836/5/1") if prev_ws_id is None: del os.environ["KB_WORKSPACE_ID"] else: os.environ["KB_WORKSPACE_ID"] = prev_ws_id