本文整理汇总了Python中galaxy.managers.histories.HistoryManager.error_unless_accessible方法的典型用法代码示例。如果您正苦于以下问题:Python HistoryManager.error_unless_accessible方法的具体用法?Python HistoryManager.error_unless_accessible怎么用?Python HistoryManager.error_unless_accessible使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类galaxy.managers.histories.HistoryManager
的用法示例。
在下文中一共展示了HistoryManager.error_unless_accessible方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: HistoryManagerTestCase
# 需要导入模块: from galaxy.managers.histories import HistoryManager [as 别名]
# 或者: from galaxy.managers.histories.HistoryManager import error_unless_accessible [as 别名]
#.........这里部分代码省略.........
self.log("should be able to poll whether a given user owns an item")
self.assertTrue(self.history_manager.is_owner(item1, owner))
self.assertFalse(self.history_manager.is_owner(item1, non_owner))
self.log("should raise an error when checking ownership with non-owner")
self.assertRaises(exceptions.ItemOwnershipException,
self.history_manager.error_unless_owner, item1, non_owner)
self.assertRaises(exceptions.ItemOwnershipException,
self.history_manager.get_owned, item1.id, non_owner)
self.log("should not raise an error when checking ownership with owner")
self.assertEqual(self.history_manager.error_unless_owner(item1, owner), item1)
self.assertEqual(self.history_manager.get_owned(item1.id, owner), item1)
self.log("should not raise an error when checking ownership with admin")
self.assertTrue(self.history_manager.is_owner(item1, self.admin_user))
self.assertEqual(self.history_manager.error_unless_owner(item1, self.admin_user), item1)
self.assertEqual(self.history_manager.get_owned(item1.id, self.admin_user), item1)
def test_accessible(self):
owner = self.user_manager.create(**user2_data)
item1 = self.history_manager.create(user=owner)
non_owner = self.user_manager.create(**user3_data)
self.log("should be inaccessible by default except to owner")
self.assertTrue(self.history_manager.is_accessible(item1, owner))
self.assertTrue(self.history_manager.is_accessible(item1, self.admin_user))
self.assertFalse(self.history_manager.is_accessible(item1, non_owner))
self.log("should raise an error when checking accessibility with non-owner")
self.assertRaises(exceptions.ItemAccessibilityException,
self.history_manager.error_unless_accessible, item1, non_owner)
self.assertRaises(exceptions.ItemAccessibilityException,
self.history_manager.get_accessible, item1.id, non_owner)
self.log("should not raise an error when checking ownership with owner")
self.assertEqual(self.history_manager.error_unless_accessible(item1, owner), item1)
self.assertEqual(self.history_manager.get_accessible(item1.id, owner), item1)
self.log("should not raise an error when checking ownership with admin")
self.assertTrue(self.history_manager.is_accessible(item1, self.admin_user))
self.assertEqual(self.history_manager.error_unless_accessible(item1, self.admin_user), item1)
self.assertEqual(self.history_manager.get_accessible(item1.id, self.admin_user), item1)
def test_importable(self):
owner = self.user_manager.create(**user2_data)
self.trans.set_user(owner)
non_owner = self.user_manager.create(**user3_data)
item1 = self.history_manager.create(user=owner)
self.log("should not be importable by default")
self.assertFalse(item1.importable)
self.assertIsNone(item1.slug)
self.log("should be able to make importable (accessible by link) to all users")
accessible = self.history_manager.make_importable(item1)
self.assertEqual(accessible, item1)
self.assertIsNotNone(accessible.slug)
self.assertTrue(accessible.importable)
for user in self.user_manager.list():
self.assertTrue(self.history_manager.is_accessible(accessible, user))
示例2: HistoryManagerTestCase
# 需要导入模块: from galaxy.managers.histories import HistoryManager [as 别名]
# 或者: from galaxy.managers.histories.HistoryManager import error_unless_accessible [as 别名]
#.........这里部分代码省略.........
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,
self.history_mgr.error_unless_accessible, self.trans, item1, non_owner )
self.assertRaises( exceptions.ItemAccessibilityException,
self.history_mgr.get_accessible, 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_accessible( self.trans, item1, owner ), item1 )
self.assertEqual( self.history_mgr.get_accessible( self.trans, item1.id, owner ), item1 )
self.log( "should not raise an error when checking ownership with admin" )
self.assertTrue( self.history_mgr.is_accessible( self.trans, item1, self.admin_user ) )
self.assertEqual( self.history_mgr.error_unless_accessible( self.trans, item1, self.admin_user ), item1 )
self.assertEqual( self.history_mgr.get_accessible( self.trans, item1.id, self.admin_user ), item1 )
def test_importable( self ):
owner = self.user_mgr.create( self.trans, **user2_data )
self.trans.set_user( owner )
non_owner = self.user_mgr.create( self.trans, **user3_data )
item1 = self.history_mgr.create( self.trans, user=owner )
self.log( "should not be importable by default" )
self.assertFalse( item1.importable )
self.assertIsNone( item1.slug )
self.log( "should be able to make importable (accessible by link) to all users" )
accessible = self.history_mgr.make_importable( self.trans, item1 )
self.assertEqual( accessible, item1 )
self.assertIsNotNone( accessible.slug )
self.assertTrue( accessible.importable )
for user in self.user_mgr.list( self.trans ):
self.assertTrue( self.history_mgr.is_accessible( self.trans, accessible, user ) )