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


Python HistoryManager.delete方法代码示例

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


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

示例1: HistoryFiltersTestCase

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

    def set_up_managers(self):
        super(HistoryFiltersTestCase, self).set_up_managers()
        self.history_manager = HistoryManager(self.app)
        self.filter_parser = HistoryFilters(self.app)

    # ---- functional and orm filter splitting and resolution
    def test_parse_filters(self):
        filters = self.filter_parser.parse_filters([
            ('name', 'eq', 'wot'),
            ('deleted', 'eq', 'True'),
            ('annotation', 'has', 'hrrmm')
        ])
        self.log('both orm and fn filters should be parsed and returned')
        self.assertEqual(len(filters), 3)

        self.log('values should be parsed')
        self.assertIsInstance(filters[1].right, sqlalchemy.sql.elements.True_)

    def test_parse_filters_invalid_filters(self):
        self.log('should error on non-column attr')
        self.assertRaises(exceptions.RequestParameterInvalidException, self.filter_parser.parse_filters, [
            ('merp', 'eq', 'wot'),
        ])
        self.log('should error on non-whitelisted attr')
        self.assertRaises(exceptions.RequestParameterInvalidException, self.filter_parser.parse_filters, [
            ('user_id', 'eq', 'wot'),
        ])
        self.log('should error on non-whitelisted op')
        self.assertRaises(exceptions.RequestParameterInvalidException, self.filter_parser.parse_filters, [
            ('name', 'lt', 'wot'),
        ])
        self.log('should error on non-listed fn op')
        self.assertRaises(exceptions.RequestParameterInvalidException, self.filter_parser.parse_filters, [
            ('annotation', 'like', 'wot'),
        ])
        self.log('should error on val parsing error')
        self.assertRaises(exceptions.RequestParameterInvalidException, self.filter_parser.parse_filters, [
            ('deleted', 'eq', 'true'),
        ])

    def test_orm_filter_parsing(self):
        user2 = self.user_manager.create(**user2_data)
        history1 = self.history_manager.create(name='history1', user=user2)
        history2 = self.history_manager.create(name='history2', user=user2)
        history3 = self.history_manager.create(name='history3', user=user2)

        filters = self.filter_parser.parse_filters([
            ('name', 'like', 'history%'),
        ])
        histories = self.history_manager.list(filters=filters)
        # for h in histories:
        #    print h.name
        self.assertEqual(histories, [history1, history2, history3])

        filters = self.filter_parser.parse_filters([('name', 'like', '%2'), ])
        self.assertEqual(self.history_manager.list(filters=filters), [history2])

        filters = self.filter_parser.parse_filters([('name', 'eq', 'history2'), ])
        self.assertEqual(self.history_manager.list(filters=filters), [history2])

        self.history_manager.update(history1, dict(deleted=True))
        filters = self.filter_parser.parse_filters([('deleted', 'eq', 'True'), ])
        self.assertEqual(self.history_manager.list(filters=filters), [history1])
        filters = self.filter_parser.parse_filters([('deleted', 'eq', 'False'), ])
        self.assertEqual(self.history_manager.list(filters=filters), [history2, history3])
        self.assertEqual(self.history_manager.list(), [history1, history2, history3])

        self.history_manager.update(history3, dict(deleted=True))
        self.history_manager.update(history1, dict(importable=True))
        self.history_manager.update(history2, dict(importable=True))
        filters = self.filter_parser.parse_filters([
            ('deleted', 'eq', 'True'),
            ('importable', 'eq', 'True'),
        ])
        self.assertEqual(self.history_manager.list(filters=filters), [history1])
        self.assertEqual(self.history_manager.list(), [history1, history2, history3])

    def test_fn_filter_parsing(self):
        user2 = self.user_manager.create(**user2_data)
        history1 = self.history_manager.create(name='history1', user=user2)
        history2 = self.history_manager.create(name='history2', user=user2)
        history3 = self.history_manager.create(name='history3', user=user2)

        filters = self.filter_parser.parse_filters([('annotation', 'has', 'no play'), ])
        anno_filter = filters[0]

        history3.add_item_annotation(self.trans.sa_session, user2, history3, "All work and no play")
        self.trans.sa_session.flush()

        self.assertTrue(anno_filter(history3))
        self.assertFalse(anno_filter(history2))

        self.assertEqual(self.history_manager.list(filters=filters), [history3])

        self.log('should allow combinations of orm and fn filters')
        self.history_manager.update(history3, dict(importable=True))
        self.history_manager.update(history2, dict(importable=True))
        history1.add_item_annotation(self.trans.sa_session, user2, history1, "All work and no play")
