本文整理汇总了Python中trac.ticket.api.TicketSystem.resource_exists方法的典型用法代码示例。如果您正苦于以下问题:Python TicketSystem.resource_exists方法的具体用法?Python TicketSystem.resource_exists怎么用?Python TicketSystem.resource_exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trac.ticket.api.TicketSystem
的用法示例。
在下文中一共展示了TicketSystem.resource_exists方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TicketSystemTestCase
# 需要导入模块: from trac.ticket.api import TicketSystem [as 别名]
# 或者: from trac.ticket.api.TicketSystem import resource_exists [as 别名]
#.........这里部分代码省略.........
def test_get_ticket_fields_version_update_time(self):
"""Cached ticket fields are updated when version release time
is changed.
"""
fields = self.ticket_system.get_ticket_fields()
version_field = self._get_ticket_field('version')
v1 = Version(self.env, '1.0')
v1.time = datetime.now(utc)
v2 = Version(self.env, '2.0')
v2.time = v1.time - timedelta(seconds=1)
v1.update()
v2.update()
updated_fields = self.ticket_system.get_ticket_fields()
updated_version_field = self._get_ticket_field('version')
self.assertNotEqual(fields, updated_fields)
self.assertEqual(['2.0', '1.0'], version_field['options'])
self.assertEqual(['1.0', '2.0'], updated_version_field['options'])
def test_get_ticket_fields_milestone_rename(self):
"""Cached ticket fields are updated when milestone is renamed."""
fields = self.ticket_system.get_ticket_fields()
milestone_field = self._get_ticket_field('milestone')
m2 = Milestone(self.env, 'milestone2')
m2.name = 'milestone5'
m2.update()
updated_fields = self.ticket_system.get_ticket_fields()
updated_milestone_field = self._get_ticket_field('milestone')
self.assertNotEqual(fields, updated_fields)
self.assertEqual(['milestone1', 'milestone2',
'milestone3', 'milestone4'],
milestone_field['options'])
self.assertEqual(['milestone1', 'milestone3',
'milestone4', 'milestone5'],
updated_milestone_field['options'])
def test_get_ticket_fields_milestone_update_completed(self):
"""Cached ticket fields are updated when milestone is completed
date is changed.
"""
fields = self.ticket_system.get_ticket_fields()
milestone_field = self._get_ticket_field('milestone')
m2 = Milestone(self.env, 'milestone2')
m2.completed = datetime.now(utc)
m2.update()
updated_fields = self.ticket_system.get_ticket_fields()
updated_milestone_field = self._get_ticket_field('milestone')
self.assertNotEqual(fields, updated_fields)
self.assertEqual(['milestone1', 'milestone2',
'milestone3', 'milestone4'],
milestone_field['options'])
self.assertEqual(['milestone2', 'milestone1',
'milestone3', 'milestone4'],
updated_milestone_field['options'])
def test_get_ticket_fields_milestone_update_due(self):
"""Cached ticket fields are updated when milestone due date is
changed.
"""
fields = self.ticket_system.get_ticket_fields()
milestone_field = self._get_ticket_field('milestone')
m2 = Milestone(self.env, 'milestone2')
m2.due = datetime.now(utc)
m2.update()
updated_fields = self.ticket_system.get_ticket_fields()
updated_milestone_field = self._get_ticket_field('milestone')
self.assertNotEqual(fields, updated_fields)
self.assertEqual(['milestone1', 'milestone2',
'milestone3', 'milestone4'],
milestone_field['options'])
self.assertEqual(['milestone2', 'milestone1',
'milestone3', 'milestone4'],
updated_milestone_field['options'])
def test_resource_exists_valid_resource_id(self):
Ticket(self.env).insert()
r1 = Resource('ticket', 1)
r2 = Resource('ticket', 2)
self.assertTrue(self.ticket_system.resource_exists(r1))
self.assertFalse(self.ticket_system.resource_exists(r2))
def test_resource_exists_invalid_resource_id(self):
"""Exception is trapped from resource with invalid id."""
r1 = Resource('ticket', None)
r2 = Resource('ticket', 'abc')
r3 = Resource('ticket', '2.')
r4 = Resource('ticket', r2)
self.assertFalse(self.ticket_system.resource_exists(r1))
self.assertFalse(self.ticket_system.resource_exists(r2))
self.assertFalse(self.ticket_system.resource_exists(r3))
self.assertFalse(self.ticket_system.resource_exists(r4))