forked from quandl/quandl-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use POST request for some datatables routes if request length is long (…
…quandl#126) * Initial work on getting post requests working for datatable route * Initial work on getting post requests working for datatable export route * Additional work regarding post request body * Begin work on formatting post request arguments correctly * Format dictionary params correctly for post request * Update failing connection tests * Add .zip files to gitignore * Fix some failing tests due to httppretty * Add sanity tests for function determining request type * Add additional tests for modifying arguments to get/post request params * Add venv to flake8 ignore list * Run existing connection tests for both get and post requests * Fix some flake8 warnings * Update some datatable tests to account for get and post requests * Update some datatable data tests for get/post requests * Add config to always use post request for testing purposes * Add some more tests to ensure request made with correct params * Fix incorrect params format being passed to mocked tests * Add comment regarding 8000 character get request limit * Fix line being over 100 characters in length * Update version.py and changelog
- Loading branch information
Showing
18 changed files
with
437 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
*.pyc | ||
*.zip | ||
|
||
/.tox/ | ||
/.eggs | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
try: | ||
from urllib import urlencode | ||
except ImportError: | ||
from urllib.parse import urlencode | ||
|
||
from quandl.api_config import ApiConfig | ||
|
||
|
||
class RequestType(object): | ||
""" Determines whether a request should be made using a GET or a POST request. | ||
Default limit of 8000 is set here as it appears to be the maximum for many | ||
webservers. | ||
""" | ||
MAX_URL_LENGTH_FOR_GET = 8000 | ||
USE_GET_REQUEST = True # This is used to simplify testing code | ||
|
||
@classmethod | ||
def get_request_type(cls, url, **params): | ||
query_string = urlencode(params['params']) | ||
request_url = '%s/%s/%s' % (ApiConfig.api_base, url, query_string) | ||
if RequestType.USE_GET_REQUEST and (len(request_url) < cls.MAX_URL_LENGTH_FOR_GET): | ||
return 'get' | ||
else: | ||
return 'post' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
VERSION = '3.4.4' | ||
VERSION = '3.4.5' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import random | ||
import string | ||
|
||
|
||
def generate_random_string(n=10): | ||
return ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(n)) | ||
|
||
|
||
def generate_random_dictionary(n): | ||
random_dictionary = dict() | ||
for _ in range(n): | ||
random_dictionary[generate_random_string()] = generate_random_string() | ||
return random_dictionary |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.