commit/galaxy-central: jmchilton: Improved API collection workflow run testing.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/b43506b47aad/ Changeset: b43506b47aad User: jmchilton Date: 2014-07-29 17:55:46 Summary: Improved API collection workflow run testing. Remove some duplication between workflow and tool testing code. Affected #: 3 files diff -r 48eacfabffb9af10695beba2fbbb08d7eabc341d -r b43506b47aadfafeb2dc06286d56de7363633599 test/api/helpers.py --- a/test/api/helpers.py +++ b/test/api/helpers.py @@ -120,6 +120,25 @@ api_asserts.assert_status_code_is( tool_response, 200 ) return tool_response.json() + def get_history_dataset_content( self, history_id, wait=True, **kwds ): + if wait: + assert_ok = kwds.get( "assert_ok", True ) + self.wait_for_history( history_id, assert_ok=assert_ok ) + # kwds should contain a 'dataset' object response, a 'dataset_id' or + # the last dataset in the history will be fetched. + contents_url = "histories/%s/contents" % history_id + if "dataset_id" in kwds: + dataset_id = kwds[ "dataset_id" ] + elif "dataset" in kwds: + dataset_id = kwds[ "dataset" ][ "id" ] + else: + dataset_contents = self.galaxy_interactor.get( contents_url ).json() + dataset_id = dataset_contents[ -1 ][ "id" ] + + display_response = self.galaxy_interactor.get( "%s/%s/display" % ( contents_url, dataset_id ) ) + assert display_response.status_code == 200 + return display_response.content + class WorkflowPopulator( object ): # Impulse is to make this a Mixin, but probably better as an object. diff -r 48eacfabffb9af10695beba2fbbb08d7eabc341d -r b43506b47aadfafeb2dc06286d56de7363633599 test/api/test_tools.py --- a/test/api/test_tools.py +++ b/test/api/test_tools.py @@ -105,9 +105,8 @@ ) outputs = self._cat1_outputs( history_id, inputs=inputs ) self.assertEquals( len( outputs ), 1 ) - self.dataset_populator.wait_for_history( history_id, assert_ok=True ) output1 = outputs[ 0 ] - output1_content = self._get_content( history_id, dataset=output1 ) + output1_content = self.dataset_populator.get_history_dataset_content( history_id, dataset=output1 ) self.assertEqual( output1_content.strip(), "Cat1Test" ) @skip_without_tool( "cat1" ) @@ -122,9 +121,8 @@ } outputs = self._cat1_outputs( history_id, inputs=inputs ) self.assertEquals( len( outputs ), 1 ) - self.dataset_populator.wait_for_history( history_id, assert_ok=True ) output1 = outputs[ 0 ] - output1_content = self._get_content( history_id, dataset=output1 ) + output1_content = self.dataset_populator.get_history_dataset_content( history_id, dataset=output1 ) self.assertEqual( output1_content.strip(), "Cat1Test\nCat2Test" ) @skip_without_tool( "cat1" ) @@ -140,11 +138,10 @@ } outputs = self._cat1_outputs( history_id, inputs=inputs ) self.assertEquals( len( outputs ), 2 ) - self.dataset_populator.wait_for_history( history_id, assert_ok=True ) output1 = outputs[ 0 ] output2 = outputs[ 1 ] - output1_content = self._get_content( history_id, dataset=output1 ) - output2_content = self._get_content( history_id, dataset=output2 ) + output1_content = self.dataset_populator.get_history_dataset_content( history_id, dataset=output1 ) + output2_content = self.dataset_populator.get_history_dataset_content( history_id, dataset=output2 ) self.assertEquals( output1_content.strip(), "123" ) self.assertEquals( output2_content.strip(), "456" ) @@ -163,11 +160,10 @@ } outputs = self._cat1_outputs( history_id, inputs=inputs ) self.assertEquals( len( outputs ), 2 ) - self.dataset_populator.wait_for_history( history_id, assert_ok=True, timeout=10 ) output1 = outputs[ 0 ] output2 = outputs[ 1 ] - output1_content = self._get_content( history_id, dataset=output1 ) - output2_content = self._get_content( history_id, dataset=output2 ) + output1_content = self.dataset_populator.get_history_dataset_content( history_id, dataset=output1 ) + output2_content = self.dataset_populator.get_history_dataset_content( history_id, dataset=output2 ) self.assertEquals( output1_content.strip(), "Common\n123" ) self.assertEquals( output2_content.strip(), "Common\n456" ) @@ -190,8 +186,7 @@ } outputs = self._cat1_outputs( history_id, inputs=inputs ) self.assertEquals( len( outputs ), 2 ) - self.dataset_populator.wait_for_history( history_id, assert_ok=True ) - outputs_contents = [ self._get_content( history_id, dataset=o ).strip() for o in outputs ] + outputs_contents = [ self.dataset_populator.get_history_dataset_content( history_id, dataset=o ).strip() for o in outputs ] assert "123\n789" in outputs_contents assert "456\n0ab" in outputs_contents # TODO: Once cross production (instead of linking inputs) is an option @@ -217,11 +212,10 @@ self.assertEquals( len( jobs ), 2 ) self.assertEquals( len( outputs ), 2 ) self.assertEquals( len( implicit_collections ), 1 ) - self.dataset_populator.wait_for_history( history_id, assert_ok=True ) output1 = outputs[ 0 ] output2 = outputs[ 1 ] - output1_content = self._get_content( history_id, dataset=output1 ) - output2_content = self._get_content( history_id, dataset=output2 ) + output1_content = self.dataset_populator.get_history_dataset_content( history_id, dataset=output1 ) + output2_content = self.dataset_populator.get_history_dataset_content( history_id, dataset=output2 ) self.assertEquals( output1_content.strip(), "123" ) self.assertEquals( output2_content.strip(), "456" ) @@ -264,11 +258,10 @@ } outputs = self._cat1_outputs( history_id, inputs=inputs ) self.assertEquals( len( outputs ), 2 ) - self.dataset_populator.wait_for_history( history_id, assert_ok=True ) output1 = outputs[ 0 ] output2 = outputs[ 1 ] - output1_content = self._get_content( history_id, dataset=output1 ) - output2_content = self._get_content( history_id, dataset=output2 ) + output1_content = self.dataset_populator.get_history_dataset_content( history_id, dataset=output1 ) + output2_content = self.dataset_populator.get_history_dataset_content( history_id, dataset=output2 ) self.assertEquals( output1_content.strip(), "123\n789" ) self.assertEquals( output2_content.strip(), "456\n0ab" ) @@ -300,11 +293,10 @@ jobs = create[ 'jobs' ] assert len( jobs ) == 1 assert len( outputs ) == 2 - self.dataset_populator.wait_for_history( history_id, assert_ok=True ) output1 = outputs[ 0 ] output2 = outputs[ 1 ] - output1_content = self._get_content( history_id, dataset=output1 ) - output2_content = self._get_content( history_id, dataset=output2 ) + output1_content = self.dataset_populator.get_history_dataset_content( history_id, dataset=output1 ) + output2_content = self.dataset_populator.get_history_dataset_content( history_id, dataset=output2 ) assert output1_content.strip() == "123\n456" assert len( output2_content.strip().split("\n") ) == 3, output2_content @@ -320,11 +312,10 @@ self.dataset_populator.wait_for_history( history_id, assert_ok=True ) outputs = self._run_and_get_outputs( "collection_paired_test", history_id, inputs ) assert len( outputs ), 2 - self.dataset_populator.wait_for_history( history_id, assert_ok=True ) output1 = outputs[ 0 ] output2 = outputs[ 1 ] - output1_content = self._get_content( history_id, dataset=output1 ) - output2_content = self._get_content( history_id, dataset=output2 ) + output1_content = self.dataset_populator.get_history_dataset_content( history_id, dataset=output1 ) + output2_content = self.dataset_populator.get_history_dataset_content( history_id, dataset=output2 ) assert output1_content.strip() == "123\n456", output1_content assert output2_content.strip() == "789\n0ab", output2_content @@ -341,11 +332,10 @@ self.dataset_populator.wait_for_history( history_id, assert_ok=True ) outputs = self._run_and_get_outputs( "collection_mixed_param", history_id, inputs ) assert len( outputs ), 2 - self.dataset_populator.wait_for_history( history_id, assert_ok=True ) output1 = outputs[ 0 ] output2 = outputs[ 1 ] - output1_content = self._get_content( history_id, dataset=output1 ) - output2_content = self._get_content( history_id, dataset=output2 ) + output1_content = self.dataset_populator.get_history_dataset_content( history_id, dataset=output1 ) + output2_content = self.dataset_populator.get_history_dataset_content( history_id, dataset=output2 ) assert output1_content.strip() == "123\n456\nxxx", output1_content assert output2_content.strip() == "789\n0ab\nyyy", output2_content @@ -381,16 +371,7 @@ history_id = self.dataset_populator.new_history() new_dataset = self.dataset_populator.new_dataset( history_id, content=content, **upload_kwds ) self.dataset_populator.wait_for_history( history_id, assert_ok=True ) - return self._get_content( history_id, dataset=new_dataset ) - - def _get_content( self, history_id, **kwds ): - if "dataset_id" in kwds: - dataset_id = kwds[ "dataset_id" ] - else: - dataset_id = kwds[ "dataset" ][ "id" ] - display_response = self._get( "histories/%s/contents/%s/display" % ( history_id, dataset_id ) ) - self._assert_status_code_is( display_response, 200 ) - return display_response.content + return self.dataset_populator.get_history_dataset_content( history_id, dataset=new_dataset ) def __tool_ids( self ): index = self._get( "tools" ) diff -r 48eacfabffb9af10695beba2fbbb08d7eabc341d -r b43506b47aadfafeb2dc06286d56de7363633599 test/api/test_workflows.py --- a/test/api/test_workflows.py +++ b/test/api/test_workflows.py @@ -103,6 +103,7 @@ run_workflow_response = self._post( "workflows", data=workflow_request ) self._assert_status_code_is( run_workflow_response, 200 ) self.dataset_populator.wait_for_history( history_id, assert_ok=True ) + self.assertEquals("1 2 3\n4 5 6\n7 8 9\n0 a b\n", self.dataset_populator.get_history_dataset_content( history_id ) ) @skip_without_tool( "cat1" ) def test_extract_from_history( self ): Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
commits-noreply@bitbucket.org