#.........这里部分代码省略.........
开发者ID:bwlang,项目名称:galaxy,代码行数:103,代码来源:test_HistoryManager.py

示例2: HistorySerializerTestCase

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

    def set_up_managers(self):
        super(HistorySerializerTestCase, self).set_up_managers()
        self.history_manager = HistoryManager(self.app)
        self.hda_manager = hdas.HDAManager(self.app)
        self.history_serializer = HistorySerializer(self.app)

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

        self.log('should have a summary view')
        summary_view = self.history_serializer.serialize_to_view(history1, view='summary')
        self.assertKeys(summary_view, self.history_serializer.views['summary'])

        self.log('should have a detailed view')
        detailed_view = self.history_serializer.serialize_to_view(history1, view='detailed')
        self.assertKeys(detailed_view, self.history_serializer.views['detailed'])

        self.log('should have the summary view as default view')
        default_view = self.history_serializer.serialize_to_view(history1, default_view='summary')
        self.assertKeys(default_view, self.history_serializer.views['summary'])

        self.log('should have a serializer for all serializable keys')
        for key in self.history_serializer.serializable_keyset:
            instantiated_attribute = getattr(history1, key, None)
            if not ((key in self.history_serializer.serializers) or
                    (isinstance(instantiated_attribute, self.TYPES_NEEDING_NO_SERIALIZERS))):
                self.fail('no serializer for: %s (%s)' % (key, instantiated_attribute))
        else:
            self.assertTrue(True, 'all serializable keys have a serializer')

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

        self.log('should be able to use keys with views')
        serialized = self.history_serializer.serialize_to_view(history1,
            view='summary', keys=['state_ids', 'user_id'])
        self.assertKeys(serialized,
            self.history_serializer.views['summary'] + ['state_ids', 'user_id'])

        self.log('should be able to use keys on their own')
        serialized = self.history_serializer.serialize_to_view(history1,
            keys=['state_ids', 'user_id'])
        self.assertKeys(serialized, ['state_ids', 'user_id'])

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

        self.log('should have a serializer for all SharableModel keys')
        sharable_attrs = ['user_id', 'username_and_slug', 'importable', 'published', 'slug']
        serialized = self.history_serializer.serialize(history1, sharable_attrs)
        self.assertKeys(serialized, sharable_attrs)

        self.log('should return user_id for user with whom it\'s been shared if the requester is the owner')
        non_owner = self.user_manager.create(**user3_data)
        self.history_manager.share_with(history1, non_owner)
        serialized = self.history_serializer.serialize(history1, ['users_shared_with'], user=user2)
        self.assertKeys(serialized, ['users_shared_with'])
        self.assertIsInstance(serialized['users_shared_with'], list)
        self.assertEqual(serialized['users_shared_with'][0], self.app.security.encode_id(non_owner.id))

        self.log('should not return users_shared_with if the requester is not the owner')
        serialized = self.history_serializer.serialize(history1, ['users_shared_with'], user=non_owner)
        self.assertFalse(hasattr(serialized, 'users_shared_with'))

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

        self.log('deleted and purged should be returned in their default states')
        keys = ['deleted', 'purged']
        serialized = self.history_serializer.serialize(history1, keys)
        self.assertEqual(serialized['deleted'], False)
        self.assertEqual(serialized['purged'], False)

        self.log('deleted and purged should return their current state')
        self.history_manager.delete(history1)
        serialized = self.history_serializer.serialize(history1, keys)
        self.assertEqual(serialized['deleted'], True)
        self.assertEqual(serialized['purged'], False)

        self.history_manager.purge(history1)
        serialized = self.history_serializer.serialize(history1, keys)
        self.assertEqual(serialized['deleted'], True)
        self.assertEqual(serialized['purged'], True)

    def test_history_serializers(self):
        user2 = self.user_manager.create(**user2_data)
        history1 = self.history_manager.create(name='history1', user=user2)
        all_keys = list(self.history_serializer.serializable_keyset)
        serialized = self.history_serializer.serialize(history1, all_keys, user=user2)

        self.log('everything serialized should be of the proper type')
        self.assertIsInstance(serialized['size'], int)
        self.assertIsInstance(serialized['nice_size'], string_types)

