本文整理匯總了Python中trac.ticket.api.TicketSystem.get_ticket_actions方法的典型用法代碼示例。如果您正苦於以下問題:Python TicketSystem.get_ticket_actions方法的具體用法?Python TicketSystem.get_ticket_actions怎麽用?Python TicketSystem.get_ticket_actions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類trac.ticket.api.TicketSystem
的用法示例。
在下文中一共展示了TicketSystem.get_ticket_actions方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: ResetActionTestCase
# 需要導入模塊: from trac.ticket.api import TicketSystem [as 別名]
# 或者: from trac.ticket.api.TicketSystem import get_ticket_actions [as 別名]
class ResetActionTestCase(unittest.TestCase):
def setUp(self):
self.env = EnvironmentStub(default_data=True)
self.perm_sys = PermissionSystem(self.env)
self.ctlr = TicketSystem(self.env).action_controllers[0]
self.req1 = Mock(authname='user1', args={},
perm=PermissionCache(self.env, 'user1'))
self.req2 = Mock(authname='user2', args={},
perm=PermissionCache(self.env, 'user2'))
self.ticket = Ticket(self.env)
self.ticket['status'] = 'invalid'
self.ticket.insert()
def tearDown(self):
self.env.reset_db()
def _reload_workflow(self):
self.ctlr.actions = self.ctlr.get_all_actions()
def test_default_reset_action(self):
"""Default reset action."""
self.perm_sys.grant_permission('user2', 'TICKET_ADMIN')
self._reload_workflow()
actions1 = self.ctlr.get_ticket_actions(self.req1, self.ticket)
actions2 = self.ctlr.get_ticket_actions(self.req2, self.ticket)
chgs2 = self.ctlr.get_ticket_changes(self.req2, self.ticket, '_reset')
self.assertEqual(1, len(actions1))
self.assertNotIn((0, '_reset'), actions1)
self.assertEqual(2, len(actions2))
self.assertIn((0, '_reset'), actions2)
self.assertEqual('new', chgs2['status'])
def test_custom_reset_action(self):
"""Custom reset action in [ticket-workflow] section."""
config = self.env.config['ticket-workflow']
config.set('_reset', '-> review')
config.set('_reset.operations', 'reset_workflow')
config.set('_reset.permissions', 'TICKET_BATCH_MODIFY')
config.set('_reset.default', 2)
self.perm_sys.grant_permission('user2', 'TICKET_BATCH_MODIFY')
self._reload_workflow()
actions1 = self.ctlr.get_ticket_actions(self.req1, self.ticket)
actions2 = self.ctlr.get_ticket_actions(self.req2, self.ticket)
chgs2 = self.ctlr.get_ticket_changes(self.req2, self.ticket, '_reset')
self.assertEqual(1, len(actions1))
self.assertNotIn((2, '_reset'), actions1)
self.assertEqual(2, len(actions2))
self.assertIn((2, '_reset'), actions2)
self.assertEqual('review', chgs2['status'])