Bugfix for updating history dataset collection name.

Thanks to Bjoern for the bug report.

This attribute had been DatasetCollection in earlier versions of this code and the update code was only partially cut-over to use the new location for name (on HistoryDatasetCollectionAssociation).
This commit is contained in:
John Chilton
2014-05-14 05:26:21 -05:00
parent c79e4dcc40
commit 486dc41639
2 changed files with 21 additions and 17 deletions
+2 -14
View File
@@ -2636,20 +2636,8 @@ class DatasetCollection( object, Dictifiable, UsesAnnotations ):
return new_collection
def set_from_dict( self, new_data ):
editable_keys = ( 'name' )
changed = {}
# unknown keys are ignored here
for key in [ k for k in new_data.keys() if k in editable_keys ]:
new_val = new_data[ key ]
old_val = self.__getattribute__( key )
if new_val == old_val:
continue
self.__setattr__( key, new_val )
changed[ key ] = new_val
return changed
# Nothing currently editable in this class.
return {}
class DatasetCollectionInstance( object, HasName ):
+19 -3
View File
@@ -128,12 +128,28 @@ class HistoryContentsApiTestCase( api.ApiTestCase, TestsDatasets ):
dataset_collection = show_response.json()
assert dataset_collection[ "deleted" ]
def __show( self, hda ):
show_response = self._get( "histories/%s/contents/%s" % ( self.history_id, hda[ "id" ] ) )
def test_update_dataset_collection( self ):
payload = self.dataset_collection_populator.create_pair_payload(
self.history_id,
type="dataset_collection"
)
dataset_collection_response = self._post( "histories/%s/contents" % self.history_id, payload )
self._assert_status_code_is( dataset_collection_response, 200 )
hdca = dataset_collection_response.json()
update_url = self._api_url( "histories/%s/contents/dataset_collections/%s" % ( self.history_id, hdca[ "id" ] ), use_key=True )
# Awkward json.dumps required here because of https://trello.com/c/CQwmCeG6
body = json.dumps( dict( name="newnameforpair" ) )
update_response = put_request( update_url, data=body )
self._assert_status_code_is( update_response, 200 )
show_response = self.__show( hdca )
assert str( show_response.json()[ "name" ] ) == "newnameforpair"
def __show( self, contents ):
show_response = self._get( "histories/%s/contents/%ss/%s" % ( self.history_id, contents["history_content_type"], contents[ "id" ] ) )
return show_response
def __count_contents( self, history_id=None, **kwds ):
if history_id == None:
if history_id is None:
history_id = self.history_id
contents_response = self._get( "histories/%s/contents" % history_id, kwds )
return len( contents_response.json() )