Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't persist headers across requests #39

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion intuitlib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def send_request(method, url, header, obj, body=None, session=None, oauth1_heade
:return: requests object
"""

headers = ACCEPT_HEADER
headers = ACCEPT_HEADER.copy()
header.update(headers)

if session is not None and isinstance(session, Session):
Expand Down
8 changes: 7 additions & 1 deletion tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from urlparse import urlparse, parse_qs, urlsplit

from intuitlib.enums import Scopes
from intuitlib.config import ACCEPT_HEADER
from intuitlib.client import AuthClient
from intuitlib.exceptions import AuthClientError
from tests.helper import MockResponse
Expand Down Expand Up @@ -91,12 +92,17 @@ def test_exceptions_all_bad_request(self, mock_post):

@mock.patch('intuitlib.utils.requests.Session.request')
def test_get_user_info_ok(self, mock_session):

header_before_call = ACCEPT_HEADER.copy()

mock_resp = self.mock_request(status=200, content={
'givenName': 'Test'
})
mock_session.return_value = mock_resp

response = self.auth_client.get_user_info(access_token='token')
# verify that we didn't pollute the default headers used for subsequent calls.
assert header_before_call == ACCEPT_HEADER.copy()
assert response.json()['givenName'] == 'Test'

@mock.patch('intuitlib.utils.requests.Session.request')
Expand All @@ -108,4 +114,4 @@ def test_revoke_ok(self, mock_session):
assert response

if __name__ == '__main__':
pytest.main()
pytest.main()