#.........这里部分代码省略.........
开发者ID:bwlang,项目名称:galaxy,代码行数:103,代码来源:test_HistoryManager.py

示例3: HistoryManagerTestCase

# 需要导入模块: from galaxy.managers.histories import HistoryManager [as 别名]
# 或者: from galaxy.managers.histories.HistoryManager import delete [as 别名]

#.........这里部分代码省略.........
        self.assertFalse( published.importable )
        # note: slug still remains after unpublishing
        self.assertIsNotNone( unpublished.slug )

        self.assertTrue( self.history_mgr.is_accessible( self.trans, unpublished, owner ) )
        self.assertFalse( self.history_mgr.is_accessible( self.trans, unpublished, non_owner ) )
        self.assertTrue( self.history_mgr.is_accessible( self.trans, unpublished, self.admin_user ) )

    def test_sharable( self ):
        owner = self.user_mgr.create( self.trans, **user2_data )
        self.trans.set_user( owner )
        item1 = self.history_mgr.create( self.trans, user=owner )

        non_owner = self.user_mgr.create( self.trans, **user3_data )
        #third_party = self.user_mgr.create( self.trans, **user4_data )

        self.log( "should be unshared by default" )
        self.assertEqual( self.history_mgr.get_share_assocs( self.trans, item1 ), [] )
        self.assertEqual( item1.slug, None )

        self.log( "should be able to share with specific users" )
        share_assoc = self.history_mgr.share_with( self.trans, item1, non_owner )
        self.assertIsInstance( share_assoc, model.HistoryUserShareAssociation )
        self.assertTrue( self.history_mgr.is_accessible( self.trans, item1, non_owner ) )
        self.assertEqual(
            len( self.history_mgr.get_share_assocs( self.trans, item1 ) ), 1 )
        self.assertEqual(
            len( self.history_mgr.get_share_assocs( self.trans, item1, user=non_owner ) ), 1 )
        self.assertIsInstance( item1.slug, basestring )

        self.log( "should be able to unshare with specific users" )
        share_assoc = self.history_mgr.unshare_with( self.trans, item1, non_owner )
        self.assertIsInstance( share_assoc, model.HistoryUserShareAssociation )
        self.assertFalse( self.history_mgr.is_accessible( self.trans, item1, non_owner ) )
        self.assertEqual( self.history_mgr.get_share_assocs( self.trans, item1 ), [] )
        self.assertEqual(
            self.history_mgr.get_share_assocs( self.trans, item1, user=non_owner ), [] )

    #TODO: test slug formation

    def test_anon( self ):
        anon_user = None
        self.trans.set_user( anon_user )

        self.log( "should not allow access and owner for anon user on a history by another anon user (None)" )
        anon_history1 = self.history_mgr.create( self.trans, user=None )
        self.assertFalse( self.history_mgr.is_owner( self.trans, anon_history1, anon_user ) )
        self.assertFalse( self.history_mgr.is_accessible( self.trans, anon_history1, anon_user ) )

        self.log( "should allow access and owner for anon user on a history if it's the session's current history" )
        anon_history2 = self.history_mgr.create( self.trans, user=anon_user )
        self.trans.set_history( anon_history2 )
        self.assertTrue( self.history_mgr.is_owner( self.trans, anon_history2, anon_user ) )
        self.assertTrue( self.history_mgr.is_accessible( self.trans, anon_history2, anon_user ) )

        self.log( "should not allow owner or access for anon user on someone elses history" )
        owner = self.user_mgr.create( self.trans, **user2_data )
        someone_elses = self.history_mgr.create( self.trans, user=owner )
        self.assertFalse( self.history_mgr.is_owner( self.trans, someone_elses, anon_user ) )
        self.assertFalse( self.history_mgr.is_accessible( self.trans, someone_elses, anon_user ) )

        self.log( "should allow access for anon user if the history is published or importable" )
        self.history_mgr.make_importable( self.trans, someone_elses )
        self.assertTrue( self.history_mgr.is_accessible( self.trans, someone_elses, anon_user ) )
        self.history_mgr.publish( self.trans, someone_elses )
        self.assertTrue( self.history_mgr.is_accessible( self.trans, someone_elses, anon_user ) )

    def test_delete_and_purge( self ):
        user2 = self.user_mgr.create( self.trans, **user2_data )
        self.trans.set_user( user2 )

        history1 = self.history_mgr.create( self.trans, name='history1', user=user2 )
        self.trans.set_history( history1 )

        self.assertFalse( history1.deleted )

        self.history_mgr.delete( self.trans, history1 )
        self.assertTrue( history1.deleted )

        self.history_mgr.undelete( self.trans, history1 )
        self.assertFalse( history1.deleted )

        history2 = self.history_mgr.create( self.trans, name='history2', user=user2 )
        self.history_mgr.purge( self.trans, history1 )
        self.assertTrue( history1.purged )

    def test_histories( self ):
        user2 = self.user_mgr.create( self.trans, **user2_data )
        self.trans.set_user( user2 )

        history1 = self.history_mgr.create( self.trans, name='history1', user=user2 )
        self.trans.set_history( history1 )
        history2 = self.history_mgr.create( self.trans, name='history2', user=user2 )

        self.log( "should be able to set or get the current history for a user" )
        self.assertEqual( self.history_mgr.get_current( self.trans ), history1 )
        self.assertEqual( self.history_mgr.set_current( self.trans, history2 ), history2 )
        self.assertEqual( self.history_mgr.get_current( self.trans ), history2 )
        self.assertEqual( self.history_mgr.set_current_by_id( self.trans, history1.id ), history1 )
        self.assertEqual( self.history_mgr.get_current( self.trans ), history1 )
