def setUp(self): self.setup_app() history = model.History() self.history = history self.trans = MockTrans(self.app, self.history) self.app.model.context.add(history) self.app.model.context.flush() self.action = DefaultToolAction() self.app.config.len_file_path = "moocow" self.app.object_store = MockObjectStore()
def setUp(self): self.setup_app(mock_model=False) history = model.History() self.history = history self.trans = MockTrans(self.app, self.history) self.app.model.context.add(history) self.app.model.context.flush() self.action = DefaultToolAction() self.app.config.len_file_path = "moocow" self.app.job_config["get_handler"] = lambda h: TEST_HANDLER_NAME self.app.object_store = MockObjectStore()
def setUp(self): self.setup_app() history = model.History() self.history = history self.trans = MockTrans( self.app, self.history ) self.app.model.context.add(history) self.app.model.context.flush() self.action = DefaultToolAction() self.app.config.len_file_path = "moocow" self.app.object_store = MockObjectStore()
def setUp( self ): self.setup_app( mock_model=False ) history = model.History() self.history = history self.trans = MockTrans( self.app, self.history ) self.app.model.context.add( history ) self.app.model.context.flush() self.action = DefaultToolAction() self.app.config.len_file_path = "moocow" self.app.job_config[ "get_handler" ] = lambda h: TEST_HANDLER_NAME self.app.object_store = MockObjectStore()
class DefaultToolActionTestCase(unittest.TestCase, tools_support.UsesApp, tools_support.UsesTools): def setUp(self): self.setup_app() history = model.History() self.history = history self.trans = MockTrans(self.app, self.history) self.app.model.context.add(history) self.app.model.context.flush() self.action = DefaultToolAction() self.app.config.len_file_path = "moocow" self.app.object_store = MockObjectStore() def test_output_created(self): _, output = self._simple_execute() assert len(output) == 1 assert "out1" in output def test_output_label(self): _, output = self._simple_execute() self.assertEqual(output["out1"].name, "Output (moo)") def test_output_label_data(self): hda1 = self.__add_dataset() hda2 = self.__add_dataset() incoming = { "param1": hda1, "repeat1": [ { "param2": hda2 }, ] } job, output = self._simple_execute( tools_support.SIMPLE_CAT_TOOL_CONTENTS, incoming, ) self.assertEqual(output["out1"].name, "Test Tool on data 2 and data 1") def test_object_store_ids(self): _, output = self._simple_execute(contents=TWO_OUTPUTS) self.assertEqual(output["out1"].name, "Output (moo)") self.assertEqual(output["out2"].name, "Output 2 (moo)") def test_params_wrapped(self): hda1 = self.__add_dataset() _, output = self._simple_execute( contents=DATA_IN_LABEL_TOOL_CONTENTS, incoming=dict(repeat1=[dict(param1=hda1)]), ) # Again this is a stupid way to ensure data parameters are wrapped. self.assertEqual(output["out1"].name, "Output (%s)" % hda1.dataset.get_file_name()) def test_inactive_user_job_create_failure(self): self.trans.user_is_active = False try: self._simple_execute() except UserActivationRequiredException: return assert False, "Tool execution succeeded for inactive user!" def __add_dataset(self, state='ok'): hda = model.HistoryDatasetAssociation() hda.dataset = model.Dataset() hda.dataset.state = 'ok' hda.dataset.external_filename = "/tmp/datasets/dataset_001.dat" self.history.add_dataset(hda) self.app.model.context.flush() return hda def _simple_execute(self, contents=None, incoming=None): if contents is None: contents = tools_support.SIMPLE_TOOL_CONTENTS if incoming is None: incoming = dict(param1="moo") self._init_tool(contents) job, out_data, _, _ = self.action.execute( tool=self.tool, trans=self.trans, history=self.history, incoming=incoming, ) return job, out_data
class DefaultToolActionTestCase( unittest.TestCase, tools_support.UsesApp, tools_support.UsesTools ): def setUp( self ): self.setup_app( mock_model=False ) history = model.History() self.history = history self.trans = MockTrans( self.app, self.history ) self.app.model.context.add( history ) self.app.model.context.flush() self.action = DefaultToolAction() self.app.config.len_file_path = "moocow" self.app.job_config[ "get_handler" ] = lambda h: TEST_HANDLER_NAME self.app.object_store = MockObjectStore() def test_output_created( self ): _, output = self._simple_execute() assert len( output ) == 1 assert "out1" in output def test_output_label( self ): _, output = self._simple_execute() self.assertEquals( output[ "out1" ].name, "Output (moo)" ) def test_output_label_data( self ): hda1 = self.__add_dataset() hda2 = self.__add_dataset() incoming = { "param1": hda1, "repeat1": [ {"param2": hda2}, ] } job, output = self._simple_execute( tools_support.SIMPLE_CAT_TOOL_CONTENTS, incoming, ) self.assertEquals( output[ "out1" ].name, "Test Tool on data 2 and data 1" ) def test_object_store_ids( self ): _, output = self._simple_execute( contents=TWO_OUTPUTS ) self.assertEquals( output[ "out1" ].name, "Output (moo)" ) self.assertEquals( output[ "out2" ].name, "Output 2 (moo)" ) def test_params_wrapped( self ): hda1 = self.__add_dataset() _, output = self._simple_execute( contents=DATA_IN_LABEL_TOOL_CONTENTS, incoming=dict( repeat1=[ dict( param1=hda1 ) ] ), ) # Again this is a stupid way to ensure data parameters are wrapped. self.assertEquals( output[ "out1" ].name, "Output (%s)" % hda1.dataset.get_file_name() ) def test_handler_set( self ): job, _ = self._simple_execute() assert job.handler == TEST_HANDLER_NAME def __add_dataset( self, state='ok' ): hda = model.HistoryDatasetAssociation() hda.dataset = model.Dataset() hda.dataset.state = 'ok' hda.dataset.external_filename = "/tmp/datasets/dataset_001.dat" self.history.add_dataset( hda ) self.app.model.context.flush() return hda def _simple_execute( self, contents=None, incoming=None ): if contents is None: contents = tools_support.SIMPLE_TOOL_CONTENTS if incoming is None: incoming = dict(param1="moo") self._init_tool( contents ) return self.action.execute( tool=self.tool, trans=self.trans, history=self.history, incoming=incoming, )
class DefaultToolActionTestCase( unittest.TestCase, tools_support.UsesApp, tools_support.UsesTools ): def setUp( self ): self.setup_app( mock_model=False ) history = model.History() self.history = history self.trans = MockTrans( self.app, self.history ) self.app.model.context.add( history ) self.app.model.context.flush() self.action = DefaultToolAction() self.app.config.len_file_path = "moocow" self.app.job_config[ "get_handler" ] = lambda h: TEST_HANDLER_NAME self.app.object_store = MockObjectStore() def test_output_created( self ): _, output = self._simple_execute() assert len( output ) == 1 assert "out1" in output def test_output_label( self ): _, output = self._simple_execute() self.assertEquals( output[ "out1" ].name, "Output (moo)" ) def test_output_label_data( self ): hda1 = self.__add_dataset() hda2 = self.__add_dataset() incoming = { "param1": hda1, "repeat1": [ {"param2": hda2}, ] } job, output = self._simple_execute( tools_support.SIMPLE_CAT_TOOL_CONTENTS, incoming, ) self.assertEquals( output[ "out1" ].name, "Test Tool on data 2 and data 1" ) def test_params_wrapped( self ): hda1 = self.__add_dataset() _, output = self._simple_execute( contents=DATA_IN_LABEL_TOOL_CONTENTS, incoming=dict( repeat1=[ dict( param1=hda1 ) ] ), ) # Again this is a stupid way to ensure data parameters are wrapped. self.assertEquals( output[ "out1" ].name, "Output (%s)" % hda1.dataset.get_file_name() ) def test_handler_set( self ): job, _ = self._simple_execute() assert job.handler == TEST_HANDLER_NAME def __add_dataset( self, state='ok' ): hda = model.HistoryDatasetAssociation() hda.dataset = model.Dataset() hda.dataset.state = 'ok' hda.dataset.external_filename = "/tmp/datasets/dataset_001.dat" self.history.add_dataset( hda ) self.app.model.context.flush() return hda def _simple_execute( self, contents=None, incoming=None ): if contents is None: contents = tools_support.SIMPLE_TOOL_CONTENTS if incoming is None: incoming = dict(param1="moo") self._init_tool( contents ) return self.action.execute( tool=self.tool, trans=self.trans, history=self.history, incoming=incoming, )