fix headers capitalization on Entry class
This commit is contained in:
@@ -480,7 +480,7 @@ class Entry(Py3kObject):
|
||||
self.status = int(status)
|
||||
|
||||
for k, v in headers.items():
|
||||
name = "-".join(k.split("_")).capitalize()
|
||||
name = "-".join(k.split("_")).title()
|
||||
self.adding_headers[name] = v
|
||||
|
||||
self.validate()
|
||||
|
||||
@@ -149,10 +149,11 @@ def test_httpretty_should_allow_adding_and_overwritting_by_kwargs_u2(now):
|
||||
u"HTTPretty should allow adding and overwritting headers by " \
|
||||
"keyword args with urllib2"
|
||||
|
||||
body = "this is supposed to be the response, indeed"
|
||||
HTTPretty.register_uri(HTTPretty.GET, "http://github.com/",
|
||||
body="this is supposed to be the response, indeed",
|
||||
body=body,
|
||||
server='Apache',
|
||||
content_length='111111',
|
||||
content_length=len(body),
|
||||
content_type='application/json')
|
||||
|
||||
request = urlopen('http://github.com')
|
||||
@@ -163,7 +164,7 @@ def test_httpretty_should_allow_adding_and_overwritting_by_kwargs_u2(now):
|
||||
expect(headers).to.equal({
|
||||
'content-type': 'application/json',
|
||||
'connection': 'close',
|
||||
'content-length': '111111',
|
||||
'content-length': str(len(body)),
|
||||
'status': '200',
|
||||
'server': 'Apache',
|
||||
'date': now.strftime('%a, %d %b %Y %H:%M:%S GMT'),
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from sure import expect
|
||||
from httpretty import HTTPretty, HTTPrettyError, STATUSES, URIInfo, Py3kObject
|
||||
from httpretty import HTTPretty, HTTPrettyError, STATUSES, URIInfo, Py3kObject, Entry
|
||||
|
||||
|
||||
def test_httpretty_should_raise_proper_exception_on_inconsistent_length():
|
||||
@@ -169,3 +169,14 @@ def test_py3kobject_implements_valid__repr__based_on__str__():
|
||||
|
||||
myobj = MyObject()
|
||||
expect(repr(myobj)).to.be.equal('hi')
|
||||
|
||||
|
||||
def test_Entry_class_normalizes_headers():
|
||||
entry = Entry(HTTPretty.GET, 'http://example.com', 'example',
|
||||
host='example.com', cache_control='no-cache', x_forward_for='proxy')
|
||||
|
||||
expect(entry.adding_headers).to.equal({
|
||||
u'Host': u'example.com',
|
||||
u'Cache-Control': u'no-cache',
|
||||
u'X-Forward-For': u'proxy'
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user