本文整理汇总了Python中galaxy.managers.datasets.DatasetManager.purge方法的典型用法代码示例。如果您正苦于以下问题:Python DatasetManager.purge方法的具体用法?Python DatasetManager.purge怎么用?Python DatasetManager.purge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类galaxy.managers.datasets.DatasetManager
的用法示例。
在下文中一共展示了DatasetManager.purge方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DatasetManagerTestCase
# 需要导入模块: from galaxy.managers.datasets import DatasetManager [as 别名]
# 或者: from galaxy.managers.datasets.DatasetManager import purge [as 别名]
class DatasetManagerTestCase( BaseTestCase ):
def set_up_managers( self ):
super( DatasetManagerTestCase, self ).set_up_managers()
self.dataset_mgr = DatasetManager( self.app )
def test_create( self ):
self.log( "should be able to create a new Dataset" )
dataset1 = self.dataset_mgr.create( self.trans )
self.assertIsInstance( dataset1, model.Dataset )
self.assertEqual( dataset1, self.trans.sa_session.query( model.Dataset ).get( dataset1.id ) )
def test_base( self ):
dataset1 = self.dataset_mgr.create( self.trans )
dataset2 = self.dataset_mgr.create( self.trans )
self.log( "should be able to query" )
datasets = self.trans.sa_session.query( model.Dataset ).all()
self.assertEqual( self.dataset_mgr.list( self.trans ), datasets )
self.assertEqual( self.dataset_mgr.one( self.trans, filters=( model.Dataset.id == dataset1.id ) ), dataset1 )
self.assertEqual( self.dataset_mgr.by_id( self.trans, dataset1.id ), dataset1 )
self.assertEqual( self.dataset_mgr.by_ids( self.trans, [ dataset2.id, dataset1.id ] ), [ dataset2, dataset1 ] )
self.log( "should be able to limit and offset" )
self.assertEqual( self.dataset_mgr.list( self.trans, limit=1 ), datasets[0:1] )
self.assertEqual( self.dataset_mgr.list( self.trans, offset=1 ), datasets[1:] )
self.assertEqual( self.dataset_mgr.list( self.trans, limit=1, offset=1 ), datasets[1:2] )
self.assertEqual( self.dataset_mgr.list( self.trans, limit=0 ), [] )
self.assertEqual( self.dataset_mgr.list( self.trans, offset=3 ), [] )
self.log( "should be able to order" )
self.assertEqual( self.dataset_mgr.list( self.trans, order_by=sqlalchemy.desc( model.Dataset.create_time ) ),
[ dataset2, dataset1 ] )
def test_delete( self ):
item1 = self.dataset_mgr.create( self.trans )
self.log( "should be able to delete and undelete an hda" )
self.assertFalse( item1.deleted )
self.assertEqual( self.dataset_mgr.delete( self.trans, item1 ), item1 )
self.assertTrue( item1.deleted )
self.assertEqual( self.dataset_mgr.undelete( self.trans, item1 ), item1 )
self.assertFalse( item1.deleted )
def test_purge_allowed( self ):
self.trans.app.config.allow_user_dataset_purge = True
item1 = self.dataset_mgr.create( self.trans )
self.log( "should purge an hda if config does allow" )
self.assertFalse( item1.purged )
self.assertEqual( self.dataset_mgr.purge( self.trans, item1 ), item1 )
self.assertTrue( item1.purged )
def test_purge_not_allowed( self ):
self.trans.app.config.allow_user_dataset_purge = False
item1 = self.dataset_mgr.create( self.trans )
self.log( "should raise an error when purging an hda if config does not allow" )
self.assertFalse( item1.purged )
self.assertRaises( exceptions.ConfigDoesNotAllowException, self.dataset_mgr.purge, self.trans, item1 )
self.assertFalse( item1.purged )
##TODO: I'm unclear as to how these work, so I'm kicking this down the road a bit....
#def test_access_permission( self ):
# owner = self.user_mgr.create( self.trans, **user2_data )
# dataset = self.dataset_mgr.create( self.trans )
# # giving one user access permission makes it non-public, removing access for anyone else
# self.dataset_mgr.give_access_permission( self.trans, dataset, owner )
#
# user3 = self.user_mgr.create( self.trans, **user3_data )
# user4 = self.user_mgr.create( self.trans,
# email='[email protected]', username='user4', password=default_password )
#
# self.assertTrue( self.dataset_mgr.has_access_permission( self.trans, dataset, owner ) )
# self.assertFalse( self.dataset_mgr.has_access_permission( self.trans, dataset, user3 ) )
# self.assertFalse( self.dataset_mgr.has_access_permission( self.trans, dataset, user4 ) )
#
# # should be able to progressively add more roles without removing the previous
# self.dataset_mgr.give_access_permission( self.trans, dataset, user3 )
# self.assertTrue( self.dataset_mgr.has_access_permission( self.trans, dataset, user3 ) )
# self.assertTrue( self.dataset_mgr.has_access_permission( self.trans, dataset, owner ) )
# self.assertFalse( self.dataset_mgr.has_access_permission( self.trans, dataset, user4 ) )
#
# #self.assertTrue( self.dataset_mgr.is_accessible( self.trans, dataset, owner ) )
# #self.assertFalse( self.dataset_mgr.is_accessible( self.trans, dataset, non_owner ) )
def test_accessible( self ):
owner = self.user_mgr.create( self.trans, **user2_data )
non_owner = self.user_mgr.create( self.trans, **user3_data )
dataset = self.dataset_mgr.create( self.trans )
self.log( "(by default, dataset permissions are lax) should be accessible to all" )
for user in self.user_mgr.list( self.trans ):
self.assertTrue( self.dataset_mgr.is_accessible( self.trans, dataset, user ) )
示例2: DatasetManagerTestCase
# 需要导入模块: from galaxy.managers.datasets import DatasetManager [as 别名]
# 或者: from galaxy.managers.datasets.DatasetManager import purge [as 别名]
class DatasetManagerTestCase( BaseTestCase ):
def set_up_managers( self ):
super( DatasetManagerTestCase, self ).set_up_managers()
self.dataset_manager = DatasetManager( self.app )
def test_create( self ):
self.log( "should be able to create a new Dataset" )
dataset1 = self.dataset_manager.create()
self.assertIsInstance( dataset1, model.Dataset )
self.assertEqual( dataset1, self.trans.sa_session.query( model.Dataset ).get( dataset1.id ) )
def test_base( self ):
dataset1 = self.dataset_manager.create()
dataset2 = self.dataset_manager.create()
self.log( "should be able to query" )
datasets = self.trans.sa_session.query( model.Dataset ).all()
self.assertEqual( self.dataset_manager.list(), datasets )
self.assertEqual( self.dataset_manager.one( filters=( model.Dataset.id == dataset1.id ) ), dataset1 )
self.assertEqual( self.dataset_manager.by_id( dataset1.id ), dataset1 )
self.assertEqual( self.dataset_manager.by_ids( [ dataset2.id, dataset1.id ] ), [ dataset2, dataset1 ] )
self.log( "should be able to limit and offset" )
self.assertEqual( self.dataset_manager.list( limit=1 ), datasets[0:1] )
self.assertEqual( self.dataset_manager.list( offset=1 ), datasets[1:] )
self.assertEqual( self.dataset_manager.list( limit=1, offset=1 ), datasets[1:2] )
self.assertEqual( self.dataset_manager.list( limit=0 ), [] )
self.assertEqual( self.dataset_manager.list( offset=3 ), [] )
self.log( "should be able to order" )
self.assertEqual( self.dataset_manager.list( order_by=sqlalchemy.desc( model.Dataset.create_time ) ),
[ dataset2, dataset1 ] )
def test_delete( self ):
item1 = self.dataset_manager.create()
self.log( "should be able to delete and undelete a dataset" )
self.assertFalse( item1.deleted )
self.assertEqual( self.dataset_manager.delete( item1 ), item1 )
self.assertTrue( item1.deleted )
self.assertEqual( self.dataset_manager.undelete( item1 ), item1 )
self.assertFalse( item1.deleted )
def test_purge_allowed( self ):
self.trans.app.config.allow_user_dataset_purge = True
item1 = self.dataset_manager.create()
self.log( "should purge a dataset if config does allow" )
self.assertFalse( item1.purged )
self.assertEqual( self.dataset_manager.purge( item1 ), item1 )
self.assertTrue( item1.purged )
self.log( "should delete a dataset when purging" )
self.assertTrue( item1.deleted )
def test_purge_not_allowed( self ):
self.trans.app.config.allow_user_dataset_purge = False
item1 = self.dataset_manager.create()
self.log( "should raise an error when purging a dataset if config does not allow" )
self.assertFalse( item1.purged )
self.assertRaises( exceptions.ConfigDoesNotAllowException, self.dataset_manager.purge, item1 )
self.assertFalse( item1.purged )
def test_create_with_no_permissions( self ):
self.log( "should be able to create a new Dataset without any permissions" )
dataset = self.dataset_manager.create()
permissions = self.dataset_manager.permissions.get( dataset )
self.assertIsInstance( permissions, tuple )
self.assertEqual( len( permissions ), 2 )
manage_permissions, access_permissions = permissions
self.assertEqual( manage_permissions, [] )
self.assertEqual( access_permissions, [] )
user3 = self.user_manager.create( **user3_data )
self.log( "a dataset without permissions shouldn't be manageable to just anyone" )
self.assertFalse( self.dataset_manager.permissions.manage.is_permitted( dataset, user3 ) )
self.log( "a dataset without permissions should be accessible" )
self.assertTrue( self.dataset_manager.permissions.access.is_permitted( dataset, user3 ) )
def test_create_public_dataset( self ):
self.log( "should be able to create a new Dataset and give it some permissions that actually, you know, "
"might work if there's any justice in this universe" )
owner = self.user_manager.create( **user2_data )
owner_private_role = self.user_manager.private_role( owner )
dataset = self.dataset_manager.create( manage_roles=[ owner_private_role ] )
permissions = self.dataset_manager.permissions.get( dataset )
self.assertIsInstance( permissions, tuple )
self.assertEqual( len( permissions ), 2 )
manage_permissions, access_permissions = permissions
self.assertIsInstance( manage_permissions, list )
self.assertIsInstance( manage_permissions[0], model.DatasetPermissions )
self.assertEqual( access_permissions, [] )
user3 = self.user_manager.create( **user3_data )
self.log( "a public dataset should be manageable to it's owner" )
#.........这里部分代码省略.........