From b4e61b95bd4e414455bb62d08900694d9f90c40d Mon Sep 17 00:00:00 2001 From: Daniel Greenfeld Date: Fri, 24 Apr 2015 13:16:28 -0700 Subject: [PATCH] Additional cleanup for GET request --- eventbrite/client.py | 12 +++++++----- tests/test_client.py | 16 +--------------- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/eventbrite/client.py b/eventbrite/client.py index 9ea832b..8bc7eeb 100755 --- a/eventbrite/client.py +++ b/eventbrite/client.py @@ -35,15 +35,13 @@ def __init__(self, oauth_token): @property def headers(self): headers = { + "content-type": "application/json", "Authorization": "Bearer {0}".format(self.oauth_token), "User-Agent": "eventbrite-python-sdk {version} ({system})".format( version=__version__, system=platform(), ) } - # Resolves the search result response problem - if self.content_type_specified: - headers["content-type"] = "application/json" return headers def api(self, method, path, data, expansions=()): @@ -57,9 +55,13 @@ def api(self, method, path, data, expansions=()): @objectify def get(self, path, data=None, expansions=()): - self.content_type_specified = False + # Resolves the search result response problem + headers = self.headers + if headers.has_key('content-type'): + headers.pop('content-type') + # Get the function path path = format_path(path, self.eventbrite_api_url) - return requests.get(path, headers=self.headers, params=data or {}) + return requests.get(path, headers=headers, params=data or {}) @objectify def post(self, path, data=None, expansions=()): diff --git a/tests/test_client.py b/tests/test_client.py index 654b894..ddb06a5 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -20,18 +20,4 @@ def test_headers(): system=platform(), ) } - assert eventbrite.headers == expected_headers - - -def test_headers_without_content_type(): - """Should not have content-type""" - eventbrite = Eventbrite('12345') - eventbrite.content_type_specified = False - expected_headers = { - u'Authorization': u'Bearer 12345', - u'User-Agent': "eventbrite-python-sdk {version} ({system})".format( - version=__version__, - system=platform(), - ) - } - assert eventbrite.headers == expected_headers + assert eventbrite.headers == expected_headers \ No newline at end of file