コード例 #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'
            })
コード例 #2
0
ファイル: plot.py プロジェクト: matt-leach/repo-graphs
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
コード例 #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"})
コード例 #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'})
コード例 #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'})
コード例 #6
0
 def test_get_commit_token_not_set(self):
     with boddle(params={'owner': 'myowner'}):
         self.assertEqual(get_commit(), {'message': 'token not set'})
コード例 #7
0
 def test_get_commit_owner_not_set(self):
     with boddle():
         self.assertEqual(get_commit(), {'message': 'owner not set'})
コード例 #8
0
ファイル: tests.py プロジェクト: Asghan86/infrabox
    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()
コード例 #9
0
ファイル: tests.py プロジェクト: Asghan86/infrabox
 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'})