def test_has_contractor_comment_unrelated_comments(app, reqctx, requests_mocker): requests_mocker.get( "https://api.github.com/user", json={"login": "******"}, headers={"Content-Type": "application/json"}, ) pr = make_pull_request(user="******", number=1) with reqctx: comment = github_contractor_pr_comment(pr) comments_json = [ { "user": { "login": "******", }, "body": "this comment is unrelated", }, { # this comment will be ignored # because it's not made by our bot user "user": { "login": "******", }, "body": "It looks like you're a member of a company that does contract work for edX.", } ] requests_mocker.get( "https://api.github.com/repos/edx/edx-platform/issues/1/comments", json=comments_json, headers={"Content-Type": "application/json"}, ) with reqctx: app.preprocess_request() result = has_contractor_comment(pr) assert result is False
def test_has_contractor_comment(app, reqctx, requests_mocker): requests_mocker.get( "https://api.github.com/user", json={"login": "******"}, headers={"Content-Type": "application/json"}, ) pr = make_pull_request(user="******", number=1) with reqctx: comment = github_contractor_pr_comment(pr) comment_json = { "user": { "login": "******", }, "body": comment } requests_mocker.get( "https://api.github.com/repos/edx/edx-platform/issues/1/comments", json=[comment_json], headers={"Content-Type": "application/json"}, ) with reqctx: app.preprocess_request() result = has_contractor_comment(pr) assert result is True