本文整理汇总了Python中galaxy.managers.histories.HistoryManager.by_ids方法的典型用法代码示例。如果您正苦于以下问题:Python HistoryManager.by_ids方法的具体用法?Python HistoryManager.by_ids怎么用?Python HistoryManager.by_ids使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类galaxy.managers.histories.HistoryManager
的用法示例。
在下文中一共展示了HistoryManager.by_ids方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: HistoryManagerTestCase
# 需要导入模块: from galaxy.managers.histories import HistoryManager [as 别名]
# 或者: from galaxy.managers.histories.HistoryManager import by_ids [as 别名]
class HistoryManagerTestCase(BaseTestCase):
def set_up_managers(self):
super(HistoryManagerTestCase, self).set_up_managers()
self.history_manager = HistoryManager(self.app)
self.hda_manager = hdas.HDAManager(self.app)
def add_hda_to_history(self, history, **kwargs):
dataset = self.hda_manager.dataset_manager.create()
hda = self.hda_manager.create(history=history, dataset=dataset, **kwargs)
return hda
def test_base(self):
user2 = self.user_manager.create(**user2_data)
user3 = self.user_manager.create(**user3_data)
self.log("should be able to create a new history")
history1 = self.history_manager.create(name='history1', user=user2)
self.assertIsInstance(history1, model.History)
self.assertEqual(history1.name, 'history1')
self.assertEqual(history1.user, user2)
self.assertEqual(history1, self.trans.sa_session.query(model.History).get(history1.id))
self.assertEqual(history1,
self.trans.sa_session.query(model.History).filter(model.History.name == 'history1').one())
self.assertEqual(history1,
self.trans.sa_session.query(model.History).filter(model.History.user == user2).one())
history2 = self.history_manager.copy(history1, user=user3)
self.log("should be able to query")
histories = self.trans.sa_session.query(model.History).all()
self.assertEqual(self.history_manager.one(filters=(model.History.id == history1.id)), history1)
self.assertEqual(self.history_manager.list(), histories)
self.assertEqual(self.history_manager.by_id(history1.id), history1)
self.assertEqual(self.history_manager.by_ids([history2.id, history1.id]), [history2, history1])
self.log("should be able to limit and offset")
self.assertEqual(self.history_manager.list(limit=1), histories[0:1])
self.assertEqual(self.history_manager.list(offset=1), histories[1:])
self.assertEqual(self.history_manager.list(limit=1, offset=1), histories[1:2])
self.assertEqual(self.history_manager.list(limit=0), [])
self.assertEqual(self.history_manager.list(offset=3), [])
self.log("should be able to order")
history3 = self.history_manager.create(name="history3", user=user2)
name_first_then_time = (model.History.name, sqlalchemy.desc(model.History.create_time))
self.assertEqual(self.history_manager.list(order_by=name_first_then_time),
[history2, history1, history3])
def test_copy(self):
user2 = self.user_manager.create(**user2_data)
user3 = self.user_manager.create(**user3_data)
self.log("should be able to copy a history (and it's hdas)")
history1 = self.history_manager.create(name='history1', user=user2)
tags = [u'tag-one']
annotation = u'history annotation'
self.history_manager.set_tags(history1, tags, user=user2)
self.history_manager.annotate(history1, annotation, user=user2)
hda = self.add_hda_to_history(history1, name='wat')
hda_tags = [u'tag-one', u'tag-two']
hda_annotation = u'annotation'
self.hda_manager.set_tags(hda, hda_tags, user=user2)
self.hda_manager.annotate(hda, hda_annotation, user=user2)
history2 = self.history_manager.copy(history1, user=user3)
self.assertIsInstance(history2, model.History)
self.assertEqual(history2.user, user3)
self.assertEqual(history2, self.trans.sa_session.query(model.History).get(history2.id))
self.assertEqual(history2.name, history1.name)
self.assertNotEqual(history2, history1)
copied_hda = history2.datasets[0]
copied_hda_tags = self.hda_manager.get_tags(copied_hda)
self.assertEqual(sorted(hda_tags), sorted(copied_hda_tags))
copied_hda_annotation = self.hda_manager.annotation(copied_hda)
self.assertEqual(hda_annotation, copied_hda_annotation)
def test_has_user(self):
owner = self.user_manager.create(**user2_data)
non_owner = self.user_manager.create(**user3_data)
item1 = self.history_manager.create(user=owner)
item2 = self.history_manager.create(user=owner)
self.history_manager.create(user=non_owner)
self.log("should be able to list items by user")
user_histories = self.history_manager.by_user(owner)
self.assertEqual(user_histories, [item1, item2])
def test_ownable(self):
owner = self.user_manager.create(**user2_data)
non_owner = self.user_manager.create(**user3_data)
item1 = self.history_manager.create(user=owner)
self.log("should be able to poll whether a given user owns an item")
self.assertTrue(self.history_manager.is_owner(item1, owner))
#.........这里部分代码省略.........
示例2: HistoryManagerTestCase
# 需要导入模块: from galaxy.managers.histories import HistoryManager [as 别名]
# 或者: from galaxy.managers.histories.HistoryManager import by_ids [as 别名]
class HistoryManagerTestCase( BaseTestCase ):
def set_up_managers( self ):
super( HistoryManagerTestCase, self ).set_up_managers()
self.history_mgr = HistoryManager( self.app )
def test_base( self ):
user2 = self.user_mgr.create( self.trans, **user2_data )
user3 = self.user_mgr.create( self.trans, **user3_data )
self.log( "should be able to create a new history" )
history1 = self.history_mgr.create( self.trans, name='history1', user=user2 )
self.assertIsInstance( history1, model.History )
self.assertEqual( history1.name, 'history1' )
self.assertEqual( history1.user, user2 )
self.assertEqual( history1, self.trans.sa_session.query( model.History ).get( history1.id ) )
self.assertEqual( history1,
self.trans.sa_session.query( model.History ).filter( model.History.name == 'history1' ).one() )
self.assertEqual( history1,
self.trans.sa_session.query( model.History ).filter( model.History.user == user2 ).one() )
self.log( "should be able to copy a history" )
history2 = self.history_mgr.copy( self.trans, history1, user=user3 )
self.assertIsInstance( history2, model.History )
self.assertEqual( history2.user, user3 )
self.assertEqual( history2, self.trans.sa_session.query( model.History ).get( history2.id ) )
self.assertEqual( history2.name, history1.name )
self.assertNotEqual( history2, history1 )
self.log( "should be able to query" )
histories = self.trans.sa_session.query( model.History ).all()
self.assertEqual( self.history_mgr.one( self.trans, filters=( model.History.id == history1.id ) ), history1 )
self.assertEqual( self.history_mgr.list( self.trans ), histories )
self.assertEqual( self.history_mgr.by_id( self.trans, history1.id ), history1 )
self.assertEqual( self.history_mgr.by_ids( self.trans, [ history2.id, history1.id ] ), [ history2, history1 ] )
self.log( "should be able to limit and offset" )
self.assertEqual( self.history_mgr.list( self.trans, limit=1 ), histories[0:1] )
self.assertEqual( self.history_mgr.list( self.trans, offset=1 ), histories[1:] )
self.assertEqual( self.history_mgr.list( self.trans, limit=1, offset=1 ), histories[1:2] )
self.assertEqual( self.history_mgr.list( self.trans, limit=0 ), [] )
self.assertEqual( self.history_mgr.list( self.trans, offset=3 ), [] )
self.log( "should be able to order" )
history3 = self.history_mgr.create( self.trans, name="history3", user=user2 )
name_first_then_time = ( model.History.name, sqlalchemy.desc( model.History.create_time ) )
self.assertEqual( self.history_mgr.list( self.trans, order_by=name_first_then_time ),
[ history2, history1, history3 ] )
def test_has_user( self ):
owner = self.user_mgr.create( self.trans, **user2_data )
non_owner = self.user_mgr.create( self.trans, **user3_data )
item1 = self.history_mgr.create( self.trans, user=owner )
item2 = self.history_mgr.create( self.trans, user=owner )
item3 = self.history_mgr.create( self.trans, user=non_owner )
self.log( "should be able to list items by user" )
user_histories = self.history_mgr.by_user( self.trans, owner )
self.assertEqual( user_histories, [ item1, item2 ] )
def test_ownable( self ):
owner = self.user_mgr.create( self.trans, **user2_data )
non_owner = self.user_mgr.create( self.trans, **user3_data )
item1 = self.history_mgr.create( self.trans, user=owner )
self.log( "should be able to poll whether a given user owns an item" )
self.assertTrue( self.history_mgr.is_owner( self.trans, item1, owner ) )
self.assertFalse( self.history_mgr.is_owner( self.trans, item1, non_owner ) )
self.log( "should raise an error when checking ownership with non-owner" )
self.assertRaises( exceptions.ItemOwnershipException,
self.history_mgr.error_unless_owner, self.trans, item1, non_owner )
self.assertRaises( exceptions.ItemOwnershipException,
self.history_mgr.get_owned, self.trans, item1.id, non_owner )
self.log( "should not raise an error when checking ownership with owner" )
self.assertEqual( self.history_mgr.error_unless_owner( self.trans, item1, owner ), item1 )
self.assertEqual( self.history_mgr.get_owned( self.trans, item1.id, owner ), item1 )
self.log( "should not raise an error when checking ownership with admin" )
self.assertTrue( self.history_mgr.is_owner( self.trans, item1, self.admin_user ) )
self.assertEqual( self.history_mgr.error_unless_owner( self.trans, item1, self.admin_user ), item1 )
self.assertEqual( self.history_mgr.get_owned( self.trans, item1.id, self.admin_user ), item1 )
def test_accessible( self ):
owner = self.user_mgr.create( self.trans, **user2_data )
item1 = self.history_mgr.create( self.trans, user=owner )
non_owner = self.user_mgr.create( self.trans, **user3_data )
self.log( "should be inaccessible by default except to owner" )
self.assertTrue( self.history_mgr.is_accessible( self.trans, item1, owner ) )
self.assertTrue( self.history_mgr.is_accessible( self.trans, item1, self.admin_user ) )
self.assertFalse( self.history_mgr.is_accessible( self.trans, item1, non_owner ) )
self.log( "should raise an error when checking accessibility with non-owner" )
self.assertRaises( exceptions.ItemAccessibilityException,
#.........这里部分代码省略.........