本文整理匯總了Python中trac.ticket.web_ui.TicketModule.process_request方法的典型用法代碼示例。如果您正苦於以下問題:Python TicketModule.process_request方法的具體用法?Python TicketModule.process_request怎麽用?Python TicketModule.process_request使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類trac.ticket.web_ui.TicketModule
的用法示例。
在下文中一共展示了TicketModule.process_request方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: TicketModuleTestCase
# 需要導入模塊: from trac.ticket.web_ui import TicketModule [as 別名]
# 或者: from trac.ticket.web_ui.TicketModule import process_request [as 別名]
class TicketModuleTestCase(unittest.TestCase):
def setUp(self):
self.env = EnvironmentStub()
self.ticket_module = TicketModule(self.env)
def tearDown(self):
self.env.reset_db()
def _create_request(self, authname='anonymous', **kwargs):
kw = {'path_info': '/', 'perm': MockPerm(), 'args': _RequestArgs(),
'href': self.env.href, 'abs_href': self.env.abs_href,
'tz': utc, 'locale': None, 'lc_time': locale_en,
'session': {}, 'authname': authname,
'chrome': {'notices': [], 'warnings': []},
'method': None, 'get_header': lambda v: None, 'is_xhr': False,
'form_token': None}
if 'args' in kwargs:
kw['args'].update(kwargs.pop('args'))
kw.update(kwargs)
def redirect(url, permanent=False):
raise RequestDone
return Mock(add_redirect_listener=lambda x: [].append(x),
redirect=redirect, **kw)
def _create_ticket_with_change(self, old_props, new_props):
"""Create a ticket with `old_props` and apply properties
in `new_props`.
"""
t = Ticket(self.env)
t.populate(old_props)
t.insert()
t.populate(new_props)
t.save_changes('actor')
return t
def _insert_ticket(self, **kw):
"""Helper for inserting a ticket into the database"""
ticket = Ticket(self.env)
for k, v in kw.items():
ticket[k] = v
return ticket.insert()
def test_ticket_module_as_default_handler(self):
"""The New Ticket mainnav entry is active when TicketModule is the
`default_handler` and navigating to the base url. Test for regression
of http://trac.edgewall.org/ticket/8791.
"""
req = self._create_request()
chrome = Chrome(self.env).prepare_request(req, self.ticket_module)
name = None
for item in chrome['nav']['mainnav']:
if item['active'] is True:
name = item['name']
break
self.assertEqual('newticket', name)
def test_ticket_property_diff_owner_change(self):
"""Property diff message when ticket owner is changed."""
t = self._create_ticket_with_change({'owner': 'owner1'},
{'owner': 'owner2'})
req = self._create_request(args={'id': t.id})
data = self.ticket_module.process_request(req)[1]
field = data['changes'][0]['fields']['owner']
self.assertEqual("changed from <em>owner1</em> to <em>owner2</em>",
str(field['rendered']))
def test_ticket_property_diff_owner_add(self):
"""Property diff message when ticket owner is added."""
t = self._create_ticket_with_change({'owner': ''},
{'owner': 'owner2'})
req = self._create_request(args={'id': t.id})
data = self.ticket_module.process_request(req)[1]
field = data['changes'][0]['fields']['owner']
self.assertEqual("set to <em>owner2</em>", str(field['rendered']))
def test_ticket_property_diff_owner_remove(self):
"""Property diff message when ticket owner is removed."""
t = self._create_ticket_with_change({'owner': 'owner1'},
{'owner': ''})
req = self._create_request(args={'id': t.id})
data = self.ticket_module.process_request(req)[1]
field = data['changes'][0]['fields']['owner']
self.assertEqual("<em>owner1</em> deleted", str(field['rendered']))
def test_ticket_property_diff_reporter_change(self):
"""Property diff message when ticket reporter is changed."""
t = self._create_ticket_with_change({'reporter': 'reporter1'},
{'reporter': 'reporter2'})
req = self._create_request(args={'id': t.id})
data = self.ticket_module.process_request(req)[1]
field = data['changes'][0]['fields']['reporter']
#.........這裏部分代碼省略.........