summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Falcão <gabriel@nacaolivre.org>2013-02-19 07:48:34 -0800
committerGabriel Falcão <gabriel@nacaolivre.org>2013-02-19 07:48:34 -0800
commitfc7c06d55127b9b1b229544e125ed313c381d974 (patch)
treedb7aceaf7b763ee721e12dda1bcc5c8172c4519c
parenta77df07f8e0db89070bf41bcdd784654ac9f7df0 (diff)
parent0ba80350b7a581b7dea2472a9946a2c822f47c60 (diff)
downloadhttpretty-fc7c06d55127b9b1b229544e125ed313c381d974.tar.gz
Merge pull request #33 from hughsaunders/master
fix missing dictionary conversion in URIMatcher.get_next_entry.
-rw-r--r--httpretty/__init__.py2
-rw-r--r--tests/functional/test_requests.py32
2 files changed, 33 insertions, 1 deletions
diff --git a/httpretty/__init__.py b/httpretty/__init__.py
index 579b034..d52376e 100644
--- a/httpretty/__init__.py
+++ b/httpretty/__init__.py
@@ -692,7 +692,7 @@ class URIMatcher(object):
% (method, self))
entry = entries_for_method[self.current_entries[method]]
- if self.current_entries != -1:
+ if self.current_entries[method] != -1:
self.current_entries[method] += 1
return entry
diff --git a/tests/functional/test_requests.py b/tests/functional/test_requests.py
index 8a69e08..7757dea 100644
--- a/tests/functional/test_requests.py
+++ b/tests/functional/test_requests.py
@@ -450,3 +450,35 @@ def test_httpretty_should_allow_multiple_methods_for_the_same_uri():
for method in methods:
request_action = getattr(requests, method.lower())
expect(request_action(url).text).to.equal(method)
+
+
+@httprettified
+def test_httpretty_should_allow_multiple_responses_with_multiple_methods():
+ u"HTTPretty should allow multiple responses when binding multiple methods to the same uri"
+
+ url = 'http://test.com/list'
+
+ #add get responses
+ HTTPretty.register_uri(HTTPretty.GET, url,
+ responses=[HTTPretty.Response(body='a'),
+ HTTPretty.Response(body='b')
+ ]
+ )
+
+ #add post responses
+ HTTPretty.register_uri(HTTPretty.POST, url,
+ responses=[HTTPretty.Response(body='c'),
+ HTTPretty.Response(body='d')
+ ]
+ )
+
+ expect(requests.get(url).text).to.equal('a')
+ expect(requests.post(url).text).to.equal('c')
+
+ expect(requests.get(url).text).to.equal('b')
+ expect(requests.get(url).text).to.equal('b')
+ expect(requests.get(url).text).to.equal('b')
+
+ expect(requests.post(url).text).to.equal('d')
+ expect(requests.post(url).text).to.equal('d')
+ expect(requests.post(url).text).to.equal('d') \ No newline at end of file