commit/galaxy-central: 3 new changesets
3 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/4d4ad2a65454/ Changeset: 4d4ad2a65454 User: jmchilton Date: 2014-04-27 00:52:08 Summary: Tools API Tests - Add another test with repeat. Adding abstractions reused heavily in collections and multi-execution tests downstream. Affected #: 1 file diff -r 03efdcca196906f3aac9939517096da445ff0bf3 -r 4d4ad2a654545e461c3b41c903a53657a640c07d test/functional/api/test_tools.py --- a/test/functional/api/test_tools.py +++ b/test/functional/api/test_tools.py @@ -54,28 +54,69 @@ self.assertEquals( result_content, table ) def test_run_cat1( self ): + # Run simple non-upload tool with an input data parameter. history_id = self._new_history() - new_dataset = self._new_dataset( history_id ) - dataset_id = new_dataset[ 'id' ] + new_dataset = self._new_dataset( history_id, content='Cat1Test' ) + inputs = dict( + input1=dataset_to_param( new_dataset ), + ) + outputs = self._cat1_outputs( history_id, inputs=inputs ) + self.assertEquals( len( outputs ), 1 ) + self._wait_for_history( history_id, assert_ok=True ) + output1 = outputs[ 0 ] + output1_content = self._get_content( history_id, dataset=output1 ) + self.assertEqual( output1_content.strip(), "Cat1Test" ) + + def test_run_cat1_with_two_inputs( self ): + # Run tool with an multiple data parameter and grouping (repeat) + history_id = self._new_history() + new_dataset1 = self._new_dataset( history_id, content='Cat1Test' ) + new_dataset2 = self._new_dataset( history_id, content='Cat2Test' ) + inputs = { + 'input1': dataset_to_param( new_dataset1 ), + 'queries_0|input2': dataset_to_param( new_dataset2 ) + } + outputs = self._cat1_outputs( history_id, inputs=inputs ) + self.assertEquals( len( outputs ), 1 ) + self._wait_for_history( history_id, assert_ok=True ) + output1 = outputs[ 0 ] + output1_content = self._get_content( history_id, dataset=output1 ) + self.assertEqual( output1_content.strip(), "Cat1Test\nCat2Test" ) + + def _cat1_outputs( self, history_id, inputs ): + create_response = self._run_cat1( history_id, inputs ) + self._assert_status_code_is( create_response, 200 ) + create = create_response.json() + self._assert_has_keys( create, 'outputs' ) + return create[ 'outputs' ] + + def _run_cat1( self, history_id, inputs ): payload = self._run_tool_payload( tool_id='cat1', - inputs=dict( - input1=dict( - src='hda', - id=dataset_id - ), - ), + inputs=inputs, history_id=history_id, ) create_response = self._post( "tools", data=payload ) - self._assert_status_code_is( create_response, 200 ) - self._assert_has_keys( create_response.json(), 'outputs' ) - self._wait_for_history( history_id, assert_ok=True ) + return create_response def _upload_and_get_content( self, content, **upload_kwds ): history_id = self._new_history() new_dataset = self._new_dataset( history_id, content=content, **upload_kwds ) self._wait_for_history( history_id, assert_ok=True ) - display_response = self._get( "histories/%s/contents/%s/display" % ( history_id, new_dataset[ "id" ] ) ) + 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 + + +def dataset_to_param( dataset ): + return dict( + src='hda', + id=dataset[ 'id' ] + ) https://bitbucket.org/galaxy/galaxy-central/commits/a05d14c84adb/ Changeset: a05d14c84adb User: jmchilton Date: 2014-04-27 00:52:08 Summary: Tools API Tests - Refactor away from deprecated mixin toward DatasetPopulator class. Affected #: 2 files diff -r 4d4ad2a654545e461c3b41c903a53657a640c07d -r a05d14c84adb736daaeb80323269964a0fab97ff test/functional/api/helpers.py --- a/test/functional/api/helpers.py +++ b/test/functional/api/helpers.py @@ -9,6 +9,8 @@ # row - first grabbing 8 lines at random and then 6. workflow_random_x2_str = resource_string( __name__, "test_workflow_2.ga" ) +DEFAULT_HISTORY_TIMEOUT = 5 # Secs to wait on history to turn ok + # Deprecated mixin, use dataset populator instead. # TODO: Rework existing tests to target DatasetPopulator in a setup method instead. @@ -40,8 +42,8 @@ run_response = self.galaxy_interactor.post( "tools", data=payload ) return run_response.json()["outputs"][0] - def wait_for_history( self, history_id, assert_ok=False ): - wait_on_state( lambda: self.galaxy_interactor.get( "histories/%s" % history_id ), assert_ok=assert_ok ) + def wait_for_history( self, history_id, assert_ok=False, timeout=DEFAULT_HISTORY_TIMEOUT ): + wait_on_state( lambda: self.galaxy_interactor.get( "histories/%s" % history_id ), assert_ok=assert_ok, timeout=timeout ) def new_history( self, **kwds ): name = kwds.get( "name", "API Test History" ) diff -r 4d4ad2a654545e461c3b41c903a53657a640c07d -r a05d14c84adb736daaeb80323269964a0fab97ff test/functional/api/test_tools.py --- a/test/functional/api/test_tools.py +++ b/test/functional/api/test_tools.py @@ -3,10 +3,14 @@ from base import api from operator import itemgetter -from .helpers import TestsDatasets +from .helpers import DatasetPopulator -class ToolsTestCase( api.ApiTestCase, TestsDatasets ): +class ToolsTestCase( api.ApiTestCase ): + + def setUp( self ): + super( ToolsTestCase, self ).setUp( ) + self.dataset_populator = DatasetPopulator( self.galaxy_interactor ) def test_index( self ): index = self._get( "tools" ) @@ -27,8 +31,8 @@ assert "cat1" in tool_ids def test_upload1_paste( self ): - history_id = self._new_history() - payload = self._upload_payload( history_id, 'Hello World' ) + history_id = self.dataset_populator.new_history() + payload = self.dataset_populator.upload_payload( history_id, 'Hello World' ) create_response = self._post( "tools", data=payload ) self._assert_has_keys( create_response.json(), 'outputs' ) @@ -55,30 +59,30 @@ def test_run_cat1( self ): # Run simple non-upload tool with an input data parameter. - history_id = self._new_history() - new_dataset = self._new_dataset( history_id, content='Cat1Test' ) + history_id = self.dataset_populator.new_history() + new_dataset = self.dataset_populator.new_dataset( history_id, content='Cat1Test' ) inputs = dict( input1=dataset_to_param( new_dataset ), ) outputs = self._cat1_outputs( history_id, inputs=inputs ) self.assertEquals( len( outputs ), 1 ) - self._wait_for_history( history_id, assert_ok=True ) + self.dataset_populator.wait_for_history( history_id, assert_ok=True ) output1 = outputs[ 0 ] output1_content = self._get_content( history_id, dataset=output1 ) self.assertEqual( output1_content.strip(), "Cat1Test" ) def test_run_cat1_with_two_inputs( self ): # Run tool with an multiple data parameter and grouping (repeat) - history_id = self._new_history() - new_dataset1 = self._new_dataset( history_id, content='Cat1Test' ) - new_dataset2 = self._new_dataset( history_id, content='Cat2Test' ) + history_id = self.dataset_populator.new_history() + new_dataset1 = self.dataset_populator.new_dataset( history_id, content='Cat1Test' ) + new_dataset2 = self.dataset_populator.new_dataset( history_id, content='Cat2Test' ) inputs = { 'input1': dataset_to_param( new_dataset1 ), 'queries_0|input2': dataset_to_param( new_dataset2 ) } outputs = self._cat1_outputs( history_id, inputs=inputs ) self.assertEquals( len( outputs ), 1 ) - self._wait_for_history( history_id, assert_ok=True ) + self.dataset_populator.wait_for_history( history_id, assert_ok=True ) output1 = outputs[ 0 ] output1_content = self._get_content( history_id, dataset=output1 ) self.assertEqual( output1_content.strip(), "Cat1Test\nCat2Test" ) @@ -91,7 +95,7 @@ return create[ 'outputs' ] def _run_cat1( self, history_id, inputs ): - payload = self._run_tool_payload( + payload = self.dataset_populator.run_tool_payload( tool_id='cat1', inputs=inputs, history_id=history_id, @@ -100,9 +104,9 @@ return create_response def _upload_and_get_content( self, content, **upload_kwds ): - history_id = self._new_history() - new_dataset = self._new_dataset( history_id, content=content, **upload_kwds ) - self._wait_for_history( history_id, assert_ok=True ) + 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 ): https://bitbucket.org/galaxy/galaxy-central/commits/9dbd0de27e53/ Changeset: 9dbd0de27e53 User: jmchilton Date: 2014-04-27 00:52:08 Summary: Workflow Editor Unit Tests - Improvements to input terminal canAccept tests. Use real connectors, add tests for logic related to multiple input data parameters. Affected #: 1 file diff -r a05d14c84adb736daaeb80323269964a0fab97ff -r 9dbd0de27e53a2cac3c604c0aa6fb70ffb5ac7d1 test/qunit/tests/workflow_editor_tests.js --- a/test/qunit/tests/workflow_editor_tests.js +++ b/test/qunit/tests/workflow_editor_tests.js @@ -60,20 +60,27 @@ }; module( "Input terminal model test", { - setup: function() { - this.node = { }; - this.element = $( "<div>" ); - var input = { extensions: [ "txt" ], multiple: false }; - this.input_terminal = new InputTerminal( { element: this.element, input: input } ); + setup: function( ) { + this.node = new Node( { } ); + this.input = { extensions: [ "txt" ], multiple: false }; + this.input_terminal = new InputTerminal( { input: this.input } ); this.input_terminal.node = this.node; }, - test_connector: function( attr ) { - var connector = attr || {}; - this.input_terminal.connectors.push( connector ); + multiple: function( ) { + this.input.multiple = true; + this.input_terminal.update( this.input ); + }, + test_connector: function( ) { + var outputTerminal = new OutputTerminal( { datatypes: [ 'input' ] } ); + var inputTerminal = this.input_terminal; + var connector; + with_workflow_global( function() { + connector = new Connector( outputTerminal, inputTerminal ); + } ); return connector; }, - with_test_connector: function( attr, f ) { - this.test_connector( attr ); + with_test_connector: function( f ) { + this.test_connector( ); f(); this.reset_connectors(); }, @@ -116,7 +123,7 @@ test( "test disconnect", function() { this.node.markChanged = sinon.spy(); - var connector = this.test_connector( {} ); + var connector = this.test_connector( ); this.input_terminal.disconnect( connector ); // Assert node markChanged called @@ -126,17 +133,19 @@ } ); test( "test redraw", function() { - var connector = this.test_connector( { redraw: sinon.spy() } ); + var connector = this.test_connector( ); + connector.redraw = sinon.spy(); this.input_terminal.redraw(); // Assert connectors were redrawn ok( connector.redraw.called ); } ); test( "test destroy", function() { - var connector = this.test_connector( { destroy: sinon.spy() } ); + var connector = this.test_connector(); + connector.destroy = sinon.spy(); this.input_terminal.destroy(); - // Assert connectors were redrawn + // Assert connectors were destroyed ok( connector.destroy.called ); } ); @@ -189,11 +198,29 @@ test( "cannot accept when already connected", function() { var self = this; // If other is subtype but already connected, cannot accept - this.with_test_connector( {}, function() { + this.with_test_connector( function() { ok( ! self.test_accept() ); } ); } ); + test( "can accept already connected inputs if input is multiple", function() { + var self = this; + this.multiple(); + this.with_test_connector( function() { + ok( self.test_accept() ); + } ); + } ); + + test( "cannot accept already connected inputs if input is multiple but datatypes don't match", function() { + var other = { node: {}, datatypes: [ "binary" ] }; // binary is not txt + + var self = this; + this.multiple(); + this.with_test_connector( function() { + ok( ! self.test_accept( other ) ); + } ); + } ); + module( "Connector test", { } ); 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