From 2d562f44d498aef6620fe503bb3bece7ab872327 Mon Sep 17 00:00:00 2001 From: Justin Abrahms Date: Sat, 22 Feb 2014 12:01:47 -0800 Subject: [PATCH] Integration test for duplicate comments. --- imhotep/integration_test.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/imhotep/integration_test.py b/imhotep/integration_test.py index f216124..ee97d52 100644 --- a/imhotep/integration_test.py +++ b/imhotep/integration_test.py @@ -46,4 +46,28 @@ def test_github_post(): finally: for comment in comments: req.delete('https://api.github.com/repos/%s/pulls/comments/%s' % ( - repo, comment['id'])) \ No newline at end of file + repo, comment['id'])) + + +@require_github_creds +def test_dont_post_duplicate_comments(): + repo = 'imhotepbot/sacrificial-integration-tests' + pr = 1 + test_str = 'integration test error name' + req = GithubRequester(ghu, ghp) + r = PRReporter(req, pr) + args = [repo, 'da6a127', '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'])) \ No newline at end of file