diff options
| author | Gabriel Falcao <gabriel@nacaolivre.org> | 2012-11-07 20:43:46 -0500 |
|---|---|---|
| committer | Gabriel Falcao <gabriel@nacaolivre.org> | 2012-11-07 20:43:46 -0500 |
| commit | b5abd310fa4d48482a0eb6961c61467645f3dfba (patch) | |
| tree | 8f53c925fb2fa4f6e6a33e81082e97b3da37340f /tests | |
| parent | a02156dbb9ddbcc82eb7378a0885c9068bf679af (diff) | |
| download | httpretty-b5abd310fa4d48482a0eb6961c61467645f3dfba.tar.gz | |
fixing all tests
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/functional/test_httplib2.py | 31 | ||||
| -rw-r--r-- | tests/functional/test_urllib2.py | 15 |
2 files changed, 23 insertions, 23 deletions
diff --git a/tests/functional/test_httplib2.py b/tests/functional/test_httplib2.py index 8c3dc6c..0e18093 100644 --- a/tests/functional/test_httplib2.py +++ b/tests/functional/test_httplib2.py @@ -55,13 +55,13 @@ def test_httpretty_should_mock_headers_httplib2(now): headers, _ = httplib2.Http().request('http://github.com', 'GET') assert that(headers['status']).equals('201') - assert that(headers).equals({ - 'content-type': 'text/plain', + assert that(dict(headers)).equals({ + 'content-type': 'text/plain; charset=utf-8', 'connection': 'close', 'content-length': '35', 'status': '201', 'server': 'Python/HTTPretty', - 'date': now.strftime('%a, %d %b %Y %H:%M:%SGMT'), + 'date': now.strftime('%a, %d %b %Y %H:%M:%S GMT'), }) @@ -70,7 +70,7 @@ def test_httpretty_should_mock_headers_httplib2(now): def test_httpretty_should_allow_adding_and_overwritting_httplib2(now): u"HTTPretty should allow adding and overwritting headers with httplib2" - HTTPretty.register_uri(HTTPretty.GET, "http://github.com/", + HTTPretty.register_uri(HTTPretty.GET, "http://github.com/foo", body="this is supposed to be the response", adding_headers={ 'Server': 'Apache', @@ -78,11 +78,11 @@ def test_httpretty_should_allow_adding_and_overwritting_httplib2(now): 'Content-Type': 'application/json', }) - headers, _ = httplib2.Http().request('http://github.com', 'GET') + headers, _ = httplib2.Http().request('http://github.com/foo', 'GET') - assert that(headers).equals({ + assert that(dict(headers)).equals({ 'content-type': 'application/json', - 'content-location': 'http://github.com/', + 'content-location': 'http://github.com/foo', 'connection': 'close', 'content-length': '27', 'status': '200', @@ -96,16 +96,16 @@ def test_httpretty_should_allow_adding_and_overwritting_httplib2(now): def test_httpretty_should_allow_forcing_headers_httplib2(now): u"HTTPretty should allow forcing headers with httplib2" - HTTPretty.register_uri(HTTPretty.GET, "http://github.com/", + HTTPretty.register_uri(HTTPretty.GET, "http://github.com/foo", body="this is supposed to be the response", forcing_headers={ 'Content-Type': 'application/xml', }) - headers, _ = httplib2.Http().request('http://github.com', 'GET') + headers, _ = httplib2.Http().request('http://github.com/foo', 'GET') - assert that(headers).equals({ - 'content-location': 'http://github.com/', # httplib2 FORCES + assert that(dict(headers)).equals({ + 'content-location': 'http://github.com/foo', # httplib2 FORCES # content-location # even if the # server does not @@ -121,17 +121,17 @@ def test_httpretty_should_allow_adding_and_overwritting_by_kwargs_u2(now): u"HTTPretty should allow adding and overwritting headers by keyword args " \ "with httplib2" - HTTPretty.register_uri(HTTPretty.GET, "http://github.com/", + HTTPretty.register_uri(HTTPretty.GET, "http://github.com/foo", body="this is supposed to be the response", server='Apache', content_length='27', content_type='application/json') - headers, _ = httplib2.Http().request('http://github.com', 'GET') + headers, _ = httplib2.Http().request('http://github.com/foo', 'GET') - assert that(headers).equals({ + assert that(dict(headers)).equals({ 'content-type': 'application/json', - 'content-location': 'http://github.com/', # httplib2 FORCES + 'content-location': 'http://github.com/foo', # httplib2 FORCES # content-location # even if the # server does not @@ -225,4 +225,3 @@ def test_can_inspect_last_request_with_ssl(now): 'text/json', ) assert that(body).equals('{"repositories": ["HTTPretty", "lettuce"]}') - diff --git a/tests/functional/test_urllib2.py b/tests/functional/test_urllib2.py index aadf120..b1d049b 100644 --- a/tests/functional/test_urllib2.py +++ b/tests/functional/test_urllib2.py @@ -54,15 +54,16 @@ def test_httpretty_should_mock_headers_urllib2(now): status=201) request = urllib2.urlopen('http://github.com') + headers = dict(request.headers) request.close() assert that(request.code).equals(201) assert that(headers).equals({ - 'content-type': 'text/plain', + 'content-type': 'text/plain; charset=utf-8', 'connection': 'close', 'content-length': '35', - 'status': '201 Created', + 'status': '201', 'server': 'Python/HTTPretty', 'date': now.strftime('%a, %d %b %Y %H:%M:%S GMT'), }) @@ -90,7 +91,7 @@ def test_httpretty_should_allow_adding_and_overwritting_urllib2(now): 'content-type': 'application/json', 'connection': 'close', 'content-length': '27', - 'status': '200 OK', + 'status': '200', 'server': 'Apache', 'date': now.strftime('%a, %d %b %Y %H:%M:%S GMT'), }) @@ -123,9 +124,9 @@ def test_httpretty_should_allow_adding_and_overwritting_by_kwargs_u2(now): "keyword args with urllib2" HTTPretty.register_uri(HTTPretty.GET, "http://github.com/", - body="this is supposed to be the response", + body="this is supposed to be the response, indeed", server='Apache', - content_length='23456789', + content_length='111111', content_type='application/json') request = urllib2.urlopen('http://github.com') @@ -136,8 +137,8 @@ def test_httpretty_should_allow_adding_and_overwritting_by_kwargs_u2(now): assert that(headers).equals({ 'content-type': 'application/json', 'connection': 'close', - 'content-length': '23456789', - 'status': '200 OK', + 'content-length': '111111', + 'status': '200', 'server': 'Apache', 'date': now.strftime('%a, %d %b %Y %H:%M:%S GMT'), }) |
