summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTim Burke <tim.burke@gmail.com>2016-08-23 16:17:21 -0700
committerTim Burke <tim.burke@gmail.com>2016-11-18 11:47:14 -0800
commita1e2bcde4a54a33054c7dcb31c3c3b0e6d72d021 (patch)
tree46a4d7b28a5c2ac4a317c7f2abede8159772510d /tests
parent12d42efad23f95461692af99a77136d7591a5fee (diff)
downloadpython-swiftclient-a1e2bcde4a54a33054c7dcb31c3c3b0e6d72d021.tar.gz
Accept more types of input for headers/meta
Previously, we only accepted iterables of strings like 'Header: Value'. Now, we'll also accept lists of tuples like ('Header', 'Value') as well as dictionaries like {'Header': 'Value'}. This should be more intuitive for application developers, who are already used to being able to pass dicts or lists of tuples to libraries like requests. Change-Id: I93ed2f1e8305f0168b7a4bd90c205b04730da836
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/test_service.py19
1 files changed, 16 insertions, 3 deletions
diff --git a/tests/unit/test_service.py b/tests/unit/test_service.py
index e8385b7..2fc827c 100644
--- a/tests/unit/test_service.py
+++ b/tests/unit/test_service.py
@@ -592,11 +592,24 @@ class TestServiceUtils(unittest.TestCase):
actual = swiftclient.service.split_headers(mock_headers, 'prefix-')
self.assertEqual(expected, actual)
- def test_split_headers_error(self):
- mock_headers = ['notvalid']
+ def test_split_headers_list_of_tuples(self):
+ mock_headers = [('color', 'blue'), ('size', 'large')]
+ expected = {'Prefix-Color': 'blue', 'Prefix-Size': 'large'}
+
+ actual = swiftclient.service.split_headers(mock_headers, 'prefix-')
+ self.assertEqual(expected, actual)
+ def test_split_headers_dict(self):
+ expected = {'Color': 'blue', 'Size': 'large'}
+
+ actual = swiftclient.service.split_headers(expected)
+ self.assertEqual(expected, actual)
+
+ def test_split_headers_error(self):
+ self.assertRaises(SwiftError, swiftclient.service.split_headers,
+ ['notvalid'])
self.assertRaises(SwiftError, swiftclient.service.split_headers,
- mock_headers)
+ [('also', 'not', 'valid')])
class TestSwiftUploadObject(unittest.TestCase):