本文整理汇总了Python中trac.ticket.web_ui.TicketModule.match_request方法的典型用法代码示例。如果您正苦于以下问题:Python TicketModule.match_request方法的具体用法?Python TicketModule.match_request怎么用?Python TicketModule.match_request使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trac.ticket.web_ui.TicketModule
的用法示例。
在下文中一共展示了TicketModule.match_request方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: AdvancedTicketWorkflowTestCase
# 需要导入模块: from trac.ticket.web_ui import TicketModule [as 别名]
# 或者: from trac.ticket.web_ui.TicketModule import match_request [as 别名]
class AdvancedTicketWorkflowTestCase(unittest.TestCase):
def setUp(self):
self.env = EnvironmentStub(default_data=True,
enable=['trac.*', 'advancedworkflow.*'])
self.tktmod = TicketModule(self.env)
def tearDown(self):
self.env.reset_db()
def _config_set(self, section, entries):
for option, value in entries:
self.env.config.set(section, option, value)
def _insert_ticket(self, when=None, **values):
values.setdefault('status', 'new')
values.setdefault('type', 'defect')
ticket = Ticket(self.env)
ticket.populate(values)
return ticket.insert(when=when)
def _insert_component(self, name, owner):
component = model.Component(self.env)
component.name = name
component.owner = owner
component.insert()
def _post_req(self, action, ticket):
form_token = 'x' * 40
args = {'action': action, 'submit': '1', '__FORM_TOKEN': form_token,
'view_time': str(to_utimestamp(ticket['changetime']))}
args.update(('field_' + f['name'], ticket[f['name']])
for f in ticket.fields)
return MockRequest(self.env, method='POST', form_token=form_token,
path_info='/ticket/%d' % ticket.id, args=args)
def test_set_owner_to_reporter(self):
self.env.config.set('ticket', 'workflow',
'ConfigurableTicketWorkflow,TicketWorkflowOpOwnerReporter')
self._config_set('ticket-workflow', [
('needinfo', '* -> needinfo'),
('needinfo.name', 'Need info'),
('needinfo.operations', 'set_owner_to_reporter'),
])
tktid = self._insert_ticket(summary='set owner to reporter',
reporter='john', owner='joe')
ticket = Ticket(self.env, tktid)
req = self._post_req('needinfo', ticket)
self.assertTrue(self.tktmod.match_request(req))
self.assertRaises(RequestDone, self.tktmod.process_request, req)
ticket = Ticket(self.env, tktid)
self.assertEqual('john', ticket['owner'])
self.assertEqual('needinfo', ticket['status'])
def test_set_owner_to_component_owner(self):
self.env.config.set('ticket', 'workflow',
'ConfigurableTicketWorkflow,TicketWorkflowOpOwnerComponent')
self._config_set('ticket-workflow', [
('to-c-owner', '* -> assigned'),
('to-c-owner.operations', 'set_owner_to_component_owner'),
])
self._insert_component('component3', 'foo')
tktid = self._insert_ticket(summary='set owner to component owner',
reporter='anonymous', owner='joe',
component='component3')
ticket = Ticket(self.env, tktid)
req = self._post_req('to-c-owner', ticket)
self.assertTrue(self.tktmod.match_request(req))
self.assertRaises(RequestDone, self.tktmod.process_request, req)
ticket = Ticket(self.env, tktid)
self.assertEqual('foo', ticket['owner'])
self.assertEqual('assigned', ticket['status'])
def test_set_owner_to_component_owner_with_missing_component(self):
self.env.config.set('ticket', 'workflow',
'ConfigurableTicketWorkflow,TicketWorkflowOpOwnerComponent')
self._config_set('ticket-workflow', [
('to-c-owner', '* -> assigned'),
('to-c-owner.operations', 'set_owner_to_component_owner'),
])
tktid = self._insert_ticket(summary='set owner to component owner',
reporter='anonymous', owner='joe',
component='component3')
ticket = Ticket(self.env, tktid)
req = self._post_req('to-c-owner', ticket)
self.assertTrue(self.tktmod.match_request(req))
self.assertRaises(RequestDone, self.tktmod.process_request, req)
ticket = Ticket(self.env, tktid)
self.assertEqual('', ticket['owner'])
self.assertEqual('assigned', ticket['status'])
def test_set_owner_to_field(self):
self.env.config.set('ticket', 'workflow',
'ConfigurableTicketWorkflow,TicketWorkflowOpOwnerField')
self._config_set('ticket-workflow', [
('to-owner', '* -> assigned'),
('to-owner.operations', 'set_owner_to_field'),
('to-owner.set_owner_to_field', 'keywords'),
])
tktid = self._insert_ticket(summary='set owner to field',
#.........这里部分代码省略.........