Skip to content

Commit

Permalink
Merge pull request #46 from mgmarino/fix_view_post
Browse files Browse the repository at this point in the history
Remove special handling of post/put in _make_request.
  • Loading branch information
garbados committed Sep 22, 2014
2 parents fb9bbf9 + ef8f3f4 commit e4d17e2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cloudant/resource.py
Expand Up @@ -88,7 +88,7 @@ def _make_request(self, method, path='', **kwargs):

# normalize `params` kwarg according to method
if 'params' in opts:
if method in ['post', 'put']:
if method in ['post', 'put'] and 'data' not in opts:
opts['data'] = json.dumps(opts['params'])
del opts['params']
else:
Expand Down
19 changes: 19 additions & 0 deletions test/__init__.py
Expand Up @@ -3,6 +3,7 @@
from types import GeneratorType
import signal
import time
import json
import unittest


Expand Down Expand Up @@ -327,6 +328,24 @@ def testQueryParams(self):
response = view.get(params=dict(reduce=False))
assert 'reduce=False' not in response.url

def testMultiKeyViewQuery(self):
"""
Test using multi-key view query (post to view)
"""
view = self.db.all_docs()
d = [self.doc_name, self.otherdoc_name]
response = view.post(params=dict(reduce=False),
data=json.dumps(dict(keys=d)))
assert 'reduce=false' in response.url
assert response.status_code == 200
key_return = response.json()['rows']
assert len(key_return) == len(d)

# The documents weren't in there, so make sure they are not found
for adoc in key_return:
assert adoc["key"] in d
assert "error" in adoc

def tearDown(self):
assert self.db.delete().status_code == 200

Expand Down

0 comments on commit e4d17e2

Please sign in to comment.