diff options
| author | Konstantinos Koukopoulos <koukopoulos@gmail.com> | 2014-04-07 10:18:53 +0300 |
|---|---|---|
| committer | Konstantinos Koukopoulos <koukopoulos@gmail.com> | 2014-04-07 10:18:53 +0300 |
| commit | 991f2b4fe70a0486f17436d2b3fcb2d38af62fbb (patch) | |
| tree | a94b891a89bd023fe8ae72ed11425121349b0fc2 | |
| parent | 7dc57141ab5ee16524303e875a1beee1d42f4511 (diff) | |
| download | httpretty-991f2b4fe70a0486f17436d2b3fcb2d38af62fbb.tar.gz | |
add a test for content-length header with callable body
| -rw-r--r-- | tests/functional/test_requests.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/functional/test_requests.py b/tests/functional/test_requests.py index 8a97254..b7ca85d 100644 --- a/tests/functional/test_requests.py +++ b/tests/functional/test_requests.py @@ -501,6 +501,24 @@ def test_callback_setting_headers_and_status_response(now): expect(response.status_code).to.equal(418) @httprettified +@within(two=microseconds) +def test_callback_setting_content_length_on_head(now): + ("HTTPretty should call a callback function, use it's return tuple as status code, headers and body" + " requests and respect the content-length header when responding to HEAD") + + def request_callback(request, uri, headers): + headers.update({'content-length': 12345}) + return [200,headers, ""] + + HTTPretty.register_uri( + HTTPretty.HEAD, "https://api.yahoo.com/test", + body=request_callback) + + response = requests.head('https://api.yahoo.com/test') + expect(response.headers).to.have.key('content-length').being.equal("12345") + expect(response.status_code).to.equal(200) + +@httprettified def test_httpretty_should_allow_registering_regexes_and_give_a_proper_match_to_the_callback(): "HTTPretty should allow registering regexes with requests and giva a proper match to the callback" |
