Skip to content

Commit

Permalink
Additional cleanup for GET request
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Greenfeld committed Apr 24, 2015
1 parent a9f6a09 commit b4e61b9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 20 deletions.
12 changes: 7 additions & 5 deletions eventbrite/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=()):
Expand All @@ -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=()):
Expand Down
16 changes: 1 addition & 15 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit b4e61b9

Please sign in to comment.