本文整理汇总了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']
#.........这里部分代码省略.........