当前位置: 首页>>代码示例>>Python>>正文


Python Ticket.get_default方法代码示例

本文整理汇总了Python中trac.ticket.model.Ticket.get_default方法的典型用法代码示例。如果您正苦于以下问题:Python Ticket.get_default方法的具体用法?Python Ticket.get_default怎么用?Python Ticket.get_default使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在trac.ticket.model.Ticket的用法示例。


在下文中一共展示了Ticket.get_default方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _create_or_update_ticket

# 需要导入模块: from trac.ticket.model import Ticket [as 别名]
# 或者: from trac.ticket.model.Ticket import get_default [as 别名]
    def _create_or_update_ticket(self, runid, testaction, comment, req):
        """ creates or updates a ticket for an action (default ticket
        type if failed, enhancement if otherwise (e.g. passed with comment))
        update means add a comment to the already created ticket
        and add keyword if neccesary
        """
        self.dbg('accordion.request._create_or_update_ticket(%s)' % req.args)
        testrun = Ticket(self.env, tkt_id=runid)
        display = get_display_states(self.env)

        # build ticket summary: <todo>: <action> of <testcase>, e.g.:
        # 'Creator checks in the model of TcCaddocCreate failed.'
        todo = STATES_DISPLAY[testaction.status]
        testcase = models.TestCaseQuery(self.env,
                                        tcid=testaction.tcid).execute()[0]
        summary = "%s of %s %s." % (
            testaction.title, testcase.wiki, display[todo])

        # build description
        description = "Related test case: %s.\n\n%s" % (
            self._build_tc_link(testaction, req),
            comment
        )
        # check if a similar ticket already exists...
        existing_tickets = Query.from_string(
            self.env, "summary=%s" % summary
        ).execute()
        if existing_tickets:
            # if yes return the ticket id
            t = Ticket(self.env, existing_tickets[0]['id'])
            tp_title = self._get_testplan_title(testrun)
            if t['keywords']:
                kws = t['keywords'].split(',')
                if not tp_title in kws:
                    t['keywords'] += ',%s' % tp_title
            else:
                t['keywords'] = tp_title
            t.save_changes(author=req.authname, comment=description)
            return t.id

        # build the ticket
        ticket = Ticket(self.env)

        # determine type of ticket
        ticket_type = ticket.get_default('type')
        if testaction.status != FAILED:
            ticket_type = 'enhancement'

        data = {
            'reporter': req.authname,
            'summary': summary,
            'type': ticket_type,
            'description': description,
            'priority': req.args.get('priority', 'major'),
            'status': 'new',
            'keywords': self._get_testplan_title(testrun),
        }
        self.dbg('ticket data: %s' % data)

        try:
            ticket.populate(data)
            tid = ticket.insert()
            ticket.save_changes()

        except TracError as e:
            self.env.log.error(e)
            raise TracError(
                safe_unicode(
                    "ticket could not be created: %s" % e.message
                )
            )

        return tid
开发者ID:InQuant,项目名称:TracTestManager,代码行数:75,代码来源:jsonapi.py


注:本文中的trac.ticket.model.Ticket.get_default方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。