Exemplo n.º 1
0
def _to_yt_issue(fb_issue, value_sets):
    issue = Issue()
    issue.numberInProject = str(fb_issue.ix_bug)
    issue.summary = fb_issue.title
    issue.created = fb_issue.opened
    issue.reporterName = fb_issue.reporter.replace(' ', "_")

    for field_name in fb_issue.field_values.keys():
        value_set = None
        if field_name in value_sets:
            value_set = value_sets[field_name]
        yt_field_name = get_yt_field_name(field_name)
        field_value = fb_issue.field_values[field_name]
        if value_set is not None and field_value not in value_set :
            field_value = None
        value = to_yt_field_value(yt_field_name, field_value)
        if value is not None:
            issue[yt_field_name] = value
        
    issue.comments = []
    is_description = True
    for c in fb_issue.comments :
        if is_description:
            issue.description = c.text
            is_description = False
        else :
            issue.comments.append(_to_yt_comment(c))
    return issue
def _to_yt_issue(fb_issue, value_sets) :
    issue = Issue()
    issue.numberInProject = str(fb_issue.ix_bug)
    issue.summary = fb_issue.title
    issue.created = fb_issue.opened
    issue.reporterName = fb_issue.reporter.replace(' ', "_")

    for field_name in fb_issue.field_values.keys():
        value_set = None
        if field_name in value_sets:
            value_set = value_sets[field_name]
        yt_field_name = get_yt_name_from_fb_field_name(field_name)
        field_value = fb_issue.field_values[field_name]
        if value_set is not None and field_value not in value_set :
            field_value = None
        value = to_yt_field_value(yt_field_name, field_value)
        if value is not None:
            issue[yt_field_name] = value
        
    issue.comments = []
    is_description = True
    for c in fb_issue.comments :
        if is_description:
            issue.description = c.text
            is_description = False
        else :
            issue.comments.append(_to_yt_comment(c))
    return issue
def to_yt_issue(target, project_id, story):
    parent = Issue()
    parent.numberInProject = str(story[u"id"])
    parent.summary = story[u"text"]
    parent["Size"] = story[u"size"]
    parent["Type"] = "Feature"
    parent.created = get_created_date_for_story(story)
    color = story[u"color"]
    add_value_to_custom_field(target, project_id, "Color", color)
    parent["Color"] = color
    priority = story[u"priority"]
    if len(priority):
        add_value_to_custom_field(target, project_id, "Priority", priority)
        parent["Priority"] = priority
    if u"deadline" in story:
        parent["Deadline"] = str(to_unix_date(story[u"deadline"]))
    status = story[u"status"]
    add_value_to_custom_field(target, project_id, "Status", status)
    parent["Status"] = status
    parent["State"] = story[u"phase"][u"name"]
    creator = story[u"creator"]
    import_user(target, creator)
    if u"owner" in story:
        owner = story[u"owner"]
        import_user(target, owner)
        parent["Assignee"] = owner[u"userName"]

    parent.reporterName = creator[u"userName"]
    parent.comments = []
    if u"comments" in story:
        for comment in story[u"comments"]:
            parent.comments.append(to_yt_comment(target, comment))
    if u"details" in story:
        parent.description = story[u"details"]
    return parent
def to_yt_issue(target, project_id, story):
    parent = Issue()
    parent.numberInProject = str(story[u'id'])
    parent.summary = story[u'text']
    parent['Size'] = story[u'size']
    parent['Type'] = 'Feature'
    parent.created = get_created_date_for_story(story)
    color = story[u'color']
    add_value_to_custom_field(target, project_id, 'Color', color)
    parent['Color'] = color
    priority = story[u'priority']
    if len(priority):
        add_value_to_custom_field(target, project_id, 'Priority', priority)
        parent['Priority'] = priority
    if u'deadline' in story:
        parent['Deadline'] = str(to_unix_date(story[u'deadline']))
    status = story[u'status']
    add_value_to_custom_field(target, project_id, 'Status', status)
    parent['Status'] = status
    parent['State'] = story[u'phase'][u'name']
    creator = story[u'creator']
    import_user(target, creator)
    if u'owner' in story:
        owner = story[u'owner']
        import_user(target, owner)
        parent['Assignee'] = owner[u'userName']

    parent.reporterName = creator[u'userName']
    parent.comments = []
    if u'comments' in story:
        for comment in story[u'comments']:
            parent.comments.append(to_yt_comment(target, comment))
    if u'details' in story:
        parent.description = story[u'details']
    return parent
