def _CreateUsersDict(issue_data, project_name):
    """Extract users from list of issues into a dict.

  Args:
    issue_data: Issue data
    project_name: The name of the project being exported.

  Returns:
    Dict of users associated with a list of issues
  """
    users = {}
    for issue in issue_data:
        googlecode_issue = issues.GoogleCodeIssue(issue, project_name,
                                                  OptionalMap())

        reporting_user = googlecode_issue.GetAuthor()
        addIfNotPresent(users, reporting_user)

        assignee_user = googlecode_issue.GetOwner()
        addIfNotPresent(users, assignee_user)

        googlecode_comments = googlecode_issue.GetComments()
        for comment in googlecode_comments:
            googlecode_comment = issues.GoogleCodeComment(
                googlecode_issue, comment)
            commenting_user = googlecode_comment.GetAuthor()
            addIfNotPresent(users, commenting_user)

    return {"users": users}
Пример #2
0
 def testGetIssueUserOwner(self):
     issue_json = copy.deepcopy(ISSUE_JSON)
     issue_json["owner"]["name"] = "*****@*****.**"
     issue = issues.GoogleCodeIssue(issue_json, REPO, USER_MAP)
     self.assertEqual(DEFAULT_USERNAME, issue.GetOwner())
Пример #3
0
 def testGetIssueOwnerNoOwner(self):
     issue_json = ISSUE_JSON.copy()
     del issue_json["owner"]
     issue = issues.GoogleCodeIssue(issue_json, REPO, USER_MAP)
     self.assertEqual(None, issue.GetOwner())
Пример #4
0
    "state": "closed",
    "title": "issue_title",
    "comments": {
        "items": [COMMENT_ONE]
    },
    "labels": ["awesome", "great"],
    "published": "last year",
    "updated": "last month",
    "status": "Fixed",
    "owner": {
        "kind": "projecthosting#issuePerson",
        "name": "*****@*****.**",
    },
}

SINGLE_ISSUE = issues.GoogleCodeIssue(ISSUE_JSON, REPO, USER_MAP)

SINGLE_COMMENT = issues.GoogleCodeComment(SINGLE_ISSUE, COMMENT_ONE)


class GoogleCodeIssueTest(unittest.TestCase):
    """Tests for GoogleCodeIssue."""
    def testGetIssueOwner(self):
        self.assertEqual("a_uthor", SINGLE_ISSUE.GetOwner())

    def testGetIssueOwnerNoOwner(self):
        issue_json = ISSUE_JSON.copy()
        del issue_json["owner"]
        issue = issues.GoogleCodeIssue(issue_json, REPO, USER_MAP)
        self.assertEqual(None, issue.GetOwner())