diff --git a/src/RequestsLibrary/keywords.py b/src/RequestsLibrary/keywords.py index 03dff845..5eb7b147 100644 --- a/src/RequestsLibrary/keywords.py +++ b/src/RequestsLibrary/keywords.py @@ -1,4 +1,5 @@ import requests +import sys import json from urllib import urlencode @@ -129,7 +130,12 @@ def put(self, alias, uri, data=None, headers=None): """ session = self._cache.switch(alias) - resp = session.put(uri, data=urlencode(data), headers=headers) + if type(data) is dict: + resp = session.put(uri, data=urlencode(data), headers=headers) + else: + resp = session.put(uri, data=data, headers=headers) + + print resp.content # store the last response object session.last_resp = resp diff --git a/tests/testcase.txt b/tests/testcase.txt index 1c6621d1..3f0f6df9 100644 --- a/tests/testcase.txt +++ b/tests/testcase.txt @@ -34,6 +34,13 @@ Post Request With No Data ${resp} Post httpbin /post Should Be Equal As Strings ${resp.status_code} 200 + +Put Request With No Data + Create Session httpbin http://httpbin.org + ${resp} Put httpbin /put + Should Be Equal As Strings ${resp.status_code} 200 + + Post Request With No Dictionary Create Session httpbin http://httpbin.org Set Test Variable ${data} some content @@ -41,6 +48,15 @@ Post Request With No Dictionary Should Be Equal As Strings ${resp.status_code} 200 Should Contain ${resp.content} ${data} + +Put Request With No Dictionary + Create Session httpbin http://httpbin.org + Set Test Variable ${data} some content + ${resp} Put httpbin /put data=${data} + Should Be Equal As Strings ${resp.status_code} 200 + Should Contain ${resp.content} ${data} + + Post Requests Create Session httpbin http://httpbin.org