def to_yt_issue(target, project_id, g_issue, g_comments):
    issue = Issue()
    issue.numberInProject = issue_id(g_issue)
    issue.summary = g_issue.title.text.encode('utf-8')
    issue.description = HTMLParser.HTMLParser().unescape(g_issue.content.text).replace("<b>", "*").replace("</b>", "*").encode('utf-8')
#    issue.description = g_issue.content.text.encode('utf-8')
    issue.created = to_unix_date(g_issue.published.text)
    issue.updated = to_unix_date(g_issue.updated.text)
    reporter = g_issue.author[0].name.text
    create_user(target, reporter)
    issue.reporterName = reporter
    assignee = g_issue.owner.username.text if hasattr(g_issue, "owner") and (g_issue.owner is not None) else None
    assignee_field_name = get_yt_field_name("owner")
    if assignee is not None:
        add_value_to_field(target, project_id, assignee_field_name, googleCode.FIELD_TYPES[assignee_field_name],
            assignee)
        issue[assignee_field_name] = assignee
    status_field_name = get_yt_field_name("status")
    status = g_issue.status.text if hasattr(g_issue, "status") and (g_issue.status is not None) else None
    if status is not None:
        add_value_to_field(target, project_id, status_field_name, googleCode.FIELD_TYPES[status_field_name], status)
        issue[status_field_name] = status

    for field_name, field_value in get_custom_field_values(g_issue).items():
        for value in field_value:
            add_value_to_field(target, project_id, field_name, googleCode.FIELD_TYPES[field_name], value)
        issue[field_name] = field_value

    issue.comments = []
    for comment in g_comments:
        yt_comment = to_yt_comment(target, comment)
        if yt_comment is not None:
            issue.comments.append(yt_comment)

    return issue
 def test_resolved_date(self):
     issue = Issue()
     issue.created = '123'
     issue.id = 'BACKEND-671'
     issue = CycleTimeAwareIssue(issue, TestProvider())
     self.assertEqual(issue.resolved_date,
                      millis_to_datetime(1472861471941))
    def test_issue_in_state_time(self):
        issue = Issue()
        issue.created = '123'
        issue.id = 'BACKEND-671'
        issue = CycleTimeAwareIssue(issue, TestProvider())
        self.assertEqual(
            issue.time_in_state('Open'),
            millis_to_datetime(1362960471944) - issue.created_time)
        self.assertEqual(
            issue.time_in_state('In Progress'),
            millis_to_datetime(1472861471944) -
            millis_to_datetime(1362960471944))
        self.assertEqual(issue.time_in_state('Complete'),
                         datetime.timedelta(0))
        self.assertEqual(issue.cycle_time, datetime.timedelta(1272, 3800))

        self.assertEqual(issue.first_date_in_state('In Progress'),
                         millis_to_datetime(1362960471944))

        self.assertEqual(issue.cycle_time_start,
                         millis_to_datetime(1362960471944))
        self.assertEqual(issue.cycle_time_end,
                         millis_to_datetime(1472861471944))

        self.assertEqual(
            str(issue),
            '[BACKEND-671], (created): 1970-01-01 01:00:00.123000, '
            '(Open->In Progress): 2013-03-11 01:07:51.944000, '
            '(In Progress->Complete): 2016-09-03 02:11:11.944000, cycle time: 1272 days, 1:03:20'
        )
Exemplo n.º 8
0
def to_yt_issue(target, project_id, story):
    parent = Issue()
    parent.numberInProject = str(story[u'id'])
    parent.summary = story[u'text']
    parent['Size'] = story[u'size']
    parent['Type'] = 'Feature'
    parent.created = get_created_date_for_story(story)
    color = story[u'color']
    add_value_to_custom_field(target, project_id, 'Color', color)
    parent['Color'] = color
    priority = story[u'priority']
    if len(priority):
        add_value_to_custom_field(target, project_id, 'Priority', priority)
        parent['Priority'] = priority
    if u'deadline' in story:
        parent['Deadline'] = str(to_unix_date(story[u'deadline']))
    status = story[u'status']
    add_value_to_custom_field(target, project_id, 'Status', status)
    parent['Status'] = status
    parent['Phase'] = story[u'phase'][u'name']
    creator = story[u'creator']
    import_user(target, creator)
    if u'owner' in story:
        owner = story[u'owner']
        import_user(target, owner)
        parent['Assignee'] = owner[u'userName']

    parent.reporterName = creator[u'userName']
    parent.comments = []
    if u'comments' in story:
        for comment in story[u'comments']:
            parent.comments.append(to_yt_comment(target, comment))
    if u'details' in story:
        parent.description = story[u'details']
    return parent
