def test_github_post(): repo = 'imhotepbot/sacrificial-integration-tests' pr = 1 test_str = 'integration test error name' req = BasicAuthRequester(ghu, ghp) r = PRReporter(req, repo, pr) r.report_line('da6a127a285ae08d9bfcccb1cb62aef908485769', 'foo.py', 2, 3, test_str) comments = req.get('https://api.github.com/repos/%s/pulls/%s/comments' % (repo, pr)).json() posted = [x for x in comments if test_str in x['body']] try: assert len(posted) == 1 finally: for comment in comments: req.delete('https://api.github.com/repos/%s/pulls/comments/%s' % ( repo, comment['id']))
def test_github_post(): repo = 'imhotepbot/sacrificial-integration-tests' pr = 1 test_str = 'integration test error name' req = BasicAuthRequester(ghu, ghp) r = PRReporter(req, pr) r.report_line(repo, 'da6a127a285ae08d9bfcccb1cb62aef908485769', 'foo.py', 2, 3, test_str) comments = req.get('https://api.github.com/repos/%s/pulls/%s/comments' % (repo, pr)).json() posted = [x for x in comments if test_str in x['body']] try: assert len(posted) == 1 finally: for comment in comments: req.delete('https://api.github.com/repos/%s/pulls/comments/%s' % ( repo, comment['id']))
def test_dont_post_duplicate_comments(): repo = 'imhotepbot/sacrificial-integration-tests' pr = 1 test_str = 'integration test error name' req = BasicAuthRequester(ghu, ghp) r = PRReporter(req, pr) args = [repo, 'da6a127a285ae08d9bfcccb1cb62aef908485769', 'foo.py', 2, 3, test_str] r.report_line(*args) r.report_line(*args) # should dedupe. comment_url = 'https://api.github.com/repos/%s/pulls/%s/comments' % ( repo, pr) comments = req.get(comment_url).json() posted = [x for x in comments if test_str in x['body']] try: assert len(posted) == 1 finally: for comment in comments: req.delete('%s/%s' % (comment_url, comment['id']))
def test_dont_post_duplicate_comments(): repo = 'imhotepbot/sacrificial-integration-tests' pr = 1 test_str = 'integration test error name' req = BasicAuthRequester(ghu, ghp) r = PRReporter(req, repo, pr) args = [ 'da6a127a285ae08d9bfcccb1cb62aef908485769', 'foo.py', 2, 3, test_str ] r.report_line(*args) r.report_line(*args) # should dedupe. comment_url = 'https://api.github.com/repos/%s/pulls/%s/comments' % (repo, pr) comments = req.get(comment_url).json() posted = [x for x in comments if test_str in x['body']] try: assert len(posted) == 1 finally: for comment in comments: req.delete('%s/%s' % (comment_url, comment['id']))
def test_delete(): ghr = BasicAuthRequester('user', 'pass') with mock.patch('requests.delete') as g: ghr.delete('url') g.assert_called_with_args('url', auth=mock.ANY)