summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Falcão <gabriel@nacaolivre.org>2021-05-31 20:35:47 +0200
committerGabriel Falcão <gabriel@nacaolivre.org>2021-05-31 20:35:47 +0200
commit2bb69ae694e7cc10ad2e4859cfca950291b190ef (patch)
treede54c2570bc852f779f7136ca666fb0e48dd392d
parent5d795259edbbbd7650839d050017203711a44269 (diff)
downloadhttpretty-fix/399/multiple-instances-of-same-header.tar.gz
attempt to reproduce bug #399fix/399/multiple-instances-of-same-header
-rw-r--r--tests/bugfixes/nosetests/test_399_issuing_multiple_instances_of_same_header.py52
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/bugfixes/nosetests/test_399_issuing_multiple_instances_of_same_header.py b/tests/bugfixes/nosetests/test_399_issuing_multiple_instances_of_same_header.py
new file mode 100644
index 0000000..cbcbe4f
--- /dev/null
+++ b/tests/bugfixes/nosetests/test_399_issuing_multiple_instances_of_same_header.py
@@ -0,0 +1,52 @@
+import json
+import requests
+import httpretty
+from httpretty.errors import UnmockedError
+
+from unittest import skip
+from sure import expect
+
+
+@httpretty.activate(allow_net_connect=True)
+def test_multiple_instances_of_same_header():
+ "#399 - Issuing multiple instances of same header"
+
+ def callback(request, url, headers):
+ headers["Content-Type"] = "application/json"
+ headers["Date"] = "Mon, 31 May 2021 17:47:51 GMT"
+ headers["Set-Cookie"] = "foo;bar"
+
+ return 200, headers, json.dumps(dict(request.headers))
+
+ httpretty.register_uri(httpretty.GET, "https://httpbin.org/cookies", body=callback)
+
+ jar = requests.cookies.RequestsCookieJar()
+ jar.set("first_cookie", "first", domain="httpbin.org", path="/cookies")
+ jar.set("second_cookie", "second", domain="httpbin.org", path="/extra")
+ jar.set("third_cookie", "third", domain="httpbin.org", path="/cookies")
+ jar.set("fourth_cookie", "fourth", domain="httpbin.org", path="/")
+
+ url = "https://httpbin.org/cookies"
+ response = requests.get(url, cookies=jar)
+
+ response.json().should.equal(
+ {
+ "Accept": "*/*",
+ "Accept-Encoding": "gzip, deflate",
+ "Connection": "keep-alive",
+ "Cookie": "first_cookie=first; third_cookie=third; fourth_cookie=fourth",
+ "Host": "httpbin.org",
+ "User-Agent": "python-requests/2.25.1",
+ }
+ )
+ dict(response.headers).should.equal(
+ {
+ "connection": "close",
+ "content-length": "218",
+ "set-cookie": "foo;bar",
+ "content-type": "application/json",
+ "server": "Python/HTTPretty",
+ "date": "Mon, 31 May 2021 17:47:51 GMT",
+ "status": "200",
+ }
+ )