Skip to content

Commit

Permalink
Accepting json pyload
Browse files Browse the repository at this point in the history
  • Loading branch information
mohammadsheikhian committed Jul 14, 2018
1 parent 0eeedd2 commit fe46dd6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
6 changes: 5 additions & 1 deletion bddrest/specification/call.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import re
import sys
import json
from abc import ABCMeta, abstractmethod
from urllib.parse import urlparse, urlencode

Expand Down Expand Up @@ -128,7 +129,10 @@ def invoke(self, application) -> Response:
# upload_files=upload_files,
)
if self.form:
request_params['params'] = self.form
request_params['params'] = json.dumps(self.form) \
if self.content_type and \
self.content_type.startswith('application/json') \
else self.form

# noinspection PyProtectedMember
web_test_response = TestApp(application)._gen_request(
Expand Down
20 changes: 18 additions & 2 deletions bddrest/tests/test_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,12 @@ def test_call_to_dict():


def test_altered_call():
call = FirstCall('Testing AlteredCall contractor', url='/id: 1', query=dict(a=1))
call = FirstCall(
'Testing AlteredCall contractor',
url='/id: 1',
query=dict(a=1)
)

altered_call = AlteredCall(
call,
'Altering a call',
Expand Down Expand Up @@ -149,7 +154,12 @@ def test_alteredcall_setters_deleters():


def test_call_verify():
call = FirstCall('Testing FirstCall contractor', url='/id: 1', query=dict(a=1))
call = FirstCall(
'Testing FirstCall contractor',
url='/id: 1',
query=dict(a=1)
)

call.conclude(wsgi_application)
call.verify(wsgi_application)

Expand All @@ -175,3 +185,9 @@ def test_querystring_parser():
assert '/:id' == call.url
assert dict(a='1') == call.query


def test_form_parser():
pyload = dict(a=1, b=2)
call = FirstCall('Testing form parsing', form=pyload)
assert call.form == pyload

0 comments on commit fe46dd6

Please sign in to comment.