def to_yt_issue(target, project_id, g_issue, g_comments):
    issue = Issue()
    issue.numberInProject = issue_id(g_issue)
    issue.summary = g_issue.title.text.encode('utf-8')
    issue.description = HTMLParser.HTMLParser().unescape(g_issue.content.text).replace("<b>", "*").replace("</b>", "*").encode('utf-8')
#    issue.description = g_issue.content.text.encode('utf-8')
    issue.created = to_unix_date(g_issue.published.text)
    issue.updated = to_unix_date(g_issue.updated.text)
    reporter = g_issue.author[0].name.text
    create_user(target, reporter)
    issue.reporterName = reporter
    assignee = g_issue.owner.username.text if hasattr(g_issue, "owner") and (g_issue.owner is not None) else None
    assignee_field_name = get_yt_field_name("owner")
    if assignee is not None:
        add_value_to_field(target, project_id, assignee_field_name, googleCode.FIELD_TYPES[assignee_field_name],
            assignee)
        issue[assignee_field_name] = assignee
    status_field_name = get_yt_field_name("status")
    status = g_issue.status.text if hasattr(g_issue, "status") and (g_issue.status is not None) else None
    if status is not None:
        add_value_to_field(target, project_id, status_field_name, googleCode.FIELD_TYPES[status_field_name], status)
        issue[status_field_name] = status

    for field_name, field_value in get_custom_field_values(g_issue).items():
        for value in field_value:
            add_value_to_field(target, project_id, field_name, googleCode.FIELD_TYPES[field_name], value)
        issue[field_name] = field_value

    issue.comments = []
    for comment in g_comments:
        yt_comment = to_yt_comment(target, comment)
        if yt_comment is not None:
            issue.comments.append(yt_comment)

    return issue
 def te_st_live_get_cycle_time(self):
     yt = Connection('https://tickets.i.gini.net', username, password)
     print 'connected to [%s]' % yt.baseUrl
     issue = Issue()
     issue.id = 'BACKEND-671'
     issue.created = '123'
     issue = CycleTimeAwareIssue(issue, YoutrackProvider(yt))
     self.assertEqual(7, issue.cycle_time.days)
 def test_get_cylce_time_for_issue(self):
     issue = Issue()
     issue.created = '123'
     issue.id = 'BACKEND-671'
     issue = CycleTimeAwareIssue(issue, TestProvider())
     self.assertEqual(
         millis_to_datetime(1472861471944) -
         millis_to_datetime(1362960471944), issue.cycle_time)
     self.assertEqual(datetime.datetime(1970, 1, 1, 1, 0, 0, 123000),
                      issue.created_time)
def to_yt_sub_task(target, project_id, story, task):
    issue = Issue()
    issue.summary = task[u"text"]
    issue.reporterName = story[u"creator"][u"userName"]
    issue.created = str(to_unix_date(task[u"createTime"]))
    if u"finishTime" in task:
        issue.resolved = str(to_unix_date(task[u"finishTime"]))
    status = task[u"status"]
    add_value_to_custom_field(target, project_id, "Status", status)
    issue["Status"] = status
    issue["Type"] = "Task"
    if u"finishedBy" in task:
        finished_by = task[u"finishedBy"]
        import_user(target, finished_by)
        issue["Assignee"] = finished_by[u"userName"]
    issue.comments = []
    return issue
def to_yt_sub_task(target, project_id, story, task):
    issue = Issue()
    issue.summary = task[u'text']
    issue.reporterName = story[u'creator'][u'userName']
    issue.created = str(to_unix_date(task[u'createTime']))
    if u'finishTime' in task:
        issue.resolved = str(to_unix_date(task[u'finishTime']))
    status = task[u'status']
    add_value_to_custom_field(target, project_id, "Status", status)
    issue['Status'] = status
    issue['Type'] = 'Task'
    if u'finishedBy' in task:
        finished_by = task[u'finishedBy']
        import_user(target, finished_by)
        issue['Assignee'] = finished_by[u'userName']
    issue.comments = []
    return issue
Exemplo n.º 14
0
def to_yt_sub_task(target, project_id, story, task):
    issue = Issue()
    issue.summary = task[u'text']
    issue.reporterName = story[u'creator'][u'userName']
    issue.created = str(to_unix_date(task[u'createTime']))
    if u'finishTime' in task:
        issue.resolved = str(to_unix_date(task[u'finishTime']))
    status = task[u'status']
    add_value_to_custom_field(target, project_id, "Status", status)
    issue['Status'] = status
    issue['Type'] = 'Task'
    if u'finishedBy' in task:
        finished_by = task[u'finishedBy']
        import_user(target, finished_by)
        issue['Assignee'] = finished_by[u'userName']
    issue.comments = []
    return issue