Exemplo n.º 1
0
    def test_get_commit_for_sha(self, mocked):
        with boddle(params={'owner': 'myowner', 'token': 'mytoken', 'repo': 'myrepo', 'branch_or_sha': 'mysha'}):
            data = {
                'sha': 'mysha',
                'commit': {
                    'sha': 'mysha',
                    'author': {
                        'name': 'myname',
                        'email': 'myemail'
                    },
                    'message': 'mymessage'
                },
                'html_url': 'myurl'
            }

            mocked.return_value = MockResponse(200, json_result=[data, data])

            self.assertEqual(get_commit(), {
                'sha': 'mysha',
                'branch': 'mysha',
                'author': {
                    'name': 'myname',
                    'email': 'myemail'
                },
                'message': 'mymessage',
                'url': 'myurl'
            })
Exemplo n.º 2
0
def get_points(username, repo):
    commits = get_commit_shas(username, repo)
    loc_count = Counter()
    ys = {}
    x = []

    count = 0
    for sha in commits:
        count += 1
        c = Commit(get_commit(username, repo, sha))
        x.append(count)

        # for each extension in the commit, add it to loc_count
        for ext, val in c.loc.items():
            loc_count[ext] += val
            if ext not in ys:
                ys[ext] = [0] * (count - 1)  # Fill with 0s

        # For each extension we've seen append the current value to ys
        for ext, val in loc_count.items():
            ys[ext].append(val)

    return x, ys
Exemplo n.º 3
0
 def test_get_commit_for_sha_failed(self, mocked):
     with boddle(params={'owner': 'myowner', 'token': 'mytoken', 'repo': 'myrepo', 'branch_or_sha': 'mysha'}):
         mocked.return_value = MockResponse(404)
         self.assertEqual(get_commit(), {'message': "sha 'mysha' not found"})
Exemplo n.º 4
0
 def test_get_commit_branch_and_sha_not_set(self):
     with boddle(params={'owner': 'myowner', 'token': 'mytoken', 'repo': 'myrepo'}):
         self.assertEqual(get_commit(), {'message': 'branch_or_sha not set'})
Exemplo n.º 5
0
 def test_get_commit_repo_not_set(self):
     with boddle(params={'owner': 'myowner', 'token': 'mytoken'}):
         self.assertEqual(get_commit(), {'message': 'repo not set'})
Exemplo n.º 6
0
 def test_get_commit_token_not_set(self):
     with boddle(params={'owner': 'myowner'}):
         self.assertEqual(get_commit(), {'message': 'token not set'})
Exemplo n.º 7
0
 def test_get_commit_owner_not_set(self):
     with boddle():
         self.assertEqual(get_commit(), {'message': 'owner not set'})
Exemplo n.º 8
0
    def test_get_commit_for_sha_failed(self, mocked):
        with boddle(params={'owner': 'myowner', 'token': 'mytoken', 'repo': 'myrepo', 'sha': 'mysha'}):
            mocked.return_value = MockResponse(404)
            self.assertEqual(get_commit(), {'message': 'internal server error'})

        mocked.assert_called_once()
Exemplo n.º 9
0
 def test_get_commit_for_branch_failed_execute(self, mocked):
     with boddle(params={'owner': 'myowner', 'token': 'mytoken', 'repo': 'myrepo', 'branch': 'mybranch'}):
         mocked.return_value = MockResponse(404)
         self.assertEqual(get_commit(), {'message': 'internal server error'})