diff options
| author | Vitaly Gridnev <vgridnev@mirantis.com> | 2017-03-07 13:38:22 +0400 |
|---|---|---|
| committer | Vitaly Gridnev <gridnevvvit@gmail.com> | 2017-03-08 00:50:55 +0400 |
| commit | 028c4824d0190e0b605ae9c90756167083e46cd3 (patch) | |
| tree | d8a47a3a8633301d59dfc6aea8f70362c73f84ec /tests/unit/test_utils.py | |
| parent | 91de5e8a385178b58cfeeb702c005ec2f2c5068a (diff) | |
| download | python-swiftclient-028c4824d0190e0b605ae9c90756167083e46cd3.tar.gz | |
Fix logging of the gzipped body
Change-Id: I6d7ccbf4ef9b46e890ecec58842c5cdd2804c7a9
Closes-bug: 1670620
Diffstat (limited to 'tests/unit/test_utils.py')
| -rw-r--r-- | tests/unit/test_utils.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py index cbea8d8..c5961e8 100644 --- a/tests/unit/test_utils.py +++ b/tests/unit/test_utils.py @@ -507,3 +507,21 @@ class TestApiResponeParser(unittest.TestCase): {'content-encoding': 'gzip'}, buf.getvalue()) self.assertEqual({'test': u'\u2603'}, result) + + +class TestGetBody(unittest.TestCase): + + def test_not_gzipped(self): + result = u.parse_api_response( + {}, u'{"test": "\\u2603"}'.encode('utf8')) + self.assertEqual({'test': u'\u2603'}, result) + + def test_gzipped_body(self): + buf = six.BytesIO() + gz = gzip.GzipFile(fileobj=buf, mode='w') + gz.write(u'{"test": "\u2603"}'.encode('utf8')) + gz.close() + result = u.parse_api_response( + {'content-encoding': 'gzip'}, + buf.getvalue()) + self.assertEqual({'test': u'\u2603'}, result) |
