commit/galaxy-central: carlfeberhard: Test fixes for 5ce55f9; correct spaceghost.stderr to use system.stderr (thanks, John); correct api-workflow-tests (which I completely forgot *I* had made) and add test-data
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/ec989f77c079/ Changeset: ec989f77c079 User: carlfeberhard Date: 2014-09-02 21:35:56 Summary: Test fixes for 5ce55f9; correct spaceghost.stderr to use system.stderr (thanks, John); correct api-workflow-tests (which I completely forgot *I* had made) and add test-data Affected #: 10 files diff -r 9f63d9632d9d690c2d5e353feac3f83f12db3f78 -r ec989f77c079f7036c7cb8bb303d1e6bae4a4e4d test/casperjs/api-anon-history-permission-tests.js --- a/test/casperjs/api-anon-history-permission-tests.js +++ b/test/casperjs/api-anon-history-permission-tests.js @@ -25,9 +25,9 @@ // create three histories: make the 2nd importable (via the API), and the third published // make the current the inaccessible one - inaccessibleHistory = this.api.histories.show( 'current' ); + inaccessibleHistory = this.api.histories.index()[0]; this.api.histories.update( inaccessibleHistory.id, { name: 'inaccessible' }); - inaccessibleHistory = this.api.histories.show( 'current' ); + inaccessibleHistory = this.api.histories.index()[0]; accessibleHistory = this.api.histories.create({ name: 'accessible' }); var returned = this.api.histories.update( accessibleHistory.id, { @@ -83,7 +83,7 @@ this.test.comment( 'Attempting to copy an accessible hda (default is accessible)' + ' should work from accessible history: ' + history.name ); - this.api.hdas.create( this.api.histories.show( 'current' ).id, { + this.api.hdas.create( this.api.histories.index()[0].id, { source : 'hda', content : hdas[0].id }); @@ -114,7 +114,7 @@ this.test.comment( 'Attempting to copy an accessible hda (default is accessible)' + ' from an inaccessible history should fail for: ' + history.name ); this.api.assertRaises( function(){ - var returned = this.api.hdas.create( this.api.histories.show( 'current' ).id, { + var returned = this.api.hdas.create( this.api.histories.index()[0].id, { source : 'hda', content : hdas[0].id }); @@ -134,10 +134,6 @@ this.api.assertRaises( function(){ this.api.histories.delete_( history.id ); }, 403, 'API authentication required for this request', 'delete authentication required' ); - this.test.comment( 'set_as_current should fail for history: ' + history.name ); - this.api.assertRaises( function(){ - this.api.histories.set_as_current( history.id ); - }, 403, 'API authentication required for this request', 'set_as_current failed with error' ); this.test.comment( 'hda updating should fail for history: ' + history.name ); this.api.assertRaises( function(){ diff -r 9f63d9632d9d690c2d5e353feac3f83f12db3f78 -r ec989f77c079f7036c7cb8bb303d1e6bae4a4e4d test/casperjs/api-anon-history-tests.js --- a/test/casperjs/api-anon-history-tests.js +++ b/test/casperjs/api-anon-history-tests.js @@ -23,12 +23,6 @@ this.test.assert( historyShow.id === index[0].id, 'Is the first history' ); this.test.assert( this.hasKeys( historyShow, [ 'id', 'name', 'user_id' ] ) ); - this.test.comment( 'Calling show with "current" should return the current history' ); - var current = this.api.histories.show( 'current' ); - //this.debug( this.jsonStr( current ) ); - this.test.assert( current.id === index[0].id, 'Is the first history' ); - this.test.assert( current.id === historyShow.id, 'current returned same id' ); - // ------------------------------------------------------------------------------------------- anon forbidden //TODO: why not return the current history? @@ -36,35 +30,30 @@ var recent = this.api.histories.show( 'most_recently_used' ); this.test.assert( recent === null, 'most_recently_used returned None' ); - this.test.comment( 'Calling set_as_current should fail for an anonymous user' ); - this.api.assertRaises( function(){ - this.api.histories.set_as_current( current.id ); - }, 403, 'API authentication required for this request', 'set_as_current failed with error' ); - this.test.comment( 'Calling create should fail for an anonymous user' ); this.api.assertRaises( function(){ - this.api.histories.create({ current: true }); + this.api.histories.create({ name: 'new' }); }, 403, 'API authentication required for this request', 'create failed with error' ); this.test.comment( 'Calling delete should fail for an anonymous user' ); this.api.assertRaises( function(){ - this.api.histories.delete_( current.id ); + this.api.histories.delete_( historyShow.id ); }, 403, 'API authentication required for this request', 'create failed with error' ); this.test.comment( 'Calling update should fail for an anonymous user' ); this.api.assertRaises( function(){ - this.api.histories.update( current.id, {} ); + this.api.histories.update( historyShow.id, {} ); }, 403, 'API authentication required for this request', 'update failed with error' ); //TODO: need these two in api.js //this.test.comment( 'Calling archive_import should fail for an anonymous user' ); //this.api.assertRaises( function(){ - // this.api.histories.archive_import( current.id, {} ); + // this.api.histories.archive_import( historyShow.id, {} ); //}, 403, 'API authentication required for this request', 'archive_import failed with error' ); //this.test.comment( 'Calling archive_download should fail for an anonymous user' ); //this.api.assertRaises( function(){ - // this.api.histories.archive_download( current.id, {} ); + // this.api.histories.archive_download( historyShow.id, {} ); //}, 403, 'API authentication required for this request', 'archive_download failed with error' ); // test server bad id protection @@ -77,12 +66,6 @@ // ------------------------------------------------------------------------------------------- hdas spaceghost.thenOpen( spaceghost.baseUrl ).waitForSelector( '.history-name' ); -//TODO: can't use this - get a 400 when tools checks for history: 'logged in to manage' -//spaceghost.then( function(){ -// this.api.tools.thenUpload( spaceghost.api.histories.show( 'current' ).id, { -// filepath: '../../test-data/1.sam' -// }); -//}); spaceghost.then( function(){ spaceghost.tools.uploadFile( '../../test-data/1.sam', function( uploadInfo ){ this.test.assert( uploadInfo.hdaElement !== null, "Convenience function produced hda" ); @@ -92,7 +75,7 @@ }); spaceghost.then( function(){ - var current = this.api.histories.show( 'current' ); + var current = this.api.histories.index()[0]; // ------------------------------------------------------------------------------------------- anon allowed this.test.comment( 'anonymous users can index hdas in their current history' ); diff -r 9f63d9632d9d690c2d5e353feac3f83f12db3f78 -r ec989f77c079f7036c7cb8bb303d1e6bae4a4e4d test/casperjs/api-hda-tests.js --- a/test/casperjs/api-hda-tests.js +++ b/test/casperjs/api-hda-tests.js @@ -18,7 +18,7 @@ spaceghost.thenOpen( spaceghost.baseUrl, function(){ this.test.comment( '(logged in as ' + this.user.loggedInAs() + ')' ); - this.api.tools.thenUpload( spaceghost.api.histories.show( 'current' ).id, { + this.api.tools.thenUpload( spaceghost.api.histories.index()[0].id, { filepath: '../../test-data/1.sam' }); }); diff -r 9f63d9632d9d690c2d5e353feac3f83f12db3f78 -r ec989f77c079f7036c7cb8bb303d1e6bae4a4e4d test/casperjs/api-history-permission-tests.js --- a/test/casperjs/api-history-permission-tests.js +++ b/test/casperjs/api-history-permission-tests.js @@ -35,7 +35,7 @@ this.test.comment( 'importable, slug, and published should all be returned by show and initially off' ); // make the current the inaccessible one - inaccessibleHistory = this.api.histories.show( 'current' ); + inaccessibleHistory = this.api.histories.show( this.api.histories.index()[0].id ); this.test.assert( this.hasKeys( inaccessibleHistory, [ 'id', 'name', 'slug', 'importable', 'published' ] ), 'Has the proper keys' ); this.test.assert( inaccessibleHistory.slug === null, @@ -45,7 +45,7 @@ this.test.assert( inaccessibleHistory.published === false, 'initial published is false: ' + inaccessibleHistory.published ); this.api.histories.update( inaccessibleHistory.id, { name: 'inaccessible' }); - inaccessibleHistory = this.api.histories.show( 'current' ); + inaccessibleHistory = this.api.histories.show( inaccessibleHistory.id ); this.test.comment( 'Setting importable to true should create a slug, username_and_slug, and importable === true' ); accessibleHistory = this.api.histories.create({ name: 'accessible' }); @@ -129,7 +129,7 @@ this.test.comment( 'Attempting to copy an accessible hda (default is accessible)' + ' should work from accessible history: ' + history.name ); - returned = this.api.hdas.create( this.api.histories.show( 'current' ).id, { + returned = this.api.hdas.create( this.api.histories.index()[0].id, { source : 'hda', content : hdas[0].id }); @@ -161,7 +161,7 @@ this.test.comment( 'Attempting to copy an accessible hda (default is accessible)' + ' from an inaccessible history should fail for: ' + history.name ); this.api.assertRaises( function(){ - var returned = this.api.hdas.create( this.api.histories.show( 'current' ).id, { + var returned = this.api.hdas.create( this.api.histories.index()[0].id, { source : 'hda', content : hdas[0].id }); @@ -181,10 +181,6 @@ this.api.assertRaises( function(){ this.api.histories.delete_( history.id ); }, 403, 'History is not owned by the current user', 'delete failed with error' ); - this.test.comment( 'set_as_current should fail for history: ' + history.name ); - this.api.assertRaises( function(){ - this.api.histories.set_as_current( history.id ); - }, 403, 'History is not owned by the current user', 'set_as_current failed with error' ); this.test.comment( 'hda updating should fail for history: ' + history.name ); this.api.assertRaises( function(){ diff -r 9f63d9632d9d690c2d5e353feac3f83f12db3f78 -r ec989f77c079f7036c7cb8bb303d1e6bae4a4e4d test/casperjs/api-history-tests.js --- a/test/casperjs/api-history-tests.js +++ b/test/casperjs/api-history-tests.js @@ -67,19 +67,13 @@ this.test.assert( this.api.histories.show( this.api.histories.index()[0].id ).id === firstHistory.id, 'combining function calls works' ); - this.test.comment( 'Calling show with "current" should return the current history' ); - this.test.assert( this.api.histories.show( 'current' ).id === historyShow.id, 'current returned same id' ); - - // ------------------------------------------------------------------------------------------- CREATE - this.test.comment( 'Calling create should create a new history and allow setting the name and making it current' ); + this.test.comment( 'Calling create should create a new history and allow setting the name' ); var newHistoryName = 'Created History', - createdHistory = this.api.histories.create({ name: newHistoryName, current: true }); + createdHistory = this.api.histories.create({ name: newHistoryName }); //this.debug( 'returned from create:\n' + this.jsonStr( createdHistory ) ); this.test.assert( createdHistory.name === newHistoryName, "Name of created history (from create) is correct: " + createdHistory.name ); - this.test.assert( this.api.histories.show( 'current' ).id === createdHistory.id, - "was made current" ); // check the index var newFirstHistory = this.api.histories.index()[0]; @@ -123,20 +117,9 @@ this.test.assert( newFirstHistory.id === createdHistory.id, "Id of last history (from index) DOES appear after undeletion: " + newFirstHistory.id ); - //TODO: show, deleted flag //TODO: delete, purge flag - - // ------------------------------------------------------------------------------------------- set_as_current - this.test.comment( 'calling set_as_current on a non-current history will make it current' ); - this.test.assert( this.api.histories.show( 'current' ).id !== historyShow.id, historyShow.id + ' is not current' ); - var returned = this.api.histories.set_as_current( historyShow.id ); - this.debug( this.jsonStr( returned ) ); - this.test.assert( this.api.histories.show( 'current' ).id === historyShow.id, 'made current' ); - this.api.histories.set_as_current( newFirstHistory.id ); - - // ------------------------------------------------------------------------------------------- UPDATE // ........................................................................................... name this.test.comment( 'update should allow changing the name' ); @@ -300,10 +283,6 @@ this.api.assertRaises( function(){ this.api.histories.update( '1234123412341234', {} ); }, 400, 'unable to decode', 'Bad Request with invalid id: update' ); - spaceghost.test.comment( 'A bad id should throw an error when using set_as_current' ); - this.api.assertRaises( function(){ - this.api.histories.set_as_current( '1234123412341234' ); - }, 400, 'unable to decode', 'Bad Request with invalid id: set_as_current' ); spaceghost.test.comment( 'A bad id should throw an error when using delete' ); this.api.assertRaises( function(){ this.api.histories.delete_( '1234123412341234' ); diff -r 9f63d9632d9d690c2d5e353feac3f83f12db3f78 -r ec989f77c079f7036c7cb8bb303d1e6bae4a4e4d test/casperjs/api-workflow-tests.js --- a/test/casperjs/api-workflow-tests.js +++ b/test/casperjs/api-workflow-tests.js @@ -17,7 +17,7 @@ spaceghost.user.loginOrRegisterUser( email, password ); // =================================================================== TESTS -var workflowJSONFilepath = 'test-data/Bed_interval_lengths.ga', +var workflowJSONFilepath = 'test-data/simple_test.ga', workflowModelClass = 'StoredWorkflow', workflowSummaryKeys = [ 'id', 'model_class', 'name', 'published', 'tags', 'url' @@ -28,7 +28,7 @@ stepKeys = [ 'id', 'input_steps', 'tool_id', 'type' ], - simpleBedFilepath = 'test-data/simple.bed', + simpleBedFilepath = '../../test-data/2.bed', uploadedFile = null, workflowCreateKeys = [ 'history', 'outputs' ]; @@ -105,13 +105,9 @@ this.test.comment( 'inputs from show should be an object (and, in this case, empty)' ); var inputs = workflowShow.inputs; - //this.debug( 'inputs:\n' + this.jsonStr( inputs ) ); + this.debug( 'inputs:\n' + this.jsonStr( inputs ) ); this.test.assert( utils.isObject( workflowShow.inputs ), "inputs is an object" ); - //for( var inputKey in inputs ){ - // if( inputs.hasOwnProperty( inputKey ) ){ - // } - //} - this.test.assert( this.countKeys( workflowShow.inputs ) === 0, "inputs is empty" ); + this.test.assert( this.countKeys( workflowShow.inputs ) !== 0, "inputs has keys" ); this.test.comment( 'steps from show should be an object containing each tool defined as a step' ); var steps = workflowShow.steps; @@ -141,17 +137,14 @@ this.test.assert( this.hasKeys( step.input_steps, [ 'input' ] ), "input_steps has the proper keys" ); } - this.test.assert( step.type === 'tool', - "step type is a tool: " + step.type ); - - // check for tools in this wf with the api - this.test.assert( utils.isString( step.tool_id ), - "step tool_id is a string: " + step.tool_id ); - var tool_used = this.api.tools.show( step.tool_id ); - //this.debug( this.jsonStr( tool_used ) ) - this.test.assert( this.countKeys( step.input_steps ) !== 0, "found tool in api.tools for: " + step.tool_id ); - - // trace the path through input_steps, source_steps + if( step.type === 'tool' ){ + // check for tools in this wf with the api + this.test.assert( utils.isString( step.tool_id ), + "step tool_id is a string: " + step.tool_id ); + var tool_used = this.api.tools.show( step.tool_id.replace( / /g, '+' ) ); + this.debug( this.jsonStr( tool_used ) ); + this.test.assert( this.countKeys( tool_used ) !== 0, "found tool in api.tools for: " + step.tool_id ); + } } } @@ -181,7 +174,7 @@ var step = firstWorkflow.steps[ stepKey ]; if( this.countKeys( step.input_steps ) === 0 ){ input_step = stepKey; - this.debug( 'input step: ' + this.jsonStr( step ) ) + this.debug( 'input step: ' + this.jsonStr( step ) ); break; } } diff -r 9f63d9632d9d690c2d5e353feac3f83f12db3f78 -r ec989f77c079f7036c7cb8bb303d1e6bae4a4e4d test/casperjs/casperjs_runner.py --- a/test/casperjs/casperjs_runner.py +++ b/test/casperjs/casperjs_runner.py @@ -382,7 +382,7 @@ """ self.run_js_script( 'history-panel-tests.js' ) - def test_10_anonymous_histories( self ): + def test_10_history_options( self ): """Test history options button. """ self.run_js_script( 'history-options-tests.js' ) @@ -425,7 +425,7 @@ """ self.run_js_script( 'api-anon-history-tests.js' ) - def test_04_anon_history_api( self ): + def test_04_anon_history_permissions_api( self ): """Test API permissions for importable, published histories using anonymous user. """ self.run_js_script( 'api-anon-history-permission-tests.js' ) diff -r 9f63d9632d9d690c2d5e353feac3f83f12db3f78 -r ec989f77c079f7036c7cb8bb303d1e6bae4a4e4d test/casperjs/modules/api.js --- a/test/casperjs/modules/api.js +++ b/test/casperjs/modules/api.js @@ -215,7 +215,6 @@ delete_ : 'api/histories/%s', undelete: 'api/histories/deleted/%s/undelete', update : 'api/histories/%s', - set_as_current : 'api/histories/%s/set_as_current' }; HistoriesAPI.prototype.index = function index( deleted ){ @@ -282,15 +281,6 @@ }); }; -HistoriesAPI.prototype.set_as_current = function set_as_current( id ){ - this.api.spaceghost.info( 'histories.set_as_current: ' + id ); - id = this.api.ensureId( id ); - - return this.api._ajax( utils.format( this.urlTpls.set_as_current, id ), { - type : 'PUT' - }); -}; - // =================================================================== HDAS var HDAAPI = function HDAAPI( api ){ diff -r 9f63d9632d9d690c2d5e353feac3f83f12db3f78 -r ec989f77c079f7036c7cb8bb303d1e6bae4a4e4d test/casperjs/spaceghost.js --- a/test/casperjs/spaceghost.js +++ b/test/casperjs/spaceghost.js @@ -34,6 +34,7 @@ // ------------------------------------------------------------------- modules var require = patchRequire( require ), Casper = require( 'casper' ).Casper, + system = require( 'system' ), fs = require( 'fs' ), utils = require( 'utils' ); @@ -1022,7 +1023,7 @@ */ SpaceGhost.prototype.stderr = function( msg ){ if( msg.trim() ){ - fs.write( '/dev/stderr', msg + '\n', 'w' ); + system.stderr.writeLine( msg ); } }; diff -r 9f63d9632d9d690c2d5e353feac3f83f12db3f78 -r ec989f77c079f7036c7cb8bb303d1e6bae4a4e4d test/casperjs/test-data/simple_test.ga --- /dev/null +++ b/test/casperjs/test-data/simple_test.ga @@ -0,0 +1,96 @@ +{ + "a_galaxy_workflow": "true", + "annotation": "", + "format-version": "0.1", + "name": "simple_test", + "steps": { + "0": { + "annotation": "", + "id": 0, + "input_connections": {}, + "inputs": [ + { + "description": "", + "name": "Input Dataset" + } + ], + "name": "Input dataset", + "outputs": [], + "position": { + "left": 200, + "top": 231 + }, + "tool_errors": null, + "tool_id": null, + "tool_state": "{\"name\": \"Input Dataset\"}", + "tool_version": null, + "type": "data_input", + "user_outputs": [] + }, + "1": { + "annotation": "", + "id": 1, + "input_connections": { + "input": { + "id": 0, + "output_name": "output" + } + }, + "inputs": [], + "name": "Select first", + "outputs": [ + { + "name": "out_file1", + "type": "input" + } + ], + "position": { + "left": 409, + "top": 365 + }, + "post_job_actions": { + "HideDatasetActionout_file1": { + "action_arguments": {}, + "action_type": "HideDatasetAction", + "output_name": "out_file1" + } + }, + "tool_errors": null, + "tool_id": "Show beginning1", + "tool_state": "{\"__page__\": 0, \"input\": \"null\", \"__rerun_remap_job_id__\": null, \"lineNum\": \"\\\"10\\\"\"}", + "tool_version": "1.0.0", + "type": "tool", + "user_outputs": [] + }, + "2": { + "annotation": "", + "id": 2, + "input_connections": { + "input": { + "id": 1, + "output_name": "out_file1" + } + }, + "inputs": [], + "name": "Select random lines", + "outputs": [ + { + "name": "out_file1", + "type": "input" + } + ], + "position": { + "left": 609.5, + "top": 234 + }, + "post_job_actions": {}, + "tool_errors": null, + "tool_id": "random_lines1", + "tool_state": "{\"input\": \"null\", \"seed_source\": \"{\\\"__current_case__\\\": 0, \\\"seed_source_selector\\\": \\\"no_seed\\\"}\", \"__rerun_remap_job_id__\": null, \"num_lines\": \"\\\"5\\\"\", \"__page__\": 0}", + "tool_version": "2.0.1", + "type": "tool", + "user_outputs": [] + } + }, + "uuid": "675b4aa8-c885-46d3-b63a-3c52b3bec8c4" +} \ No newline at end of file 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