Пример #1
0
 def test_send_async_bitbucket_requests(self, mock_grequests, mock_json):
     self.req_urls = ['https://bitbucket.org/api/1.0/repositories/DrkSephy/smw-koopa-krisis/changesets/?start=5&limit=2']
     self.auth_tokens = {}
     self.json_list = [{
       "count": 693,
       "start": "5",
       "limit": 2,
       "changesets": [
         {
           "node": "982bb31ef6ea",
           "files": [
             {
               "type": "modified",
               "file": "lib/game/entities/player.js"
             },
             {
               "type": "modified",
               "file": "lib/game/levels/test.js"
             },
             {
               "type": "modified",
               "file": "lib/game/main.js"
             }
           ],
           "raw_author": "David Leonard <*****@*****.**>",
           "utctimestamp": "2013-07-27 01:10:46+00:00",
           "author": "DrkSephy",
           "timestamp": "2013-07-27 03:10:46",
           "raw_node": "982bb31ef6ea9e0a071a59c6c38c900e2b9e78a6",
           "parents": [
             "db8e184555a2"
           ],
           "branch": "default",
           "message": "Player entity added",
           "revision": 5,
           "size": -1
         }
       ]
     }]
     mock_grequests.map.return_value = MagicMock()
     mock_grequests.response.content.return_value = MagicMock()
     mock_grequests.get.return_value = self.json_list
     self.assertEqual(bitmethods.send_async_bitbucket_requests(self.req_urls, self.auth_tokens), [])
Пример #2
0
def parse_issues_for_tallying(req_urls, auth_tokens):
    """
    Grabs all issues in a repository with async requests.
    Purpose is to parse issues open, assigned, and resolved.
    """
    parsed_issues = []
    if req_urls:
        raw_issues = bitmethods.send_async_bitbucket_requests(req_urls, auth_tokens)
        for issues_list in raw_issues:
            for issue in issues_list['issues']:
                data = {}
                data['status']  = issue['status']
                data['issue_id']  = issue['local_id']
                data['opened_by'] = issue['reported_by']['display_name']
                data['timestamp'] = issue['utc_last_updated']
                data['assigned']  = None
                if 'responsible' in issue:
                    data['assigned'] = issue['responsible']['display_name']
                parsed_issues.append(data)
    return parsed_issues
Пример #3
0
def iterate_all_changesets(req_urls, auth_tokens):
    """
    Sends async API requests to gets all of the commits
    from a repository based on the req_urls. Parses the
    json reponse and tallies commits for each user.
    Uses parse_changesets as a helper function.

    Parameters:
        req_urls: List

    Returns:
        List
    """
    parsed_changesets = []
    if req_urls:
        # Send async requests to get raw changesets
        raw_changesets = bitmethods.send_async_bitbucket_requests(req_urls, auth_tokens)
        for changesets in raw_changesets:
            if 'changesets' in changesets:
                for changeset in changesets['changesets']:
                    parsed_changesets.append(parse_changeset(changeset))
    return parsed_changesets