Skip to content

Commit

Permalink
Put requests now support raw text data in parameter
Browse files Browse the repository at this point in the history
* closes #6
  • Loading branch information
bulkan committed Nov 1, 2012
1 parent 5baaddd commit 9b1d7aa
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/RequestsLibrary/keywords.py
@@ -1,4 +1,5 @@
import requests
import sys
import json

from urllib import urlencode
Expand Down Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions tests/testcase.txt
Expand Up @@ -34,13 +34,29 @@ 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
${resp} Post httpbin /post data=${data}
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

Expand Down

0 comments on commit 9b1d7aa

Please sign in to comment.