diff --git a/.ci/flake8_lint_include_list.txt b/.ci/flake8_lint_include_list.txt index 284f897c7560..6a5c6916e438 100644 --- a/.ci/flake8_lint_include_list.txt +++ b/.ci/flake8_lint_include_list.txt @@ -5,7 +5,6 @@ cron/cleanup_datasets.py cron/parse_builds_3_sites.py cron/parse_builds.py doc/parse_gx_xsd.py -doc/patch.py lib/galaxy/actions/ lib/galaxy/auth/ lib/galaxy/config.py diff --git a/.gitignore b/.gitignore index 928136f522c6..a32c10efd74b 100644 --- a/.gitignore +++ b/.gitignore @@ -93,7 +93,7 @@ tool-data/genome/* tool-data/*.sample tool-data/testtoolshed.g2.bx.psu.edu/ tool-data/toolshed.g2.bx.psu.edu/ -tool-data/**/*.fa +tool-data/**/*.fa # Test output test-data-cache @@ -135,4 +135,3 @@ doc/source/dev/schema.rst .DS_Store *.rej *~ -.idea/ diff --git a/client/galaxy/scripts/apps/analysis.js b/client/galaxy/scripts/apps/analysis.js index 34d8adb7edf8..e08dae433e78 100644 --- a/client/galaxy/scripts/apps/analysis.js +++ b/client/galaxy/scripts/apps/analysis.js @@ -9,6 +9,8 @@ var jQuery = require( 'jquery' ), UserPreferences = require( 'mvc/user/user-preferences' ), CustomBuilds = require( 'mvc/user/user-custom-builds' ), Tours = require( 'mvc/tours' ), + GridView = require( 'mvc/grid/grid-view' ), + PageList = require( 'mvc/page/page-list' ), Workflows = require( 'mvc/workflow/workflow' ), WorkflowsConfigureMenu = require( 'mvc/workflow/workflow-configure-menu' ); @@ -80,6 +82,8 @@ window.app = function app( options, bootstrapped ){ '(/)user(/)' : 'show_user', '(/)user(/)(:form_id)' : 'show_user_form', '(/)workflow(/)' : 'show_workflows', + '(/)pages(/)(:action_id)' : 'show_pages', + '(/)datasets(/)(:action_id)' : 'show_datasets', '(/)workflow/configure_menu(/)' : 'show_configure_menu', '(/)custom_builds' : 'show_custom_builds' }, @@ -115,6 +119,18 @@ window.app = function app( options, bootstrapped ){ this.page.display( new UserPreferences.Forms( { form_id: form_id, user_id: Galaxy.params.id } ) ); }, + show_datasets : function() { + this.page.display( new GridView( { url_base: Galaxy.root + 'dataset/list', dict_format: true } ) ); + }, + + show_pages : function( action_id ) { + if ( action_id == 'list' ) { + this.page.display( new PageList.View() ); + } else { + this.page.display( new GridView( { url_base: Galaxy.root + 'page/list_published', dict_format: true } ) ); + } + }, + show_workflows : function(){ this.page.display( new Workflows.View() ); }, diff --git a/client/galaxy/scripts/layout/menu.js b/client/galaxy/scripts/layout/menu.js index f791fc29b8f7..db22975d30f8 100644 --- a/client/galaxy/scripts/layout/menu.js +++ b/client/galaxy/scripts/layout/menu.js @@ -65,7 +65,7 @@ var Collection = Backbone.Collection.extend({ url : 'visualization/list_published' },{ title : _l('Pages'), - url : 'page/list_published' + url : 'pages/list_published' }] }); @@ -122,13 +122,21 @@ var Collection = Backbone.Collection.extend({ $.each(webhooks.models, function(index, model) { var webhook = model.toJSON(); if (webhook.activate) { - self.add({ + var obj = { id : webhook.name, icon : webhook.config.icon, url : webhook.config.url, tooltip : webhook.config.tooltip, onclick : webhook.config.function && new Function(webhook.config.function), - }); + }; + + // Galaxy.page is undefined for data libraries, workflows pages + if( Galaxy.page ) { + Galaxy.page.masthead.collection.add(obj); + } + else if( Galaxy.masthead ) { + Galaxy.masthead.collection.add(obj); + } } }); }); @@ -271,11 +279,11 @@ var Collection = Backbone.Collection.extend({ target : 'galaxy_main' },{ title : _l('Saved Datasets'), - url : 'dataset/list', - target : 'galaxy_main' + url : 'datasets/list', + target : '_top' },{ title : _l('Saved Pages'), - url : 'page/list', + url : 'pages/list', target : '_top' }] }; diff --git a/client/galaxy/scripts/mvc/collection/collection-view.js b/client/galaxy/scripts/mvc/collection/collection-view.js index d2273177b8db..6ff6e6a27020 100644 --- a/client/galaxy/scripts/mvc/collection/collection-view.js +++ b/client/galaxy/scripts/mvc/collection/collection-view.js @@ -45,6 +45,7 @@ var CollectionView = _super.extend( this.parentName = attributes.parentName; /** foldout or drilldown */ this.foldoutStyle = attributes.foldoutStyle || 'foldout'; + this.downloadUrl = this.model.attributes.url + '/download'; }, _queueNewRender : function( $newRender, speed ) { @@ -171,7 +172,14 @@ CollectionView.prototype.templates = (function(){ '', '
', - '' + + '
', + '', + '', + '', + '
', + '', ], 'collection' ); return _.extend( _.clone( _super.prototype.templates ), { diff --git a/client/galaxy/scripts/mvc/dataset/dataset-li.js b/client/galaxy/scripts/mvc/dataset/dataset-li.js index 30f4a8cec3d3..857482690683 100644 --- a/client/galaxy/scripts/mvc/dataset/dataset-li.js +++ b/client/galaxy/scripts/mvc/dataset/dataset-li.js @@ -307,7 +307,7 @@ var DatasetListItemView = _super.extend( _renderNametags : function(){ var tpl = _.template([ - '<% _.each(_.uniq(tags), function(tag){ %>', + '<% _.each(_.sortBy(_.uniq(tags), function(x) { return x }), function(tag){ %>', '<% if (tag.indexOf("name:") == 0){ %>', '<%- tag.slice(5) %>', '<% } %>', diff --git a/client/galaxy/scripts/mvc/form/form-input.js b/client/galaxy/scripts/mvc/form/form-input.js index c773e09b80b2..9721c9b59057 100644 --- a/client/galaxy/scripts/mvc/form/form-input.js +++ b/client/galaxy/scripts/mvc/form/form-input.js @@ -11,7 +11,8 @@ define([], function() { text_enable : this.app_options.text_enable || 'Enable', text_disable : this.app_options.text_disable || 'Disable', cls_enable : this.app_options.cls_enable || 'fa fa-caret-square-o-down', - cls_disable : this.app_options.cls_disable || 'fa fa-caret-square-o-up' + cls_disable : this.app_options.cls_disable || 'fa fa-caret-square-o-up', + always_refresh : this.app_options.always_refresh }).set( options ); // set element and link components @@ -44,6 +45,11 @@ define([], function() { app.trigger && app.trigger( 'change' ); self.render(); }); + + // hide error on value change + if ( this.field.model && !this.model.get( 'always_refresh' ) ) { + this.listenTo( this.field.model, 'change:value', function() { self.reset() } ); + } }, /** Set backdrop for input element */ diff --git a/client/galaxy/scripts/mvc/grid/grid-template.js b/client/galaxy/scripts/mvc/grid/grid-template.js index b2d2662cdc88..6a973ae291da 100644 --- a/client/galaxy/scripts/mvc/grid/grid-template.js +++ b/client/galaxy/scripts/mvc/grid/grid-template.js @@ -215,7 +215,7 @@ return { } return tmpl; }, - + // template footer: function(options) { @@ -304,7 +304,7 @@ return { '' + '' + '' + - 'For selected ' + options.get_class_plural + ': '; + 'For selected items: '; // configure buttons for operations for (i in options.operations) { diff --git a/client/galaxy/scripts/mvc/grid/grid-view.js b/client/galaxy/scripts/mvc/grid/grid-view.js index 20a7a3f99d57..82c4443adf93 100644 --- a/client/galaxy/scripts/mvc/grid/grid-view.js +++ b/client/galaxy/scripts/mvc/grid/grid-view.js @@ -4,10 +4,11 @@ jQuery.ajaxSettings.traditional = true; // dependencies define([ + 'utils/utils', 'mvc/grid/grid-model', 'mvc/grid/grid-template', "mvc/ui/popup-menu" -], function(GridModel, Templates, PopupMenu) { +], function(Utils, GridModel, Templates, PopupMenu) { // grid view return Backbone.View.extend({ @@ -18,8 +19,36 @@ return Backbone.View.extend({ // Initialize initialize: function(grid_config) { + this.dict_format = grid_config.dict_format; + var self = this; + window.add_tag_to_grid_filter = function( tag_name, tag_value ){ + // Put tag name and value together. + var tag = tag_name + ( tag_value !== undefined && tag_value !== "" ? ":" + tag_value : "" ); + var advanced_search = $( '#advanced-search').is(":visible" ); + if( !advanced_search ){ + $('#standard-search').slideToggle('fast'); + $('#advanced-search').slideToggle('fast'); + } + self.add_filter_condition( "tags", tag ); + }; + // set element - this.setElement('#grid-container'); + if ( this.dict_format ) { + this.setElement('
'); + if ( grid_config.url_base && !grid_config.items ) { + Utils.get({ + url: grid_config.url_base, + success: function( response ) { + self.init_grid( response ); + } + }); + } else { + this.init_grid(grid_config); + } + } else { + this.setElement('#grid-container'); + this.init_grid(grid_config); + } // fix padding if (grid_config.use_panels) { @@ -28,9 +57,6 @@ return Backbone.View.extend({ overflow : 'auto' }); } - - // initialize controls - this.init_grid(grid_config); }, // refresh frames @@ -545,7 +571,7 @@ return Backbone.View.extend({ }); // Do operation. If operation cannot be performed asynchronously, redirect to location. - if (this.grid.can_async_op(operation)) { + if (this.grid.can_async_op(operation) || this.dict_format) { this.update_grid(); } else { this.go_to(target, href); @@ -562,7 +588,7 @@ return Backbone.View.extend({ } // refresh grid - if (this.grid.get('async')) { + if (this.grid.get('async') || this.dict_format) { this.update_grid(); } else { this.go_to(target, href); @@ -630,7 +656,7 @@ return Backbone.View.extend({ var insert = self.grid.get('insert'); // request new configuration - var json = $.parseJSON(response_text); + var json = self.dict_format ? response_text : $.parseJSON(response_text); // update json.embedded = embedded; diff --git a/client/galaxy/scripts/mvc/history/hda-li.js b/client/galaxy/scripts/mvc/history/hda-li.js index 4d566fcc3f5c..8d84d7048752 100644 --- a/client/galaxy/scripts/mvc/history/hda-li.js +++ b/client/galaxy/scripts/mvc/history/hda-li.js @@ -16,7 +16,7 @@ var _super = DATASET_LI.DatasetListItemView; var HDAListItemView = _super.extend( /** @lends HDAListItemView.prototype */{ - className : _super.prototype.className + " history-content", + className : _super.prototype.className + " history-content", initialize : function( attributes, options ){ _super.prototype.initialize.call( this, attributes, options ); @@ -45,7 +45,7 @@ HDAListItemView.prototype.templates = (function(){ '
', '
', '', - '<% _.each(dataset.tags, function(tag){ %>', + '<% _.each(_.sortBy(_.uniq(dataset.tags), function(x) { return x }), function(tag){ %>', '<% if (tag.indexOf("name:") == 0){ %>', '<%- tag.slice(5) %>', '<% } %>', diff --git a/client/galaxy/scripts/mvc/history/hdca-li.js b/client/galaxy/scripts/mvc/history/hdca-li.js index 252123b3993b..7cc93b2e1f76 100644 --- a/client/galaxy/scripts/mvc/history/hdca-li.js +++ b/client/galaxy/scripts/mvc/history/hdca-li.js @@ -85,7 +85,7 @@ HDCAListItemView.prototype.templates = (function(){ '', '
', '', - '<% _.each(_.uniq(collection.tags), function(tag){ %>', + '<% _.each(_.sortBy(_.uniq(collection.tags), function(x) { return x }), function(tag){ %>', '<% if (tag.indexOf("name:") == 0){ %>', '<%- tag.slice(5) %>', '<% } %>', diff --git a/client/galaxy/scripts/mvc/page/page-list.js b/client/galaxy/scripts/mvc/page/page-list.js new file mode 100644 index 000000000000..8bec1a2bc854 --- /dev/null +++ b/client/galaxy/scripts/mvc/page/page-list.js @@ -0,0 +1,56 @@ +/** This class renders the page list. */ +define( [ 'utils/utils', 'mvc/grid/grid-view' ], function( Utils, GridView ) { + var View = Backbone.View.extend({ + initialize: function( options ) { + var self = this; + this.setElement( $( '
' ) ); + this.model = new Backbone.Model(); + Utils.get({ + url : Galaxy.root + 'page/list', + success : function( response ) { + response[ 'dict_format' ] = true; + self.model.set( response ); + self.render(); + } + }); + }, + + render: function() { + var grid = new GridView( this.model.attributes ); + this.$el.empty().append( grid.$el ); + this.$el.append( this._templateShared() ); + }, + + _templateShared: function() { + var $tmpl = $( '
' + + '

Pages shared with you by others

' + + '
' ); + var options = this.model.attributes; + if ( options.shared_by_others && options.shared_by_others.length > 0 ) { + var $table = $( '' + + '' + + '' + + '' + + '' + + '
TitleOwner
' ); + _.each( options.shared_by_others, function( page, index ) { + var display_url = Galaxy.root + 'page/display_by_username_and_slug?username=' + page.username + '&slug=' + page.slug; + $table.append( '' + + '' + + '' + _.escape( page.title ) + '' + + '' + + '' + _.escape( page.username ) + '' + + '' ); + }); + $tmpl.append( $table ); + } else { + $tmpl.append( 'No pages have been shared with you.' ); + } + return $tmpl; + } + }); + + return { + View: View + } +}); \ No newline at end of file diff --git a/client/galaxy/scripts/mvc/tool/tool-form-base.js b/client/galaxy/scripts/mvc/tool/tool-form-base.js index 6e5fa18b3a93..8e8733c4456e 100644 --- a/client/galaxy/scripts/mvc/tool/tool-form-base.js +++ b/client/galaxy/scripts/mvc/tool/tool-form-base.js @@ -243,6 +243,22 @@ define( [ 'utils/utils', 'utils/deferred', 'mvc/ui/ui-misc', 'mvc/form/form-view }); } + // add tool menu webhooks + $.getJSON('/api/webhooks/tool-menu/all', function(webhooks) { + _.each(webhooks, function(webhook) { + if (webhook.activate && webhook.config.function) { + menu_button.addMenu({ + icon : webhook.config.icon, + title : webhook.config.title, + onclick : function() { + var func = new Function('options', webhook.config.function); + func(options); + } + }); + } + }); + }); + return { menu : menu_button, versions : versions_button diff --git a/client/galaxy/scripts/mvc/tool/tool-form-composite.js b/client/galaxy/scripts/mvc/tool/tool-form-composite.js index 7ee5b3f6a928..d67406a839cf 100644 --- a/client/galaxy/scripts/mvc/tool/tool-form-composite.js +++ b/client/galaxy/scripts/mvc/tool/tool-form-composite.js @@ -457,7 +457,9 @@ define([ 'utils/utils', 'utils/deferred', 'mvc/ui/ui-misc', 'mvc/form/form-view' if ($.isArray( response ) && response.length > 0) { self.$el.append( $( '
', { id: 'webhook-view' } ) ); var WebhookApp = new Webhooks.WebhookView({ - urlRoot: Galaxy.root + 'api/webhooks/workflow' + urlRoot: Galaxy.root + 'api/webhooks/workflow', + toolId: job_def.tool_id, + toolVersion: job_def.tool_version, }); } diff --git a/client/galaxy/scripts/mvc/tool/tool-form.js b/client/galaxy/scripts/mvc/tool/tool-form.js index f0b913de1553..7a10c5eba74f 100644 --- a/client/galaxy/scripts/mvc/tool/tool-form.js +++ b/client/galaxy/scripts/mvc/tool/tool-form.js @@ -110,7 +110,8 @@ define([ 'utils/utils', 'mvc/ui/ui-misc', 'mvc/ui/ui-modal', 'mvc/tool/tool-form if ( response.jobs && response.jobs.length > 0 ) { self.$el.append( $( '
', { id: 'webhook-view' } ) ); var WebhookApp = new Webhooks.WebhookView({ - urlRoot: Galaxy.root + 'api/webhooks/tool' + urlRoot: Galaxy.root + 'api/webhooks/tool', + toolId: job_def.tool_id }); } parent.Galaxy && parent.Galaxy.currHistoryPanel && parent.Galaxy.currHistoryPanel.refreshContents(); diff --git a/client/galaxy/scripts/mvc/ui/ui-slider.js b/client/galaxy/scripts/mvc/ui/ui-slider.js index abb3abc28c21..d09baf4b5551 100644 --- a/client/galaxy/scripts/mvc/ui/ui-slider.js +++ b/client/galaxy/scripts/mvc/ui/ui-slider.js @@ -1,105 +1,107 @@ define([ 'utils/utils' ], function( Utils ) { -var View = Backbone.View.extend({ - initialize : function( options ) { - var self = this; - this.options = Utils.merge( options, { - id : Utils.uid(), - min : null, - max : null, - step : null, - precise : false, - split : 10000 - } ); + var View = Backbone.View.extend({ + initialize : function( options ) { + var self = this; + this.model = options && options.model || new Backbone.Model({ + id : Utils.uid(), + min : null, + max : null, + step : null, + precise : false, + split : 10000, + value : null, + onchange : function(){} + }).set( options ); - // create new element - this.setElement( this._template( this.options ) ); + // create new element + this.setElement( this._template() ); + this.$el.attr( 'id', this.model.id ); + this.$text = this.$( '.ui-form-slider-text' ); + this.$slider = this.$( '.ui-form-slider-element' ); - // determine wether to use the slider - this.useslider = this.options.max !== null && this.options.min !== null && this.options.max > this.options.min; - - // set default step size - if ( this.options.step === null ) { - this.options.step = 1.0; - if ( this.options.precise && this.useslider ) { - this.options.step = ( this.options.max - this.options.min ) / this.options.split; - } - } - - // create slider if min and max are defined properly - if ( this.useslider ) { - this.$slider = this.$( '#slider' ); - this.$slider.slider( this.options ); - this.$slider.on( 'slide', function ( event, ui ) { - self.value( ui.value ); + // add text field event + var pressed = []; + this.$text.on( 'change', function () { + self.value( $( this ).val() ); + }).on( 'keyup', function( e ) { + pressed[e.which] = false; + }).on( 'keydown', function ( e ) { + var v = e.which; + pressed[ v ] = true; + if ( self.model.get( 'is_workflow' ) && pressed[ 16 ] && v == 52 ) { + self.value( '$' ); + event.preventDefault(); + } else if (!( v == 8 || v == 9 || v == 13 || v == 37 || v == 39 || ( v >= 48 && v <= 57 && !pressed[ 16 ] ) || ( v >= 96 && v <= 105 ) + || ( ( v == 190 || v == 110 ) && $( this ).val().indexOf( '.' ) == -1 && self.model.get( 'precise' ) ) + || ( ( v == 189 || v == 109 ) && $( this ).val().indexOf( '-' ) == -1 ) + || self._isParameter( $( this ).val() ) + || pressed[ 91 ] || pressed[ 17 ] ) ) { + event.preventDefault(); + } }); - } else { - this.$( '.ui-form-slider-text' ).css( 'width', '100%' ); - } - // link text input field - this.$text = this.$( '#text' ); + // build slider, cannot be rebuild in render + var opts = this.model.attributes; + this.has_slider = opts.max !== null && opts.min !== null && opts.max > opts.min; + var step = opts.step; + if ( !step ) { + if ( opts.precise && this.has_slider ) { + step = ( opts.max - opts.min ) / opts.split; + } else { + step = 1.0; + } + } + if ( this.has_slider ) { + this.$text.addClass( 'ui-form-slider-left' ); + this.$slider.slider( { min: opts.min, max: opts.max, step: step } ) + .on( 'slide', function ( event, ui ) { self.value( ui.value ) } ); + } else { + this.$slider.hide(); + } - // set initial value - this.options.value !== undefined && ( this.value( this.options.value ) ); + // add listeners + this.listenTo( this.model, 'change', this.render, this ); + this.render(); + }, - // add text field event - var pressed = []; - this.$text.on( 'change', function () { - self.value( $( this ).val() ); - }); - this.$text.on( 'keyup', function( e ) { - pressed[e.which] = false; - self.options.onchange && self.options.onchange( $( this ).val() ); - }); - this.$text.on( 'keydown', function ( e ) { - var v = e.which; - pressed[ v ] = true; - if ( self.options.is_workflow && pressed[ 16 ] && v == 52 ) { - self.value( '$' ) - event.preventDefault(); - } else if (!( v == 8 || v == 9 || v == 13 || v == 37 || v == 39 || ( v >= 48 && v <= 57 && !pressed[ 16 ] ) || ( v >= 96 && v <= 105 ) - || ( ( v == 190 || v == 110 ) && $( this ).val().indexOf( '.' ) == -1 && self.options.precise ) - || ( ( v == 189 || v == 109 ) && $( this ).val().indexOf( '-' ) == -1 ) - || self._isParameter( $( this ).val() ) - || pressed[ 91 ] || pressed[ 17 ] ) ) { - event.preventDefault(); - } - }); - }, + render: function() { + var value = this.model.get( 'value' ); + this.has_slider && this.$slider.slider( 'value', value ); + value !== this.$text.val() && this.$text.val( value ); + }, - /** Set and Return the current value - */ - value : function ( new_val ) { - if ( new_val !== undefined ) { - if ( new_val !== null && new_val !== '' && !this._isParameter( new_val ) ) { - isNaN( new_val ) && ( new_val = 0 ); - this.options.max !== null && ( new_val = Math.min( new_val, this.options.max ) ); - this.options.min !== null && ( new_val = Math.max( new_val, this.options.min ) ); + /** Set and return the current value */ + value : function ( new_val ) { + var options = this.model.attributes; + if ( new_val !== undefined ) { + if ( new_val !== null && new_val !== '' && !this._isParameter( new_val ) ) { + isNaN( new_val ) && ( new_val = 0 ); + !options.precise && ( new_val = Math.round( new_val ) ); + options.max !== null && ( new_val = Math.min( new_val, options.max ) ); + options.min !== null && ( new_val = Math.max( new_val, options.min ) ); + } + this.model.set( 'value', new_val ); + this.model.trigger( 'change' ); + options.onchange( new_val ); } - this.$slider && this.$slider.slider( 'value', new_val ); - this.$text.val( new_val ); - this.options.onchange && this.options.onchange( new_val ); - } - return this.$text.val(); - }, + return this.model.get( 'value' ); + }, - /** Return true if the field contains a workflow parameter i.e. $('name') - */ - _isParameter: function( value ) { - return this.options.is_workflow && String( value ).substring( 0, 1 ) === '$'; - }, + /** Return true if the field contains a workflow parameter i.e. $('name') */ + _isParameter: function( value ) { + return this.model.get( 'is_workflow' ) && String( value ).substring( 0, 1 ) === '$'; + }, - /** Slider template - */ - _template: function( options ) { - return '
' + - '' + - '
' + - '
'; - } -}); + /** Slider template */ + _template: function() { + return '
' + + '' + + '
' + + '
'; + } + }); -return { - View : View -}; + return { + View : View + }; }); \ No newline at end of file diff --git a/client/galaxy/scripts/mvc/webhooks.js b/client/galaxy/scripts/mvc/webhooks.js index fe5bdd46b076..de97487a6dad 100644 --- a/client/galaxy/scripts/mvc/webhooks.js +++ b/client/galaxy/scripts/mvc/webhooks.js @@ -18,6 +18,11 @@ define([], function() { initialize: function(options) { var me = this; + var toolId = options.toolId || ''; + var toolVersion = options.toolVersion || ''; + + this.$el.attr('tool_id', toolId); + this.$el.attr('tool_version', toolVersion); this.model = new WebhookModel(); this.model.urlRoot = options.urlRoot; @@ -34,7 +39,7 @@ define([], function() { this.$el.html('
'); if (webhook.styles) $(' - - -<%def name="center_panel()"> - -
-
- - ${h.to_unicode( embedded_grid )} -
-
- diff --git a/test/api/test_dataset_collections.py b/test/api/test_dataset_collections.py index 2327ebfc2d15..567c56eb0939 100644 --- a/test/api/test_dataset_collections.py +++ b/test/api/test_dataset_collections.py @@ -1,7 +1,9 @@ import json +import tarfile from base import api from base.populators import DatasetCollectionPopulator, DatasetPopulator +from six import StringIO class DatasetCollectionApiTestCase( api.ApiTestCase ): @@ -93,6 +95,53 @@ def test_create_list_of_new_pairs( self ): pair_1_element_1 = pair_elements[ 0 ] assert pair_1_element_1[ "element_index" ] == 0 + def test_list_download(self): + dataset_collection = self.dataset_collection_populator.create_list_in_history(self.history_id).json() + returned_datasets = dataset_collection["elements"] + assert len(returned_datasets) == 3, dataset_collection + for element in returned_datasets: + self.dataset_populator.wait_for_dataset(history_id=self.history_id, dataset_id=element['id'], assert_ok=True) + create_response = self._download_dataset_collection(history_id=self.history_id, hdca_id=dataset_collection['id']) + self._assert_status_code_is(create_response, 200) + tar_contents = tarfile.open(fileobj=StringIO(create_response.content)) + namelist = tar_contents.getnames() + assert len(namelist) == 3, "Expected 3 elements in [%s]" % namelist + collection_name = dataset_collection['name'] + for element, zip_path in zip(returned_datasets, namelist): + assert "%s/%s.%s" % (collection_name, element['element_identifier'], element['object']['file_ext']) == zip_path + + def test_pair_download(self): + dataset_collection = self.dataset_collection_populator.create_pair_in_history(self.history_id).json() + returned_datasets = dataset_collection["elements"] + for element in returned_datasets: + self.dataset_populator.wait_for_dataset(history_id=self.history_id, dataset_id=element['id'], assert_ok=True) + hdca_id = dataset_collection['id'] + create_response = self._download_dataset_collection(history_id=self.history_id, hdca_id=hdca_id) + self._assert_status_code_is(create_response, 200) + tar_contents = tarfile.open(fileobj=StringIO(create_response.content)) + namelist = tar_contents.getnames() + assert len(namelist) == 2, "Expected 2 elements in [%s]" % namelist + collection_name = dataset_collection['name'] + for element, zip_path in zip(returned_datasets, namelist): + assert "%s/%s.%s" % (collection_name, element['element_identifier'], element['object']['file_ext']) == zip_path + + def test_list_pair_download(self): + dataset_collection = self.dataset_collection_populator.create_list_of_pairs_in_history(self.history_id).json() + returned_datasets = dataset_collection["elements"] + assert len(returned_datasets) == 1, dataset_collection + list_collection_name = dataset_collection['name'] + pair = returned_datasets[0] + for element in pair['object']['elements']: + self.dataset_populator.wait_for_dataset(history_id=self.history_id, dataset_id=element['id'], assert_ok=True) + create_response = self._download_dataset_collection(history_id=self.history_id, hdca_id=dataset_collection['id']) + self._assert_status_code_is(create_response, 200) + tar_contents = tarfile.open(fileobj=StringIO(create_response.content)) + namelist = tar_contents.getnames() + assert len(namelist) == 2, "Expected 2 elements in [%s]" % namelist + pair_collection_name = pair['element_identifier'] + for element, zip_path in zip(pair['object']['elements'], namelist): + assert "%s/%s/%s.%s" % (list_collection_name, pair_collection_name, element['element_identifier'], element['object']['file_ext']) == zip_path + def test_hda_security( self ): element_identifiers = self.dataset_collection_populator.pair_identifiers( self.history_id ) @@ -128,3 +177,6 @@ def _check_create_response( self, create_response ): dataset_collection = create_response.json() self._assert_has_keys( dataset_collection, "elements", "url", "name", "collection_type" ) return dataset_collection + + def _download_dataset_collection(self, history_id, hdca_id): + return self._get("histories/%s/contents/dataset_collections/%s/download" % (history_id, hdca_id)) diff --git a/test/base/populators.py b/test/base/populators.py index f83386ddadf1..0d26844a1a27 100644 --- a/test/base/populators.py +++ b/test/base/populators.py @@ -220,6 +220,9 @@ def _get( self, route ): def _summarize_history_errors( self, history_id ): self.galaxy_interactor._summarize_history_errors( history_id ) + def wait_for_dataset(self, history_id, dataset_id, assert_ok=False, timeout=DEFAULT_TIMEOUT): + return wait_on_state(lambda: self._get("histories/%s/contents/%s" % (history_id, dataset_id)), assert_ok=assert_ok, timeout=timeout) + class BaseWorkflowPopulator( object ): diff --git a/test/functional/tools/mulled_example_multi_versionless.xml b/test/functional/tools/mulled_example_multi_versionless.xml new file mode 100644 index 000000000000..396526ef39ba --- /dev/null +++ b/test/functional/tools/mulled_example_multi_versionless.xml @@ -0,0 +1,18 @@ + + $out_file1 ; + echo "Moo" >> $out_file1 ; + samtools >> $out_file1 2>&1 ; + echo "Cow" >> $out_file1 ; + ]]> + + samtools + bedtools + + + + + + + + diff --git a/test/functional/tools/samples_tool_conf.xml b/test/functional/tools/samples_tool_conf.xml index d4a9c7e7d765..4197eb61b5ff 100644 --- a/test/functional/tools/samples_tool_conf.xml +++ b/test/functional/tools/samples_tool_conf.xml @@ -135,6 +135,7 @@ + diff --git a/test/functional/webhooks/phdcomics/helper/__init__.py b/test/functional/webhooks/phdcomics/helper/__init__.py index 2e9574ea7900..b6828d2c21ab 100644 --- a/test/functional/webhooks/phdcomics/helper/__init__.py +++ b/test/functional/webhooks/phdcomics/helper/__init__.py @@ -6,7 +6,7 @@ log = logging.getLogger(__name__) -def main(trans, webhook): +def main(trans, webhook, params): error = '' comic_src = '' diff --git a/test/functional/webhooks/trans_object/config/trans_object.yaml b/test/functional/webhooks/trans_object/config/trans_object.yaml index 041f6656349c..67b2bb8097e5 100644 --- a/test/functional/webhooks/trans_object/config/trans_object.yaml +++ b/test/functional/webhooks/trans_object/config/trans_object.yaml @@ -1,5 +1,5 @@ name: trans_object -type: +type: - masthead activate: true @@ -7,6 +7,6 @@ icon: fa-user tooltip: Show Username function: > - $.getJSON(Galaxy.root + "/api/webhooks/trans_object/get_data", function(data) { + $.getJSON(Galaxy.root + "api/webhooks/trans_object/get_data", function(data) { alert('Username: ' + data.username); }); diff --git a/test/functional/webhooks/trans_object/helper/__init__.py b/test/functional/webhooks/trans_object/helper/__init__.py index cbc85282e34c..dafa10e7d62c 100644 --- a/test/functional/webhooks/trans_object/helper/__init__.py +++ b/test/functional/webhooks/trans_object/helper/__init__.py @@ -1,4 +1,4 @@ -def main(trans, webhook): +def main(trans, webhook, params): if trans.user: user = trans.user.username else: diff --git a/test/qunit/tests/ui_tests.html b/test/qunit/tests/ui_tests.html index c0add87b60c7..4d54e521ceb9 100644 --- a/test/qunit/tests/ui_tests.html +++ b/test/qunit/tests/ui_tests.html @@ -3,9 +3,12 @@ test environment is bootstrapped in test-common.js --> + + + - + \ No newline at end of file diff --git a/test/qunit/tests/ui_tests.js b/test/qunit/tests/ui_tests.js index 976dbc8836eb..e6da0a937050 100644 --- a/test/qunit/tests/ui_tests.js +++ b/test/qunit/tests/ui_tests.js @@ -1,6 +1,6 @@ /* global define, QUnit, module, test, ok, equal, deepEqual, notEqual */ -define([ 'test-app', 'mvc/ui/ui-misc', 'mvc/ui/ui-select-content', 'mvc/ui/ui-drilldown', 'mvc/ui/ui-thumbnails', 'mvc/ui/ui-tabs' -], function( testApp, Ui, SelectContent, Drilldown, Thumbnails, Tabs ){ +define([ 'test-app', 'mvc/ui/ui-misc', 'mvc/ui/ui-select-content', 'mvc/ui/ui-drilldown', 'mvc/ui/ui-slider', 'mvc/ui/ui-thumbnails', 'mvc/ui/ui-tabs' +], function( testApp, Ui, SelectContent, Drilldown, Slider, Thumbnails, Tabs ){ 'use strict'; module( 'Ui test', { setup: function() { @@ -581,6 +581,22 @@ define([ 'test-app', 'mvc/ui/ui-misc', 'mvc/ui/ui-select-content', 'mvc/ui/ui-dr ok( label.$el.html() === '_new_title', 'Correct new title' ); } ); + test( 'slider', function() { + var input = new Slider.View( { min: 1, max: 100, value: 10 } ); + $( 'body' ).prepend( input.$el ); + ok( input.$slider.slider( 'value' ) == 10, 'Correct value.' ); + ok( input.value( 1000 ) == 100, 'Correct upper limit.' ); + ok( input.$slider.slider( 'value' ) == 100, 'Correct slider value.' ); + ok( input.$slider.slider( 'option', 'step' ) == 1, 'Correct default step size.' ); + var input1 = new Slider.View( { value: 10 } ); + $( 'body' ).prepend( input1.$el ); + ok( input1.$slider.css( 'display' ) == 'none', 'Slider hidden.' ); + var input2 = new Slider.View( { min: 0, max: 100, value: 10.1, precise: true } ); + $( 'body' ).prepend( input2.$el ); + ok( input2.$slider.slider( 'option', 'step' ) == 0.01, 'Correct float step size.' ); + ok( input2.$slider.slider( 'value' ) == 10.1, 'Correct float slider value.' ); + } ); + test( 'input', function() { var input = new Ui.Input(); $( 'body' ).prepend( input.$el ); diff --git a/test/unit/jobs/conditional_runners_job_conf.xml b/test/unit/jobs/conditional_runners_job_conf.xml new file mode 100644 index 000000000000..38b7c3179fa9 --- /dev/null +++ b/test/unit/jobs/conditional_runners_job_conf.xml @@ -0,0 +1,25 @@ + + + + + + + True + + + False + + + + + + + + + True + + + False + + + diff --git a/test/unit/jobs/test_job_configuration.py b/test/unit/jobs/test_job_configuration.py index ec19701b1584..012022e5e69a 100644 --- a/test/unit/jobs/test_job_configuration.py +++ b/test/unit/jobs/test_job_configuration.py @@ -11,6 +11,7 @@ # there are advantages to testing the documentation/examples. SIMPLE_JOB_CONF = os.path.join( os.path.dirname( __file__ ), "..", "..", "..", "config", "job_conf.xml.sample_basic" ) ADVANCED_JOB_CONF = os.path.join( os.path.dirname( __file__ ), "..", "..", "..", "config", "job_conf.xml.sample_advanced" ) +CONDITIONAL_RUNNER_JOB_CONF = os.path.join( os.path.dirname( __file__ ), "conditional_runners_job_conf.xml" ) class JobConfXmlParserTestCase( unittest.TestCase ): @@ -137,6 +138,30 @@ def test_macro_expansion( self ): for name in ["foo_small", "foo_medium", "foo_large", "foo_longrunning"]: assert self.job_config.destinations[ name ] + def test_conditional_runners( self ): + self.__write_config_from( CONDITIONAL_RUNNER_JOB_CONF ) + runner_ids = [ r[ "id" ] for r in self.job_config.runner_plugins ] + assert "local2" in runner_ids + assert "local3" not in runner_ids + + assert "local2_dest" in self.job_config.destinations + assert "local3_dest" not in self.job_config.destinations + + def test_conditional_runners_from_environ( self ): + self.__write_config_from( CONDITIONAL_RUNNER_JOB_CONF ) + os.environ["LOCAL2_ENABLED"] = "False" + os.environ["LOCAL3_ENABLED"] = "True" + try: + runner_ids = [ r[ "id" ] for r in self.job_config.runner_plugins ] + assert "local2" not in runner_ids + assert "local3" in runner_ids + + assert "local2_dest" not in self.job_config.destinations + assert "local3_dest" in self.job_config.destinations + finally: + del os.environ["LOCAL2_ENABLED"] + del os.environ["LOCAL3_ENABLED"] + # TODO: Add job metrics parsing test. @property diff --git a/test/unit/tools/test_toolbox.py b/test/unit/tools/test_toolbox.py index 0dfb4edd70a5..6a64976ff5ef 100644 --- a/test/unit/tools/test_toolbox.py +++ b/test/unit/tools/test_toolbox.py @@ -11,7 +11,7 @@ from galaxy.model import tool_shed_install from galaxy.model.tool_shed_install import mapping from galaxy.tools import ToolBox -from galaxy.tools.toolbox.cache import ToolCache +from galaxy.tools.cache import ToolCache from galaxy.tools.toolbox.lineages.tool_shed import ToolVersionCache from galaxy.tools.toolbox.watcher import get_tool_conf_watcher from galaxy.webapps.galaxy.config_watchers import ConfigWatchers