當前位置: 首頁>>代碼示例>>Python>>正文


Python TicketModule.match_request方法代碼示例

本文整理匯總了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',
#.........這裏部分代碼省略.........
開發者ID:aroth-arsoft,項目名稱:trac-advancedworkflow,代碼行數:103,代碼來源:controller.py


注:本文中的trac.ticket.web_ui.TicketModule.match_request方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。