Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions rester/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import apirunner
17 changes: 16 additions & 1 deletion rester/exc.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,17 @@ def _build_param_dict(self, test_step):
params[key] = self.case.variables.expand(value)
return params

def _build_data_dict(self, test_step):
data = {}
if hasattr(test_step, 'payload') and test_step.payload is not None:
print "PAYLOAD %r", test_step.payload
print "PAYLOAD ITEMS %r", test_step.payload.items()
for key, value in test_step.payload.items():
print "KEY %r", key
print "VALUE %r", value
data[key] = self.case.variables.expand(value)
return data

def _execute_test_step(self, test_step):
http_client = HttpClient(**self.case.request_opts)
failures = Failure([], None)
Expand All @@ -83,9 +94,13 @@ def _execute_test_step(self, test_step):
# process and set up params
params = self._build_param_dict(test_step)

# process and set up data
data = self._build_data_dict(test_step)

url = self.case.variables.expand(test_step.apiUrl)
self.logger.debug('Evaluated URL : %s', url)
response_wrapper = http_client.request(url, method, headers, params, is_raw)
self.logger.debug('Sending Data : %s', data)
response_wrapper = http_client.request(url, method, headers, params, data, is_raw)

# expected_status = getattr(getattr(test_step, 'asserts'), 'status', 200)
# if response_wrapper.status != expected_status:
Expand Down
4 changes: 2 additions & 2 deletions rester/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class HttpClient(object):
def __init__(self, **kwargs):
self.extra_request_opts = kwargs

def request(self, api_url, method, headers, params, is_raw):
def request(self, api_url, method, headers, params, data, is_raw):
self.logger.info(
'\n Invoking REST Call... api_url: %s, method: %s, headers %s : ', api_url, method, headers)

Expand All @@ -20,7 +20,7 @@ def request(self, api_url, method, headers, params, is_raw):
except AttributeError:
self.logger.error('undefined HTTP method!!! %s', method)
raise
response = func(api_url, headers=headers, params=params, **self.extra_request_opts)
response = func(api_url, headers=headers, params=params, json=data, **self.extra_request_opts)

if is_raw or 'application/json' not in response.headers['content-type']:
payload = {"__raw__": response.text}
Expand Down