本文整理汇总了Python中galaxy.managers.histories.HistoryManager.unshare_with方法的典型用法代码示例。如果您正苦于以下问题:Python HistoryManager.unshare_with方法的具体用法?Python HistoryManager.unshare_with怎么用?Python HistoryManager.unshare_with使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类galaxy.managers.histories.HistoryManager
的用法示例。
在下文中一共展示了HistoryManager.unshare_with方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: HistoryManagerTestCase
# 需要导入模块: from galaxy.managers.histories import HistoryManager [as 别名]
# 或者: from galaxy.managers.histories.HistoryManager import unshare_with [as 别名]
#.........这里部分代码省略.........
self.assertTrue(published.importable)
self.history_manager.make_non_importable(unpublished)
self.assertFalse(published.importable)
# note: slug still remains after unpublishing
self.assertIsNotNone(unpublished.slug)
self.assertTrue(self.history_manager.is_accessible(unpublished, owner))
self.assertFalse(self.history_manager.is_accessible(unpublished, non_owner))
self.assertTrue(self.history_manager.is_accessible(unpublished, self.admin_user))
def test_sharable(self):
owner = self.user_manager.create(**user2_data)
self.trans.set_user(owner)
item1 = self.history_manager.create(user=owner)
non_owner = self.user_manager.create(**user3_data)
# third_party = self.user_manager.create( **user4_data )
self.log("should be unshared by default")
self.assertEqual(self.history_manager.get_share_assocs(item1), [])
self.assertEqual(item1.slug, None)
self.log("should be able to share with specific users")
share_assoc = self.history_manager.share_with(item1, non_owner)
self.assertIsInstance(share_assoc, model.HistoryUserShareAssociation)
self.assertTrue(self.history_manager.is_accessible(item1, non_owner))
self.assertEqual(
len(self.history_manager.get_share_assocs(item1)), 1)
self.assertEqual(
len(self.history_manager.get_share_assocs(item1, user=non_owner)), 1)
self.assertIsInstance(item1.slug, string_types)
self.log("should be able to unshare with specific users")
share_assoc = self.history_manager.unshare_with(item1, non_owner)
self.assertIsInstance(share_assoc, model.HistoryUserShareAssociation)
self.assertFalse(self.history_manager.is_accessible(item1, non_owner))
self.assertEqual(self.history_manager.get_share_assocs(item1), [])
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)
示例2: HistoryManagerTestCase
# 需要导入模块: from galaxy.managers.histories import HistoryManager [as 别名]
# 或者: from galaxy.managers.histories.HistoryManager import unshare_with [as 别名]
#.........这里部分代码省略.........
self.assertTrue( published.importable )
self.history_mgr.make_non_importable( self.trans, unpublished )
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 ) )