summaryrefslogtreecommitdiff
path: root/glanceclient/tests/unit
diff options
context:
space:
mode:
Diffstat (limited to 'glanceclient/tests/unit')
-rw-r--r--glanceclient/tests/unit/test_exc.py8
-rw-r--r--glanceclient/tests/unit/test_http.py8
-rw-r--r--glanceclient/tests/unit/v1/test_shell.py4
3 files changed, 18 insertions, 2 deletions
diff --git a/glanceclient/tests/unit/test_exc.py b/glanceclient/tests/unit/test_exc.py
index 575c62b..9a2d01f 100644
--- a/glanceclient/tests/unit/test_exc.py
+++ b/glanceclient/tests/unit/test_exc.py
@@ -68,3 +68,11 @@ class TestHTTPExceptions(testtools.TestCase):
self.assertIsInstance(err, exc.HTTPNotFound)
self.assertEqual("404 Entity Not Found: Entity could not be found",
err.details)
+
+ def test_format_no_content_type(self):
+ mock_resp = mock.Mock()
+ mock_resp.status_code = 400
+ mock_resp.headers = {'content-type': 'application/octet-stream'}
+ body = b'Error \n\n'
+ err = exc.from_response(mock_resp, body)
+ self.assertEqual('Error \n', err.details)
diff --git a/glanceclient/tests/unit/test_http.py b/glanceclient/tests/unit/test_http.py
index 28ae8e1..020e146 100644
--- a/glanceclient/tests/unit/test_http.py
+++ b/glanceclient/tests/unit/test_http.py
@@ -239,6 +239,14 @@ class TestClient(testtools.TestCase):
test_client = http.HTTPClient(endpoint, token=u'adc123')
self.assertEqual(600.0, test_client.timeout)
+ def test__chunk_body_exact_size_chunk(self):
+ test_client = http._BaseHTTPClient()
+ bytestring = b'x' * http.CHUNKSIZE
+ data = six.BytesIO(bytestring)
+ chunk = list(test_client._chunk_body(data))
+ self.assertEqual(1, len(chunk))
+ self.assertEqual([bytestring], chunk)
+
def test_http_chunked_request(self):
text = "Ok"
data = six.StringIO(text)
diff --git a/glanceclient/tests/unit/v1/test_shell.py b/glanceclient/tests/unit/v1/test_shell.py
index 93f3fe6..95bbd07 100644
--- a/glanceclient/tests/unit/v1/test_shell.py
+++ b/glanceclient/tests/unit/v1/test_shell.py
@@ -574,7 +574,7 @@ class ShellStdinHandlingTests(testtools.TestCase):
self.assertIn('data', self.collected_args[1])
self.assertIsInstance(self.collected_args[1]['data'], file_type)
- self.assertEqual('Some Data',
+ self.assertEqual(b'Some Data',
self.collected_args[1]['data'].read())
finally:
@@ -599,7 +599,7 @@ class ShellStdinHandlingTests(testtools.TestCase):
self.assertIn('data', self.collected_args[1])
self.assertIsInstance(self.collected_args[1]['data'], file_type)
- self.assertEqual('Some Data\n',
+ self.assertEqual(b'Some Data\n',
self.collected_args[1]['data'].read())
finally: