{"action":"created","comment":{"url":"https://api.github.com/repos/apache/incubator-airflow/pulls/comments/184918622","pull_request_review_id":116205537,"id":184918622,"diff_hunk":"@@ -0,0 +1,260 @@\n+# -*- coding: utf-8 -*-\n+#\n+# Licensed under the Apache License, Version 2.0 (the \"License\");\n+# you may not use this file except in compliance with the License.\n+# You may obtain a copy of the License at\n+#\n+# http://www.apache.org/licenses/LICENSE-2.0\n+#\n+# Unless required by applicable law or agreed to in writing, software\n+# distributed under the License is distributed on an \"AS IS\" BASIS,\n+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+# See the License for the specific language governing permissions and\n+# limitations under the License.\n+import unittest\n+\n+import json\n+\n+import requests\n+import requests_mock\n+\n+import tenacity\n+\n+from airflow import configuration, models\n+from airflow.exceptions import AirflowException\n+\n+try:\n+    from airflow.hooks.http_hook import HttpHook","path":"tests/hooks/test_http_hook.py","position":27,"original_position":27,"commit_id":"3ff0efd95baa06c44a3945792417bb6369794f57","original_commit_id":"3ff0efd95baa06c44a3945792417bb6369794f57","user":{"login":"Fokko","id":1134248,"avatar_url":"https://avatars0.githubusercontent.com/u/1134248?v=4","gravatar_id":"","url":"https://api.github.com/users/Fokko","html_url":"https://github.com/Fokko","followers_url":"https://api.github.com/users/Fokko/followers","following_url":"https://api.github.com/users/Fokko/following{/other_user}","gists_url":"https://api.github.com/users/Fokko/gists{/gist_id}","starred_url":"https://api.github.com/users/Fokko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Fokko/subscriptions","organizations_url":"https://api.github.com/users/Fokko/orgs","repos_url":"https://api.github.com/users/Fokko/repos","events_url":"https://api.github.com/users/Fokko/events{/privacy}","received_events_url":"https://api.github.com/users/Fokko/received_events","type":"User","site_admin":false},"body":"Please","created_at":"2018-04-30T06:44:51Z","updated_at":"2018-04-30T06:44:51Z","html_url":"https://github.com/apache/incubator-airflow/pull/3071#discussion_r184918622","pull_request_url":"https://api.github.com/repos/apache/incubator-airflow/pulls/3071","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-airflow/pulls/comments/184918622"},"html":{"href":"https://github.com/apache/incubator-airflow/pull/3071#discussion_r184918622"},"pull_request":{"href":"https://api.github.com/repos/apache/incubator-airflow/pulls/3071"}},"in_reply_to_id":184862531},"pull_request":{"url":"https://api.github.com/repos/apache/incubator-airflow/pulls/3071","id":171020432,"html_url":"https://github.com/apache/incubator-airflow/pull/3071","diff_url":"https://github.com/apache/incubator-airflow/pull/3071.diff","patch_url":"https://github.com/apache/incubator-airflow/pull/3071.patch","issue_url":"https://api.github.com/repos/apache/incubator-airflow/issues/3071","number":3071,"state":"open","locked":false,"title":"[AIRFLOW-2110] Enhance Http Hook to use a header in passed in the \"extra\" argument and add tenacity retry","user":{"login":"albertocalderari","id":7837183,"avatar_url":"https://avatars1.githubusercontent.com/u/7837183?v=4","gravatar_id":"","url":"https://api.github.com/users/albertocalderari","html_url":"https://github.com/albertocalderari","followers_url":"https://api.github.com/users/albertocalderari/followers","following_url":"https://api.github.com/users/albertocalderari/following{/other_user}","gists_url":"https://api.github.com/users/albertocalderari/gists{/gist_id}","starred_url":"https://api.github.com/users/albertocalderari/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/albertocalderari/subscriptions","organizations_url":"https://api.github.com/users/albertocalderari/orgs","repos_url":"https://api.github.com/users/albertocalderari/repos","events_url":"https://api.github.com/users/albertocalderari/events{/privacy}","received_events_url":"https://api.github.com/users/albertocalderari/received_events","type":"User","site_admin":false},"body":"Make sure you have checked _all_ steps below.\r\n\r\n## JIRA\r\n\r\n- [x]   My PR addresses the following Airflow JIRA issues and references them in the PR title. For example, \"[AIRFLOW-XXX] My Airflow PR\"\r\n[AIRFLOW-2110] Enhance Http Hook to use a header in passed in the \"extra\" argument and add tenacity retry\"\r\nhttps://issues.apache.org/jira/browse/AIRFLOW-2122\r\n\r\n## Description\r\n- [x]  Add possibility to add a json header in the \"extra\" field in the connection:\r\n{\"Authorization\": \"Bearer Here1sMyT0k3N\"}\r\nAlso add tenacity retry so the operator won't fall over in case of a connection issue.\r\nHere are some details about my PR, including screenshots of any UI changes:\r\nIn the original hook we could not skip raise for status, pass headers from the \"extra\" field in the airflow UI and would immediately fail on connection error. Now in case of connection error the hook will retry 7 times with exponential backoff, the \"raise for status\" method can be skipped and can pass a JSON header in the extra field in the UI.\r\n\r\n## Tests\r\n\r\n- [x]  My PR adds the following unit tests OR does not need testing for this extremely good reason:\r\ntest_raise_for_status_with_200\r\ntest_get_request_do_not_raise_for_status_if_check_response_is_false\r\ntest_hook_contains_header_from_extra_field\r\ntest_hook_uses_provided_header\r\ntest_hook_has_no_header_from_extra\r\ntest_hooks_header_from_extra_is_overridden\r\ntest_post_request\r\ntest_post_request_with_error_code\r\ntest_post_request_do_not_raise_for_status_if_check_response_is_false\r\ntest_retry_on_conn_error\r\ntest_header_from_extra_and_run_method_are_merged\r\n\r\n## Commits \r\n\r\n- [x] My commits all reference JIRA issues in their subject lines, and I have squashed multiple commits if they address the same issue. In addition, my commits follow the guidelines from \"How to write a good git commit message\":\r\n\r\nSubject is separated from body by a blank line\r\nSubject is limited to 50 characters\r\nSubject does not end with a period\r\nSubject uses the imperative mood (\"add\", not \"adding\")\r\nBody wraps at 72 characters\r\nBody explains \"what\" and \"why\", not \"how\"\r\n\r\n- [x]  Passes git diff upstream/master -u -- \"*.py\" | flake8 --diff","created_at":"2018-02-23T13:56:18Z","updated_at":"2018-04-30T06:44:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c516baedeef63e8c31871268f343f808a0c7618d","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/incubator-airflow/pulls/3071/commits","review_comments_url":"https://api.github.com/repos/apache/incubator-airflow/pulls/3071/comments","review_comment_url":"https://api.github.com/repos/apache/incubator-airflow/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/incubator-airflow/issues/3071/comments","statuses_url":"https://api.github.com/repos/apache/incubator-airflow/statuses/3ff0efd95baa06c44a3945792417bb6369794f57","head":{"label":"albertocalderari:master","ref":"master","sha":"3ff0efd95baa06c44a3945792417bb6369794f57","user":{"login":"albertocalderari","id":7837183,"avatar_url":"https://avatars1.githubusercontent.com/u/7837183?v=4","gravatar_id":"","url":"https://api.github.com/users/albertocalderari","html_url":"https://github.com/albertocalderari","followers_url":"https://api.github.com/users/albertocalderari/followers","following_url":"https://api.github.com/users/albertocalderari/following{/other_user}","gists_url":"https://api.github.com/users/albertocalderari/gists{/gist_id}","starred_url":"https://api.github.com/users/albertocalderari/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/albertocalderari/subscriptions","organizations_url":"https://api.github.com/users/albertocalderari/orgs","repos_url":"https://api.github.com/users/albertocalderari/repos","events_url":"https://api.github.com/users/albertocalderari/events{/privacy}","received_events_url":"https://api.github.com/users/albertocalderari/received_events","type":"User","site_admin":false},"repo":{"id":121654842,"name":"incubator-airflow","full_name":"albertocalderari/incubator-airflow","owner":{"login":"albertocalderari","id":7837183,"avatar_url":"https://avatars1.githubusercontent.com/u/7837183?v=4","gravatar_id":"","url":"https://api.github.com/users/albertocalderari","html_url":"https://github.com/albertocalderari","followers_url":"https://api.github.com/users/albertocalderari/followers","following_url":"https://api.github.com/users/albertocalderari/following{/other_user}","gists_url":"https://api.github.com/users/albertocalderari/gists{/gist_id}","starred_url":"https://api.github.com/users/albertocalderari/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/albertocalderari/subscriptions","organizations_url":"https://api.github.com/users/albertocalderari/orgs","repos_url":"https://api.github.com/users/albertocalderari/repos","events_url":"https://api.github.com/users/albertocalderari/events{/privacy}","received_events_url":"https://api.github.com/users/albertocalderari/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/albertocalderari/incubator-airflow","description":"Apache Airflow (Incubating)","fork":true,"url":"https://api.github.com/repos/albertocalderari/incubator-airflow","forks_url":"https://api.github.com/repos/albertocalderari/incubator-airflow/forks","keys_url":"https://api.github.com/repos/albertocalderari/incubator-airflow/keys{/key_id}","collaborators_url":"https://api.github.com/repos/albertocalderari/incubator-airflow/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/albertocalderari/incubator-airflow/teams","hooks_url":"https://api.github.com/repos/albertocalderari/incubator-airflow/hooks","issue_events_url":"https://api.github.com/repos/albertocalderari/incubator-airflow/issues/events{/number}","events_url":"https://api.github.com/repos/albertocalderari/incubator-airflow/events","assignees_url":"https://api.github.com/repos/albertocalderari/incubator-airflow/assignees{/user}","branches_url":"https://api.github.com/repos/albertocalderari/incubator-airflow/branches{/branch}","tags_url":"https://api.github.com/repos/albertocalderari/incubator-airflow/tags","blobs_url":"https://api.github.com/repos/albertocalderari/incubator-airflow/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/albertocalderari/incubator-airflow/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/albertocalderari/incubator-airflow/git/refs{/sha}","trees_url":"https://api.github.com/repos/albertocalderari/incubator-airflow/git/trees{/sha}","statuses_url":"https://api.github.com/repos/albertocalderari/incubator-airflow/statuses/{sha}","languages_url":"https://api.github.com/repos/albertocalderari/incubator-airflow/languages","stargazers_url":"https://api.github.com/repos/albertocalderari/incubator-airflow/stargazers","contributors_url":"https://api.github.com/repos/albertocalderari/incubator-airflow/contributors","subscribers_url":"https://api.github.com/repos/albertocalderari/incubator-airflow/subscribers","subscription_url":"https://api.github.com/repos/albertocalderari/incubator-airflow/subscription","commits_url":"https://api.github.com/repos/albertocalderari/incubator-airflow/commits{/sha}","git_commits_url":"https://api.github.com/repos/albertocalderari/incubator-airflow/git/commits{/sha}","comments_url":"https://api.github.com/repos/albertocalderari/incubator-airflow/comments{/number}","issue_comment_url":"https://api.github.com/repos/albertocalderari/incubator-airflow/issues/comments{/number}","contents_url":"https://api.github.com/repos/albertocalderari/incubator-airflow/contents/{+path}","compare_url":"https://api.github.com/repos/albertocalderari/incubator-airflow/compare/{base}...{head}","merges_url":"https://api.github.com/repos/albertocalderari/incubator-airflow/merges","archive_url":"https://api.github.com/repos/albertocalderari/incubator-airflow/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/albertocalderari/incubator-airflow/downloads","issues_url":"https://api.github.com/repos/albertocalderari/incubator-airflow/issues{/number}","pulls_url":"https://api.github.com/repos/albertocalderari/incubator-airflow/pulls{/number}","milestones_url":"https://api.github.com/repos/albertocalderari/incubator-airflow/milestones{/number}","notifications_url":"https://api.github.com/repos/albertocalderari/incubator-airflow/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/albertocalderari/incubator-airflow/labels{/name}","releases_url":"https://api.github.com/repos/albertocalderari/incubator-airflow/releases{/id}","deployments_url":"https://api.github.com/repos/albertocalderari/incubator-airflow/deployments","created_at":"2018-02-15T16:50:41Z","updated_at":"2018-03-18T14:42:51Z","pushed_at":"2018-03-18T14:42:50Z","git_url":"git://github.com/albertocalderari/incubator-airflow.git","ssh_url":"git@github.com:albertocalderari/incubator-airflow.git","clone_url":"https://github.com/albertocalderari/incubator-airflow.git","svn_url":"https://github.com/albertocalderari/incubator-airflow","homepage":"","size":15916,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"a15bd804815aac74a4ca4b8cf6985dd7455a7889","user":{"login":"apache","id":47359,"avatar_url":"https://avatars0.githubusercontent.com/u/47359?v=4","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":33884891,"name":"incubator-airflow","full_name":"apache/incubator-airflow","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars0.githubusercontent.com/u/47359?v=4","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/incubator-airflow","description":"Apache Airflow (Incubating)","fork":false,"url":"https://api.github.com/repos/apache/incubator-airflow","forks_url":"https://api.github.com/repos/apache/incubator-airflow/forks","keys_url":"https://api.github.com/repos/apache/incubator-airflow/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/incubator-airflow/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/incubator-airflow/teams","hooks_url":"https://api.github.com/repos/apache/incubator-airflow/hooks","issue_events_url":"https://api.github.com/repos/apache/incubator-airflow/issues/events{/number}","events_url":"https://api.github.com/repos/apache/incubator-airflow/events","assignees_url":"https://api.github.com/repos/apache/incubator-airflow/assignees{/user}","branches_url":"https://api.github.com/repos/apache/incubator-airflow/branches{/branch}","tags_url":"https://api.github.com/repos/apache/incubator-airflow/tags","blobs_url":"https://api.github.com/repos/apache/incubator-airflow/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/incubator-airflow/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/incubator-airflow/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/incubator-airflow/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/incubator-airflow/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/incubator-airflow/languages","stargazers_url":"https://api.github.com/repos/apache/incubator-airflow/stargazers","contributors_url":"https://api.github.com/repos/apache/incubator-airflow/contributors","subscribers_url":"https://api.github.com/repos/apache/incubator-airflow/subscribers","subscription_url":"https://api.github.com/repos/apache/incubator-airflow/subscription","commits_url":"https://api.github.com/repos/apache/incubator-airflow/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/incubator-airflow/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/incubator-airflow/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/incubator-airflow/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/incubator-airflow/contents/{+path}","compare_url":"https://api.github.com/repos/apache/incubator-airflow/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/incubator-airflow/merges","archive_url":"https://api.github.com/repos/apache/incubator-airflow/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/incubator-airflow/downloads","issues_url":"https://api.github.com/repos/apache/incubator-airflow/issues{/number}","pulls_url":"https://api.github.com/repos/apache/incubator-airflow/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/incubator-airflow/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/incubator-airflow/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/incubator-airflow/labels{/name}","releases_url":"https://api.github.com/repos/apache/incubator-airflow/releases{/id}","deployments_url":"https://api.github.com/repos/apache/incubator-airflow/deployments","created_at":"2015-04-13T18:04:58Z","updated_at":"2018-04-30T06:42:49Z","pushed_at":"2018-04-30T06:42:25Z","git_url":"git://github.com/apache/incubator-airflow.git","ssh_url":"git@github.com:apache/incubator-airflow.git","clone_url":"https://github.com/apache/incubator-airflow.git","svn_url":"https://github.com/apache/incubator-airflow","homepage":"","size":19361,"stargazers_count":7843,"watchers_count":7843,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2511,"mirror_url":null,"archived":false,"open_issues_count":331,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":2511,"open_issues":331,"watchers":7843,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-airflow/pulls/3071"},"html":{"href":"https://github.com/apache/incubator-airflow/pull/3071"},"issue":{"href":"https://api.github.com/repos/apache/incubator-airflow/issues/3071"},"comments":{"href":"https://api.github.com/repos/apache/incubator-airflow/issues/3071/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/incubator-airflow/pulls/3071/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/incubator-airflow/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/incubator-airflow/pulls/3071/commits"},"statuses":{"href":"https://api.github.com/repos/apache/incubator-airflow/statuses/3ff0efd95baa06c44a3945792417bb6369794f57"}},"author_association":"NONE"}}
{"actor":{"display_login":"Fokko"}}