1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/01b7b48cc823/ Changeset: 01b7b48cc823 User: carlfeberhard Date: 2013-04-26 14:59:05 Summary: Browser tests: add skeleton for workflow API testing Affected #: 2 files diff -r 3be9ecc2030b096dce14b6c8f91a347c88b39c64 -r 01b7b48cc823a64f9ea9d35c144e9ac12b0d205b test/casperjs/api-workflow-tests.js --- /dev/null +++ b/test/casperjs/api-workflow-tests.js @@ -0,0 +1,101 @@ +/* Utility to load a specific page and output html, page text, or a screenshot + * Optionally wait for some time, text, or dom selector + */ +try { + //...if there's a better way - please let me know, universe + var scriptDir = require( 'system' ).args[3] + // remove the script filename + .replace( /[\w|\.|\-|_]*$/, '' ) + // if given rel. path, prepend the curr dir + .replace( /^(?!\/)/, './' ), + spaceghost = require( scriptDir + 'spaceghost' ).create({ + // script options here (can be overridden by CLI) + //verbose: true, + //logLevel: debug, + scriptDir: scriptDir + }); + +} catch( error ){ + console.debug( error ); + phantom.exit( 1 ); +} +spaceghost.start(); + +// =================================================================== SET UP +var utils = require( 'utils' ); + +var email = spaceghost.user.getRandomEmail(), + password = '123456'; +if( spaceghost.fixtureData.testUser ){ + email = spaceghost.fixtureData.testUser.email; + password = spaceghost.fixtureData.testUser.password; +} +spaceghost.user.loginOrRegisterUser( email, password ); + +function hasKeys( object, keysArray ){ + if( !utils.isObject( object ) ){ return false; } + for( var i=0; i<keysArray.length; i += 1 ){ + if( !object.hasOwnProperty( keysArray[i] ) ){ + spaceghost.debug( 'key not found: ' + keysArray[i] ); + return false; + } + } + return true; +} + +function compareObjs( obj1, where ){ + for( var key in where ){ + if( where.hasOwnProperty( key ) ){ + if( !obj1.hasOwnProperty( key ) ){ return false; } + if( obj1[ key ] !== where[ key ] ){ return false; } + } + } + return true; +} + +function findObject( objectArray, where, start ){ + start = start || 0; + for( var i=start; i<objectArray.length; i += 1 ){ + if( compareObjs( objectArray[i], where ) ){ return objectArray[i]; } + } + return null; +} + +// =================================================================== TESTS +var workflowSummaryKeys = [ + 'id', 'model_class', 'name', 'published', 'tags', 'url' + ], + workflowDetailKeys = workflowSummaryKeys.concat([ + 'inputs', 'steps' + ]); + + +spaceghost.thenOpen( spaceghost.baseUrl ).then( function(){ + + // ------------------------------------------------------------------------------------------- INDEX + this.test.comment( 'index should get a list of workflows' ); + var workflowIndex = this.api.workflows.index(); + this.debug( this.jsonStr( workflowIndex ) ); + this.test.assert( utils.isArray( workflowIndex ), "index returned an array: length " + workflowIndex.length ); + + // need a way to import/create a workflow here for testing + if( workflowIndex.length <= 0 ){ + log.warn( 'No workflows available' ); + return; + } + this.test.assert( workflowIndex.length >= 1, 'Has at least one workflow' ); + + // ------------------------------------------------------------------------------------------- SHOW + this.test.comment( 'show should get detailed data about the workflow with the given id' ); + var workflowShow = this.api.workflows.show( workflowIndex[0].id ); + this.debug( this.jsonStr( workflowShow ) ); + + + // ------------------------------------------------------------------------------------------- CREATE + + // ------------------------------------------------------------------------------------------- MISC +}); + +// =================================================================== +spaceghost.run( function(){ +}); diff -r 3be9ecc2030b096dce14b6c8f91a347c88b39c64 -r 01b7b48cc823a64f9ea9d35c144e9ac12b0d205b test/casperjs/modules/api.js --- a/test/casperjs/modules/api.js +++ b/test/casperjs/modules/api.js @@ -21,6 +21,7 @@ this.histories = new HistoriesAPI( this ); this.hdas = new HDAAPI( this ); this.tools = new ToolsAPI( this ); + this.workflows = new WorkflowsAPI( this ); }; exports.API = API; @@ -318,3 +319,78 @@ // }); //}; +// =================================================================== WORKFLOWS +var WorkflowsAPI = function WorkflowsAPI( api ){ + this.api = api; +}; +WorkflowsAPI.prototype.toString = function toString(){ + return this.api + '.WorkflowsAPI'; +}; + +// ------------------------------------------------------------------- +WorkflowsAPI.prototype.urlTpls = { + index : 'api/workflows', + show : 'api/workflows/%s', + // run a workflow + create : 'api/workflows', + update : 'api/workflows/%s', + + upload : 'api/workflows/upload', // POST + download: 'api/workflows/download/%s' // GET +}; + +WorkflowsAPI.prototype.index = function index(){ + this.api.spaceghost.info( 'workflows.index: ' + [] ); + var data = {}; + + return this.api._ajax( utils.format( this.urlTpls.index ), { + data : data + }); +}; + +WorkflowsAPI.prototype.show = function show( id ){ + this.api.spaceghost.info( 'workflows.show: ' + [ id ] ); + var data = {}; + + id = ( id === 'most_recently_used' )?( id ):( this.api.ensureId( id ) ); + return this.api._ajax( utils.format( this.urlTpls.show, this.api.ensureId( id ) ), { + data : data + }); +}; + +//WorkflowsAPI.prototype.create = function create( payload ){ +// this.api.spaceghost.info( 'workflows.create: ' + [ this.api.spaceghost.jsonStr( payload ) ] ); +// +// // py.payload <-> ajax.data +// payload = this.api.ensureObject( payload ); +// return this.api._ajax( utils.format( this.urlTpls.create ), { +// type : 'POST', +// data : payload +// }); +//}; +// +//WorkflowsAPI.prototype.update = function create( id, payload ){ +// this.api.spaceghost.info( 'workflows.update: ' + [ id, this.api.spaceghost.jsonStr( payload ) ] ); +// +// // py.payload <-> ajax.data +// historyId = this.api.ensureId( historyId ); +// id = this.api.ensureId( id ); +// payload = this.api.ensureObject( payload ); +// url = utils.format( this.urlTpls.update, id ); +// +// return this.api._ajax( url, { +// type : 'PUT', +// data : payload +// }); +//}; + +WorkflowsAPI.prototype.upload = function upload( filepath ){ + this.api.spaceghost.info( 'workflows.show: ' + [ id ] ); + var data = {}; + + id = ( id === 'most_recently_used' )?( id ):( this.api.ensureId( id ) ); + return this.api._ajax( utils.format( this.urlTpls.show, this.api.ensureId( id ) ), { + data : data + }); +}; + 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.