summaryrefslogtreecommitdiff
path: root/tests/unit/test_swiftclient.py
diff options
context:
space:
mode:
authorTim Burke <tim.burke@gmail.com>2016-08-25 10:51:29 -0700
committerTim Burke <tim.burke@gmail.com>2016-08-25 11:32:08 -0700
commitab60e08e2e34ac4a87bc6c1701c6ace69bb392cf (patch)
treeb955ac317d9463bb8a2a6f453f56fd116050ef04 /tests/unit/test_swiftclient.py
parent5acefd27e4e4de01414cc67f6652cc946b51957b (diff)
downloadpython-swiftclient-ab60e08e2e34ac4a87bc6c1701c6ace69bb392cf.tar.gz
Convert numeric and boolean header values to strings
Recently, requests got a bit more picky about what types of data it will accept as header values [1]. The reasons for this are generally sound; str()ing arbitrary objects just before pushing them out a socket may not do what the developer wanted/expected. However, there are a few standard types that developers may be sending that we should convert for them as a convenience. Now, we'll convert all int, float, and bool values to strings before sending them on to requests. Change-Id: I6c2f451009cb03cb78812f54e4ed8566076de821 Closes-Bug: 1614932
Diffstat (limited to 'tests/unit/test_swiftclient.py')
-rw-r--r--tests/unit/test_swiftclient.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/tests/unit/test_swiftclient.py b/tests/unit/test_swiftclient.py
index 4e4c9f4..09d8e76 100644
--- a/tests/unit/test_swiftclient.py
+++ b/tests/unit/test_swiftclient.py
@@ -185,9 +185,9 @@ class TestHttpHelpers(MockHttpTest):
def test_encode_meta_headers(self):
headers = {'abc': '123',
- u'x-container-meta-\u0394': '123',
- u'x-account-meta-\u0394': '123',
- u'x-object-meta-\u0394': '123'}
+ u'x-container-meta-\u0394': 123,
+ u'x-account-meta-\u0394': 12.3,
+ u'x-object-meta-\u0394': True}
r = swiftclient.encode_meta_headers(headers)
@@ -199,6 +199,7 @@ class TestHttpHelpers(MockHttpTest):
for k, v in r.items():
self.assertIs(type(k), binary_type)
self.assertIs(type(v), binary_type)
+ self.assertIn(v, (b'123', b'12.3', b'True'))
def test_set_user_agent_default(self):
_junk, conn = c.http_connection('http://www.example.com')