/test/functional/test_metadata_editing.py

https://bitbucket.org/cistrome/cistrome-harvard/ · Python · 57 lines · 46 code · 3 blank · 8 comment · 1 complexity · f986738d2e285d8ed9b1ab261431a6c4 MD5 · raw file

  1. from base.twilltestcase import TwillTestCase
  2. from functional import database_contexts
  3. import galaxy.model
  4. from galaxy.model.orm import (
  5. and_,
  6. desc,
  7. )
  8. class TestMetadataEdit( TwillTestCase ):
  9. def test_00_metadata_edit( self ):
  10. """test_metadata_edit: Testing metadata editing"""
  11. sa_session = database_contexts.galaxy_context
  12. self.logout()
  13. self.login( email='test@bx.psu.edu', username='admin-user' )
  14. admin_user = sa_session.query( galaxy.model.User ) \
  15. .filter( galaxy.model.User.table.c.email == 'test@bx.psu.edu' ) \
  16. .one()
  17. self.new_history( name='Test Metadata Edit' )
  18. history1 = sa_session.query( galaxy.model.History ) \
  19. .filter( and_( galaxy.model.History.table.c.deleted == False,
  20. galaxy.model.History.table.c.user_id == admin_user.id ) ) \
  21. .order_by( desc( galaxy.model.History.table.c.create_time ) ) \
  22. .first()
  23. self.upload_file( '1.bed' )
  24. latest_hda = sa_session.query( galaxy.model.HistoryDatasetAssociation ) \
  25. .order_by( desc( galaxy.model.HistoryDatasetAssociation.table.c.create_time ) ) \
  26. .first()
  27. self.home()
  28. # Due to twill not being able to handle the permissions forms, we'll eliminate
  29. # DefaultHistoryPermissions prior to uploading a dataset so that the permission
  30. # form will not be displayed on ted edit attributes page.
  31. for dp in latest_hda.dataset.actions:
  32. sa_session.delete( dp )
  33. sa_session.flush()
  34. sa_session.refresh( latest_hda.dataset )
  35. self.check_history_for_string( '1.bed' )
  36. self.check_metadata_for_string( '1.bed uploaded file unspecified (\?) chromCol value="1" selected endCol value="3" is_strandCol value="true" checked', hid=str( latest_hda.hid ) )
  37. """test editing attributes"""
  38. self.edit_hda_attribute_info( hda_id=str( latest_hda.id ),
  39. new_name='Testdata',
  40. new_info="Uploaded my file",
  41. new_dbkey='hg16',
  42. new_startcol='6' )
  43. self.check_metadata_for_string( 'Testdata bed Uploaded my file hg16 "bed" selected="yes" "startCol" value="6" selected', hid=str( latest_hda.hid ) )
  44. """test Auto-detecting attributes"""
  45. self.auto_detect_metadata( hda_id=str( latest_hda.id ) )
  46. self.check_metadata_for_string('Testdata bed Uploaded my file hg16 "bed" selected="yes" "startCol" value="2" selected', hid=str( latest_hda.hid ) )
  47. """test converting formats"""
  48. self.convert_format( hda_id=str( latest_hda.id ), target_type='gff' )
  49. self.check_metadata_for_string( '"gff" selected="yes"', hid=str( latest_hda.hid ) )
  50. """test changing data type"""
  51. self.change_datatype( hda_id=str( latest_hda.id ), datatype='gff3' )
  52. self.check_metadata_for_string( 'gff3', hid=str( latest_hda.hid ) )
  53. self.delete_history( id=self.security.encode_id( history1.id ) )
  54. self.logout()