本文整理汇总了Python中trac.ticket.model.Ticket类的典型用法代码示例。如果您正苦于以下问题:Python Ticket类的具体用法?Python Ticket怎么用?Python Ticket使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Ticket类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_email_map
def test_email_map(self):
"""Login-to-email mapping"""
self.env.config.set("notification", "always_notify_owner", "true")
self.env.config.set("notification", "always_notify_reporter", "true")
self.env.config.set("notification", "smtp_always_cc", "[email protected]")
self.env.known_users = [
("joeuser", "Joe User", "[email protected]"),
("[email protected]", "Jim User", "[email protected]"),
]
ticket = Ticket(self.env)
ticket["reporter"] = "joeuser"
ticket["owner"] = "[email protected]"
ticket["summary"] = "This is a summary"
ticket.insert()
tn = TicketNotifyEmail(self.env)
tn.notify(ticket, newticket=True)
message = notifysuite.smtpd.get_message()
(headers, body) = parse_smtp_message(message)
# Msg should always have a 'To' field
self.failIf("To" not in headers)
tolist = [addr.strip() for addr in headers["To"].split(",")]
# 'To' list should have been resolved to the real email address
self.failIf("[email protected]" not in tolist)
self.failIf("[email protected]" not in tolist)
self.failIf("joeuser" in tolist)
self.failIf("[email protected]" in tolist)
示例2: _test_updater
def _test_updater(disable):
if disable:
self.env.config.set('notification','always_notify_updater',
'false')
ticket = Ticket(self.env)
ticket['reporter'] = '[email protected]'
ticket['summary'] = u'This is a súmmäry'
ticket['cc'] = '[email protected]'
ticket.insert()
ticket['component'] = 'dummy'
now = time.time()
ticket.save_changes('[email protected]', 'This is a change',
when=now)
tn = TicketNotifyEmail(self.env)
tn.notify(ticket, newticket=False, modtime=now)
message = notifysuite.smtpd.get_message()
(headers, body) = parse_smtp_message(message)
# checks for header existence
self.failIf(not headers)
# checks for updater in the 'To' recipient list
self.failIf('To' not in headers)
tolist = [addr.strip() for addr in headers['To'].split(',')]
if disable:
self.failIf('[email protected]' in tolist)
else:
self.failIf('[email protected]' not in tolist)
示例3: test_get_tickets
def test_get_tickets(self):
for pdata in (
{'prefix': 'p2', 'name':'product, too', 'description': ''},
{'prefix': 'p3', 'name':'strike three', 'description': ''},
):
num_tickets = 5
product = Product(self.global_env)
product._data.update(pdata)
product.insert()
self.env = ProductEnvironment(self.global_env, product)
for i in range(num_tickets):
ticket = Ticket(self.env)
ticket['summary'] = 'hello ticket #%s-%d' % (product.prefix, i)
ticket['reporter'] = 'admin'
tid = ticket.insert()
# retrieve tickets using both global and product scope
tickets_from_global = [(t['product'], t['id']) for t in
Product.get_tickets(self.global_env, product.prefix)]
self.assertEqual(len(tickets_from_global), num_tickets)
tickets_from_product = [(t['product'], t['id']) for t in
Product.get_tickets(self.env)]
self.assertEqual(len(tickets_from_product), num_tickets)
# both lists should contain same elements
intersection = set(tickets_from_global) & set(tickets_from_product)
self.assertEqual(len(intersection), num_tickets)
示例4: ticket_setup
def ticket_setup(tc):
ticket = Ticket(tc.env)
ticket['reporter'] = 'santa'
ticket['summary'] = 'This is the summary'
ticket.insert()
ticket['status'] = 'new'
ticket.save_changes('claus', 'set status', 0)
示例5: _test_short_login
def _test_short_login(enabled):
ticket = Ticket(self.env)
ticket['reporter'] = 'joeuser'
ticket['summary'] = 'This is a summary'
ticket.insert()
# Be sure that at least one email address is valid, so that we
# send a notification even if other addresses are not valid
self.env.config.set('notification', 'smtp_always_cc',
'[email protected]')
if enabled:
self.env.config.set('notification', 'use_short_addr', 'true')
tn = TicketNotifyEmail(self.env)
tn.notify(ticket, newticket=True)
message = notifysuite.smtpd.get_message()
(headers, body) = parse_smtp_message(message)
# Msg should not have a 'To' header
if not enabled:
self.failIf('To' in headers)
else:
tolist = [addr.strip() for addr in headers['To'].split(',')]
# Msg should have a 'Cc' field
self.failIf('Cc' not in headers)
cclist = [addr.strip() for addr in headers['Cc'].split(',')]
if enabled:
# Msg should be delivered to the reporter
self.failIf(ticket['reporter'] not in tolist)
else:
# Msg should not be delivered to joeuser
self.failIf(ticket['reporter'] in cclist)
# Msg should still be delivered to the always_cc list
self.failIf(self.env.config.get('notification',
'smtp_always_cc') not in cclist)
示例6: create
def create(self, req, summary, description, attributes={}, notify=False):
""" Create a new ticket, returning the ticket ID.
PS: Borrowed from XmlRpcPlugin.
"""
if 'product' in attributes:
env = self.env.parent or self.env
if attributes['product']:
env = ProductEnvironment(env, attributes['product'])
else:
env = self.env
t = Ticket(env)
t['summary'] = summary
t['description'] = description
t['reporter'] = req.authname
for k, v in attributes.iteritems():
t[k] = v
t['status'] = 'new'
t['resolution'] = ''
t.insert()
if notify:
try:
tn = TicketNotifyEmail(env)
tn.notify(t, newticket=True)
except Exception, e:
self.log.exception("Failure sending notification on creation "
"of ticket #%s: %s" % (t.id, e))
示例7: test_no_disown_from_changed_component
def test_no_disown_from_changed_component(self):
"""
Verify that a ticket is not disowned when the component is changed to
a non-assigned component.
"""
component1 = Component(self.env)
component1.name = 'test1'
component1.owner = 'joe'
component1.insert()
component2 = Component(self.env)
component2.name = 'test2'
component2.owner = ''
component2.insert()
ticket = Ticket(self.env)
ticket['reporter'] = 'santa'
ticket['summary'] = 'Foo'
ticket['component'] = 'test1'
ticket['status'] = 'new'
tktid = ticket.insert()
ticket = Ticket(self.env, tktid)
ticket['component'] = 'test2'
ticket.save_changes('jane', 'Testing')
self.assertEqual('joe', ticket['owner'])
示例8: get_changelog
def get_changelog( self , ticketid):
t = Ticket(self.macroenv.tracenv, ticketid)
try:
return( t.get_changelog() )
except:
self.macroenv.tracenv.log.warning("get_changelog failed on ticket %s", ticketid)
return [] # no changelogs
示例9: post_process_request
def post_process_request(self, req, template, data, content_type):
if template == 'timeline.html':
filter_projects = self._filtered_projects(req)
if not filter_projects: #no filter means likely more than 1 project, so we insert the project name
filter_projects = [project[1] for project in self.__SmpModel.get_all_projects()]
if filter_projects:
filtered_events = []
tickettypes = ("newticket", "editedticket", "closedticket", "attachment", "reopenedticket")
self._old_render_fn = []
self._current_project = []
self._read_idx = -1
for event in data['events']:
if event['kind'] in tickettypes:
resource = event['kind'] == "attachment" and event['data'][0].parent or event['data'][0]
if resource.realm == "ticket":
ticket = Ticket( self.env, resource.id )
project = ticket.get_value_or_default('project')
if project and project in filter_projects:
if len(filter_projects) > 1: #only if more than 1 filtered project
#store the old render function and the project to be inserted
self._old_render_fn.append(event['render'])
self._current_project.append(project)
#redirect to our new render function (which will insert the project name)
event['render'] = self._render_ticket_event
#add to the list of displayed events
filtered_events.append(event)
else:
filtered_events.append(event)
data['events'] = filtered_events
return template, data, content_type
示例10: new_another_ticket
def new_another_ticket(self, env, ticket, comment, author, trac):
project_name = self.env.config.get('project','name')
project_url = self.env.config.get('project','url')
tkt_id = ticket.id
tkt = Ticket(env)
self.log.info("Ticket_id: %s" %(ticket.id))
tkt['status'] = 'new'
tkt['reporter'] = project_name
tkt['summary'] = '[' + project_name + '] #'+ str(tkt_id) +": "+ ticket['summary']
description = ticket['description']
if not comment == "":
comment = "\n * Comment: \n" + comment + "\n"
ticket_url = "\n * Ticket: " + "[" + project_url + "/ticket/" + str(tkt_id) + " " + project_name + "]"
tkt['description'] = description + comment + ticket_url
if ticket['taskstatus']:
tkt['taskstatus'] = trac['newstatus']
self.log.info("tkt.insert")
another_tkt_id = tkt.insert()
if another_tkt_id:
self._insert_anotherticket(env, another_tkt_id, project_name, tkt_id)
self.notify(env, tkt, True)
return another_tkt_id
else:
return False
示例11: change_another_ticket
def change_another_ticket(self, env, tkt_id, comment, author, ticket, trac, action='another'):
""" Change ticket in another_trac """
self.log.info("Call change_another_ticket(%s)" %(tkt_id))
another_proj_name = env.config.get('project','name')
if not re.match(".* \["+ another_proj_name +"\]", author):
(db,cursor) = self._get_dbcursor(env)
utc = UTC()
when = datetime.now(utc)
project_name = self.env.config.get('project','name')
try:
tkt = Ticket(env, tkt_id, db)
except util.TracError, detail:
return False
if action == 'native':
if 'closed' in ticket['status']:
cursor.execute("SELECT oldvalue,author FROM ticket_change WHERE ticket='"+tkt_id+"' AND field = 'owner' ORDER by time DESC LIMIT 1")
old_owner = cursor.fetchone()[0]
# tkt['owner'] = old_owner
tkt['owner'] = tkt['reporter']
if tkt['taskstatus']:
tkt['taskstatus'] = trac['returnstatus']
elif action == 'another':
if 'closed' in tkt['status'] and 'closed' not in ticket['status']:
self.log.info("TICKET FIXED AND CLOSED! REOPEN IT!")
tkt['status'] = 'reopened'
tkt['resolution'] = ''
author = author + " [" + project_name + "]"
tkt.save_changes(author, comment, when)
self.notify(env, tkt, False, when)
return True
示例12: test_props_format_wrap_bothsides_unicode
def test_props_format_wrap_bothsides_unicode(self):
self.env.config.set("notification", "mime_encoding", "none")
self.env.config.set("notification", "ambiguous_char_width", "double")
ticket = Ticket(self.env)
ticket["summary"] = u"This is a summary"
ticket["reporter"] = u"anonymous"
ticket["status"] = u"new"
ticket["owner"] = u"somebody"
ticket["type"] = u"defect"
ticket["priority"] = u"major"
ticket["milestone"] = u"Trac 在经过修改的BSD协议下发布。" u"[1:]协议的完整文本可以[2:在线查" u"看]也可在发布版的 [3:COPYING] 文" u"件中找到。"
ticket["component"] = (
u"Trac は BSD ライセンスのもとで配"
u"布されています。[1:]このライセ"
u"ンスの全文は、𠀋配布ファイル"
u"に含まれている[3:CОPYING]ファイ"
u"ルと同じものが[2:オンライン]で"
u"参照できます。"
)
ticket["version"] = u"2.0"
ticket["resolution"] = u"fixed"
ticket["keywords"] = u""
ticket.insert()
formatted = """\
Reporter: anonymous | Owner: somebody
Type: defect | Status: new
Priority: major | Milestone: Trac 在经过修改的BSD协
Component: Trac は BSD ライセンス | 议下发布。[1:]协议的完整文本可以[2:
のもとで配布されています。[1:]こ | 在线查看]也可在发布版的 [3:COPYING]
のライセンスの全文は、𠀋配布ファ | 文件中找到。
イルに含まれている[3:CОPYING]フ | Version: 2.0
ァイルと同じものが[2:オンライン] | Keywords:
で参照できます。 |
Resolution: fixed |"""
self._validate_props_format(formatted, ticket)
示例13: test_props_format_wrap_leftside_unicode
def test_props_format_wrap_leftside_unicode(self):
self.env.config.set("notification", "mime_encoding", "none")
ticket = Ticket(self.env)
ticket["summary"] = u"This is a summary"
ticket["reporter"] = u"anonymous"
ticket["status"] = u"new"
ticket["owner"] = u"somebody"
ticket["type"] = u"defect"
ticket["priority"] = u"major"
ticket["milestone"] = u"milestone1"
ticket["component"] = (
u"Trac は BSD ライセンスのもとで配"
u"布されています。[1:]このライセ"
u"ンスの全文は、配布ファイルに"
u"含まれている [3:COPYING] ファイル"
u"と同じものが[2:オンライン]で参"
u"照できます。"
)
ticket["version"] = u"2.0"
ticket["resolution"] = u"fixed"
ticket["keywords"] = u""
ticket.insert()
formatted = """\
Reporter: anonymous | Owner: somebody
Type: defect | Status: new
Priority: major | Milestone: milestone1
Component: Trac は BSD ライセンスのもとで配布 | Version: 2.0
されています。[1:]このライセンスの全文は、配 | Keywords:
布ファイルに含まれている [3:COPYING] ファイル |
と同じものが[2:オンライン]で参照できます。 |
Resolution: fixed |"""
self._validate_props_format(formatted, ticket)
示例14: test_ignore_domains
def test_ignore_domains(self):
"""Non-SMTP domain exclusion"""
self.env.config.set("notification", "ignore_domains", "example.com, example.org")
self.env.known_users = [
("[email protected]", "No Email", ""),
("[email protected]", "With Email", "[email protected]"),
]
ticket = Ticket(self.env)
ticket["reporter"] = "[email protected]"
ticket["owner"] = "[email protected]"
ticket["summary"] = "This is a summary"
ticket.insert()
tn = TicketNotifyEmail(self.env)
tn.notify(ticket, newticket=True)
message = notifysuite.smtpd.get_message()
(headers, body) = parse_smtp_message(message)
# Msg should always have a 'To' field
self.failIf("To" not in headers)
tolist = [addr.strip() for addr in headers["To"].split(",")]
# 'To' list should not contain addresses with non-SMTP domains
self.failIf("[email protected]" in tolist)
self.failIf("[email protected]" in tolist)
# 'To' list should have been resolved to the actual email address
self.failIf("[email protected]" not in tolist)
self.failIf(len(tolist) != 1)
示例15: _insert_ticket
def _insert_ticket(self, summary, **kw):
"""Helper for inserting a ticket into the database"""
ticket = Ticket(self.env)
ticket['summary'] = summary
for k, v in kw.items():
ticket[k] = v
return ticket.insert()