Пример #1
0
    def test_checks_dependencies_upon_receiving_pr_comment_event_for_more_than_one_dependency_on_external_repo(
            self, requests_mock):
        payload = PR_COMMENT_EVENT.replace("This is the PR body",
                                           "Depends on owner/repo#2.")
        payload = json.loads(
            payload.replace(
                "this is a comment",
                ("Depends on https://github.com/owner/repo/pull/3."
                 "Depends on https://github.com/owner/repo/issues/4.")))

        response = check(payload, headers=GITHUB_HEADERS, host=HOST)

        self.assertEqual(201, response.get("statusCode"))

        expected_url_dep_2 = "{}repos/{}/{}/issues/{}".format(
            BASE_GITHUB_URL, "owner", "repo", "2")

        expected_url_dep_3 = "{}repos/{}/{}/issues/{}".format(
            BASE_GITHUB_URL, "owner", "repo", "3")

        expected_url_dep_4 = "{}repos/{}/{}/issues/{}".format(
            BASE_GITHUB_URL, "owner", "repo", "4")

        requests_mock.assert_any_call('GET',
                                      expected_url_dep_2,
                                      headers=HEADERS)
        requests_mock.assert_any_call('GET',
                                      expected_url_dep_3,
                                      headers=HEADERS)
        requests_mock.assert_any_call('GET',
                                      expected_url_dep_4,
                                      headers=HEADERS)
Пример #2
0
def webhook_event():

    app.logger.info("Received request with headers \n{}and data: \n{}".format(
        request.headers, request.data))
    result = check(request.data, request.headers,
                   request.environ.get("HTTP_HOST"))
    return result.get("body"), result.get("statusCode")
Пример #3
0
    def test_checks_dependencies_upon_receiving_pr_created_event(
            self, requests_mock):
        payload = json.loads(
            PR_CREATED.replace("This is the PR body",
                               "This is the PR body. Depends on #2."))

        response = check(payload, headers=GITHUB_HEADERS, host=HOST)

        assert 201 == response.get("statusCode")

        expected_url = "{}repos/{}/{}/issues/{}".format(
            BASE_GITHUB_URL, "alvarocavalcanti", "pierre-decheck", "2")

        requests_mock.assert_any_call('GET', expected_url, headers=HEADERS)
Пример #4
0
    def test_checks_dependencies_upon_receiving_pr_comment_event_for_more_than_one_dependency(
            self, requests_mock):
        payload = PR_COMMENT_EVENT.replace("This is the PR body",
                                           "Depends on #2.")
        payload = json.loads(
            payload.replace("this is a comment", "Depends on #3."))

        response = check(payload, headers=GITHUB_HEADERS, host=HOST)

        assert 201 == response.get("statusCode")

        expected_url_dep_2 = "{}repos/{}/{}/issues/{}".format(
            BASE_GITHUB_URL, "alvarocavalcanti", "pierre-decheck", "2")

        expected_url_dep_3 = "{}repos/{}/{}/issues/{}".format(
            BASE_GITHUB_URL, "alvarocavalcanti", "pierre-decheck", "3")

        requests_mock.assert_any_call('GET',
                                      expected_url_dep_2,
                                      headers=HEADERS)
        requests_mock.assert_any_call('GET',
                                      expected_url_dep_3,
                                      headers=HEADERS)
Пример #5
0
def pierre_decheck(event, context):
    event_data = json.loads(event.get("body"))
    headers = json.loads(event.get("headers"))
    host = json.loads(event.get("environ").get("HTTP_HOST"))
    return check(event_data, headers, host)