开发者ID:BinglanLi,项目名称:galaxy,代码行数:104,代码来源:test_HistoryManager.py

示例4: HistoryManagerTestCase

# 需要导入模块: from galaxy.managers.histories import HistoryManager [as 别名]
# 或者: from galaxy.managers.histories.HistoryManager import delete [as 别名]

#.........这里部分代码省略.........
        self.assertEqual(
            self.history_manager.get_share_assocs(item1, user=non_owner), [])

    # TODO: test slug formation

    def test_anon(self):
        anon_user = None
        self.trans.set_user(anon_user)

        self.log("should not allow access and owner for anon user on a history by another anon user (None)")
        anon_history1 = self.history_manager.create(user=None)
        # do not set the trans.history!
        self.assertFalse(self.history_manager.is_owner(anon_history1, anon_user, current_history=self.trans.history))
        self.assertFalse(self.history_manager.is_accessible(anon_history1, anon_user, current_history=self.trans.history))

        self.log("should allow access and owner for anon user on a history if it's the session's current history")
        anon_history2 = self.history_manager.create(user=anon_user)
        self.trans.set_history(anon_history2)
        self.assertTrue(self.history_manager.is_owner(anon_history2, anon_user, current_history=self.trans.history))
        self.assertTrue(self.history_manager.is_accessible(anon_history2, anon_user, current_history=self.trans.history))

        self.log("should not allow owner or access for anon user on someone elses history")
        owner = self.user_manager.create(**user2_data)
        someone_elses = self.history_manager.create(user=owner)
        self.assertFalse(self.history_manager.is_owner(someone_elses, anon_user, current_history=self.trans.history))
        self.assertFalse(self.history_manager.is_accessible(someone_elses, anon_user, current_history=self.trans.history))

        self.log("should allow access for anon user if the history is published or importable")
        self.history_manager.make_importable(someone_elses)
        self.assertTrue(self.history_manager.is_accessible(someone_elses, anon_user, current_history=self.trans.history))
        self.history_manager.publish(someone_elses)
        self.assertTrue(self.history_manager.is_accessible(someone_elses, anon_user, current_history=self.trans.history))

    def test_delete_and_purge(self):
        user2 = self.user_manager.create(**user2_data)
        self.trans.set_user(user2)

        history1 = self.history_manager.create(name='history1', user=user2)
        self.trans.set_history(history1)

        self.log("should allow deletion and undeletion")
        self.assertFalse(history1.deleted)

        self.history_manager.delete(history1)
        self.assertTrue(history1.deleted)

        self.history_manager.undelete(history1)
        self.assertFalse(history1.deleted)

        self.log("should allow purging")
        history2 = self.history_manager.create(name='history2', user=user2)
        self.history_manager.purge(history2)
        self.assertTrue(history2.deleted)
        self.assertTrue(history2.purged)

    def test_current(self):
        user2 = self.user_manager.create(**user2_data)
        self.trans.set_user(user2)

        history1 = self.history_manager.create(name='history1', user=user2)
        self.trans.set_history(history1)
        history2 = self.history_manager.create(name='history2', user=user2)

        self.log("should be able to set or get the current history for a user")
        self.assertEqual(self.history_manager.get_current(self.trans), history1)
        self.assertEqual(self.history_manager.set_current(self.trans, history2), history2)
