コード例 #1
0
 def test_get_combined_status_with_url(self, req):
     pr = GithubStatus()
     pr.get_combined_status(url='https://api.github.com/repos/nanliu/circleci/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e/status')
     req.assert_called_once_with(
         'https://api.github.com/repos/nanliu/circleci/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e/status',
         headers={
             'Content-Type': 'application/json',
             'Authorization': 'token GH_TOKEN'
         },
     )
コード例 #2
0
ファイル: test_github_status.py プロジェクト: nanliu/circleci
 def change_status_and_assert_change(
     self,
     ref,
     state,
     desc='test_desc',
     target_url='http://target_url',
 ):
     url1 = 'https://api.github.com/repos/nanliu/circleci/statuses/{}'.format(
         ref)
     url2 = 'https://api.github.com/repos/nanliu/circleci/commits/{}/status'.format(
         ref)
     output = subprocess.check_output([
         'gh_status',
         '-u',
         url1,
         state,
         target_url,
         desc,
     ])
     data = GithubStatus().get_combined_status(url=url2)
     found = False
     for s in data['statuses']:
         if s['description'] == desc:
             print s
             found = True
             assert s['target_url'] == target_url
             assert s['state'] == state
     assert found, True
コード例 #3
0
ファイル: integration.py プロジェクト: nanliu/circleci
 def update_status(self):
     for url in self.status_urls:
         desc = 'The integration build {} started'.format(self.build_num)
         GithubStatus().create_status('pending',
                                      self.build_url,
                                      desc,
                                      self.context,
                                      url=url)
コード例 #4
0
 def test_headers(self):
     pr = GithubStatus()
     self.assertEqual(
         pr.headers,
         {
             'Authorization': 'token GH_TOKEN',
             'Content-Type': 'application/json'
         }
     )
コード例 #5
0
 def test_create_status(self, req):
     pr = GithubStatus()
     pr.create_status(
         'success',
         'https://ci.example.com/1000/output',
         'Build has completed successfully',
         'continuous-integration/jenkins',
     )
     req.assert_called_once_with(
         'https://api.github.com/repos/octocat/Hello-World/statuses/6dcb09b5b57875f334f61aebed695e2e4193db5e',
         headers={
             'Content-Type': 'application/json',
             'Authorization': 'token GH_TOKEN'
         },
         data=json.dumps({
             'state': 'success',
             'target_url': 'https://ci.example.com/1000/output',
             'description': 'Build has completed successfully',
             'context': 'continuous-integration/jenkins'
         }),
     )
コード例 #6
0
 def test_format_url(self):
     pr = GithubStatus()
     self.assertEqual(
         pr.format_url('{}/repos/{}/{}/statuses/{}'),
         'https://api.github.com/repos/octocat/Hello-World/statuses/6dcb09b5b57875f334f61aebed695e2e4193db5e'
     )
     self.assertEqual(
         pr.format_url('{}/repos/{}/{}/statuses/{}', owner='nanliu', repo='circleci'),
         'https://api.github.com/repos/nanliu/circleci/statuses/6dcb09b5b57875f334f61aebed695e2e4193db5e'
     )
     self.assertEqual(
         pr.format_url('{}/repos/{}/{}/commits/{}/status'),
         'https://api.github.com/repos/octocat/Hello-World/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e/status'
     )
     self.assertEqual(
         pr.format_url('{}/repos/{}/{}/statuses/{}', owner='nanliu', repo='circleci'),
         'https://api.github.com/repos/nanliu/circleci/statuses/6dcb09b5b57875f334f61aebed695e2e4193db5e'
     )