当前位置: 首页>>代码示例>>Python>>正文


Python HistoryManager.contents方法代码示例

本文整理汇总了Python中galaxy.managers.histories.HistoryManager.contents方法的典型用法代码示例。如果您正苦于以下问题:Python HistoryManager.contents方法的具体用法?Python HistoryManager.contents怎么用?Python HistoryManager.contents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在galaxy.managers.histories.HistoryManager的用法示例。


在下文中一共展示了HistoryManager.contents方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: HistoryAsContainerTestCase

# 需要导入模块: from galaxy.managers.histories import HistoryManager [as 别名]
# 或者: from galaxy.managers.histories.HistoryManager import contents [as 别名]
class HistoryAsContainerTestCase( BaseTestCase, CreatesCollectionsMixin ):

    def set_up_managers( self ):
        super( HistoryAsContainerTestCase, self ).set_up_managers()
        self.history_manager = HistoryManager( self.app )
        self.hda_manager = hdas.HDAManager( self.app )
        self.collection_manager = collections.DatasetCollectionManager( 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 add_list_collection_to_history( self, history, hdas, name='test collection', **kwargs ):
        hdca = self.collection_manager.create( self.trans, history, name, 'list',
            element_identifiers=self.build_element_identifiers( hdas ) )
        return hdca

    def test_contents( self ):
        user2 = self.user_manager.create( **user2_data )
        history = self.history_manager.create( name='history', user=user2 )

        self.log( "calling contents on an empty history should return an empty list" )
        self.assertEqual( [], list( self.history_manager.contents( history ) ) )

        self.log( "calling contents on an history with hdas should return those in order of their hids" )
        hdas = [ self.add_hda_to_history( history, name=( 'hda-' + str( x ) ) ) for x in xrange( 3 ) ]
        random.shuffle( hdas )
        ordered_hda_contents = list( self.history_manager.contents( history ) )
        self.assertEqual( map( lambda hda: hda.hid, ordered_hda_contents ), [ 1, 2, 3 ] )

        self.log( "calling contents on an history with both hdas and collections should return both" )
        hdca = self.add_list_collection_to_history( history, hdas )
        all_contents = list( self.history_manager.contents( history ) )
        self.assertEqual( all_contents, list( ordered_hda_contents ) + [ hdca ] )

    def test_contained( self ):
        user2 = self.user_manager.create( **user2_data )
        history = self.history_manager.create( name='history', user=user2 )

        self.log( "calling contained on an empty history should return an empty list" )
        self.assertEqual( [], list( self.history_manager.contained( history ) ) )

        self.log( "calling contained on an history with both hdas and collections should return only hdas" )
        hdas = [ self.add_hda_to_history( history, name=( 'hda-' + str( x ) ) ) for x in xrange( 3 ) ]
        self.add_list_collection_to_history( history, hdas )
        self.assertEqual( list( self.history_manager.contained( history ) ), hdas )

    def test_subcontainers( self ):
        user2 = self.user_manager.create( **user2_data )
        history = self.history_manager.create( name='history', user=user2 )

        self.log( "calling subcontainers on an empty history should return an empty list" )
        self.assertEqual( [], list( self.history_manager.subcontainers( history ) ) )

        self.log( "calling subcontainers on an history with both hdas and collections should return only collections" )
        hdas = [ self.add_hda_to_history( history, name=( 'hda-' + str( x ) ) ) for x in xrange( 3 ) ]
        hdca = self.add_list_collection_to_history( history, hdas )
        subcontainers = list( self.history_manager.subcontainers( history ) )
        self.assertEqual( subcontainers, [ hdca ] )
开发者ID:galaxyguardians,项目名称:galaxy,代码行数:62,代码来源:test_HistoryManager.py


注:本文中的galaxy.managers.histories.HistoryManager.contents方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。