开发者ID:bwlang,项目名称:galaxy,代码行数:70,代码来源:test_HistoryManager.py

示例5: HistorySerializerTestCase

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

    def set_up_managers( self ):
        super( HistorySerializerTestCase, self ).set_up_managers()
        self.history_mgr = HistoryManager( self.app )
        self.hda_mgr = hdas.HDAManager( self.app )
        self.history_serializer = HistorySerializer( self.app )

    def test_views( self ):
        user2 = self.user_mgr.create( self.trans, **user2_data )
        history1 = self.history_mgr.create( self.trans, name='history1', user=user2 )

        self.log( 'should have a summary view' )
        summary_view = self.history_serializer.serialize_to_view( self.trans, history1, view='summary' )
        self.assertKeys( summary_view, self.history_serializer.views[ 'summary' ] )

        self.log( 'should have a detailed view' )
        detailed_view = self.history_serializer.serialize_to_view( self.trans, history1, view='detailed' )
        self.assertKeys( detailed_view, self.history_serializer.views[ 'detailed' ] )

        self.log( 'should have the summary view as default view' )
        default_view = self.history_serializer.serialize_to_view( self.trans, history1, default_view='summary' )
        self.assertKeys( summary_view, self.history_serializer.views[ 'summary' ] )

        self.log( 'should have a serializer for all serializable keys' )
        need_no_serializers = ( basestring, bool, type( None ) )
        for key in self.history_serializer.serializable_keyset:
            instantiated_attribute = getattr( history1, key, None )
            if not ( ( key in self.history_serializer.serializers )
                  or ( isinstance( instantiated_attribute, need_no_serializers ) ) ):
                self.fail( 'no serializer for: %s (%s)' % ( key, instantiated_attribute ) )
        else:
            self.assertTrue( True, 'all serializable keys have a serializer' )

    def test_views_and_keys( self ):
        user2 = self.user_mgr.create( self.trans, **user2_data )
        history1 = self.history_mgr.create( self.trans, name='history1', user=user2 )

        self.log( 'should be able to use keys with views' )
        serialized = self.history_serializer.serialize_to_view( self.trans, history1,
            view='summary', keys=[ 'state_ids', 'user_id' ] )
        self.assertKeys( serialized,
            self.history_serializer.views[ 'summary' ] + [ 'state_ids', 'user_id' ] )

        self.log( 'should be able to use keys on their own' )
        serialized = self.history_serializer.serialize_to_view( self.trans, history1,
            keys=[ 'state_ids', 'user_id' ] )
        self.assertKeys( serialized, [ 'state_ids', 'user_id' ] )

    def test_sharable( self ):
        user2 = self.user_mgr.create( self.trans, **user2_data )
        history1 = self.history_mgr.create( self.trans, name='history1', user=user2 )

        self.log( 'should have a serializer for all SharableModel keys' )
        sharable_attrs = [ 'user_id', 'username_and_slug', 'importable', 'published', 'slug' ]
        serialized = self.history_serializer.serialize( self.trans, history1, sharable_attrs )
        self.assertKeys( serialized, sharable_attrs )

    def test_purgable( self ):
        user2 = self.user_mgr.create( self.trans, **user2_data )
        history1 = self.history_mgr.create( self.trans, name='history1', user=user2 )

        self.log( 'deleted and purged should be returned in their default states' )
        keys = [ 'deleted', 'purged' ]
        serialized = self.history_serializer.serialize( self.trans, history1, keys )
        self.assertEqual( serialized[ 'deleted' ], False )
        self.assertEqual( serialized[ 'purged' ], False )

        self.log( 'deleted and purged should return their current state' )
        self.history_mgr.delete( self.trans, history1 )
        serialized = self.history_serializer.serialize( self.trans, history1, keys )
        self.assertEqual( serialized[ 'deleted' ], True )
        self.assertEqual( serialized[ 'purged' ], False )

        self.history_mgr.purge( self.trans, history1 )
        serialized = self.history_serializer.serialize( self.trans, history1, keys )
        self.assertEqual( serialized[ 'deleted' ], True )
        self.assertEqual( serialized[ 'purged' ], True )

    def test_history_serializers( self ):
        user2 = self.user_mgr.create( self.trans, **user2_data )
        history1 = self.history_mgr.create( self.trans, name='history1', user=user2 )
        
        serialized = self.history_serializer.serialize( self.trans, history1, [ 'size', 'nice_size' ])
        self.assertIsInstance( serialized[ 'size' ], int )
        self.assertIsInstance( serialized[ 'nice_size' ], basestring )

    def test_contents( self ):
        user2 = self.user_mgr.create( self.trans, **user2_data )
        history1 = self.history_mgr.create( self.trans, name='history1', user=user2 )

        self.log( 'a history with no contents should be properly reflected in empty, etc.' )
        keys = [ 'empty', 'count', 'state_ids', 'state_details', 'state', 'hdas' ]
        serialized = self.history_serializer.serialize( self.trans, history1, keys )
        self.assertEqual( serialized[ 'state' ], 'new' )
        self.assertEqual( serialized[ 'empty' ], True )
        self.assertEqual( serialized[ 'count' ], 0 )
        self.assertEqual( sum( serialized[ 'state_details' ].values() ), 0 )
        self.assertEqual( serialized[ 'state_ids' ][ 'ok' ], [] )
        self.assertIsInstance( serialized[ 'hdas' ], list )
#.........这里部分代码省略.........
开发者ID:BinglanLi,项目名称:galaxy,代码行数:103,代码来源:test_HistoryManager.py


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