Merge "Fix and enable remaining v1 tests on py35."
This commit is contained in:
commit
16de72b4b4
@ -47,13 +47,13 @@ class TestApi(functional.FunctionalTest):
|
||||
response, content = http.request(
|
||||
path, 'POST', headers=headers, body=image_data)
|
||||
self.assertEqual(status, response.status)
|
||||
return content
|
||||
return content.decode()
|
||||
|
||||
def test_checksum_32_chars_at_image_create(self):
|
||||
self.cleanup()
|
||||
self.start_servers(**self.__dict__.copy())
|
||||
headers = minimal_headers('Image1')
|
||||
image_data = "*" * FIVE_KB
|
||||
image_data = b"*" * FIVE_KB
|
||||
|
||||
# checksum can be no longer that 32 characters (String(32))
|
||||
headers['X-Image-Meta-Checksum'] = 'x' * 42
|
||||
@ -71,7 +71,7 @@ class TestApi(functional.FunctionalTest):
|
||||
for param in ['min_disk', 'min_ram']:
|
||||
headers = minimal_headers('Image1')
|
||||
# check that long numbers result in 400
|
||||
headers['X-Image-Meta-%s' % param] = str(sys.maxint + 1)
|
||||
headers['X-Image-Meta-%s' % param] = str(sys.maxsize + 1)
|
||||
content = self._check_image_create(headers,
|
||||
http_client.BAD_REQUEST)
|
||||
self.assertIn("'%s' value out of range" % param, content)
|
||||
@ -94,18 +94,18 @@ class TestApi(functional.FunctionalTest):
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(http_client.OK, response.status)
|
||||
self.assertEqual('{"images": []}', content)
|
||||
self.assertEqual('{"images": []}', content.decode())
|
||||
|
||||
# Verify no public images
|
||||
path = "http://%s:%d/v1/images/detail" % ("127.0.0.1", self.api_port)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(http_client.OK, response.status)
|
||||
self.assertEqual('{"images": []}', content)
|
||||
self.assertEqual('{"images": []}', content.decode())
|
||||
|
||||
# POST /images with private image named Image1
|
||||
# attribute and no custom properties. Verify a 200 OK is returned
|
||||
image_data = "*" * FIVE_KB
|
||||
image_data = b"*" * FIVE_KB
|
||||
headers = minimal_headers('Image1', public=False)
|
||||
path = "http://%s:%d/v1/images" % ("127.0.0.1", self.api_port)
|
||||
http = httplib2.Http()
|
||||
@ -154,8 +154,8 @@ class TestApi(functional.FunctionalTest):
|
||||
expected_value,
|
||||
response[expected_key]))
|
||||
|
||||
self.assertEqual("*" * FIVE_KB, content)
|
||||
self.assertEqual(hashlib.md5("*" * FIVE_KB).hexdigest(),
|
||||
self.assertEqual(image_data, content)
|
||||
self.assertEqual(hashlib.md5(image_data).hexdigest(),
|
||||
hashlib.md5(content).hexdigest())
|
||||
|
||||
# PUT image with custom properties to make public and then
|
||||
@ -271,7 +271,7 @@ class TestApi(functional.FunctionalTest):
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(http_client.OK, response.status)
|
||||
self.assertEqual('{"images": []}', content)
|
||||
self.assertEqual('{"images": []}', content.decode())
|
||||
|
||||
# 1. GET /images/detail
|
||||
# Verify no public images
|
||||
@ -279,11 +279,11 @@ class TestApi(functional.FunctionalTest):
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(http_client.OK, response.status)
|
||||
self.assertEqual('{"images": []}', content)
|
||||
self.assertEqual('{"images": []}', content.decode())
|
||||
|
||||
# 2. POST /images with public image named Image1
|
||||
# attribute and no custom properties. Verify a 200 OK is returned
|
||||
image_data = "*" * FIVE_KB
|
||||
image_data = b"*" * FIVE_KB
|
||||
headers = minimal_headers('Image1')
|
||||
path = "http://%s:%d/v1/images" % ("127.0.0.1", self.api_port)
|
||||
http = httplib2.Http()
|
||||
@ -342,8 +342,8 @@ class TestApi(functional.FunctionalTest):
|
||||
expected_value,
|
||||
response[expected_key]))
|
||||
|
||||
self.assertEqual("*" * FIVE_KB, content)
|
||||
self.assertEqual(hashlib.md5("*" * FIVE_KB).hexdigest(),
|
||||
self.assertEqual(image_data, content)
|
||||
self.assertEqual(hashlib.md5(image_data).hexdigest(),
|
||||
hashlib.md5(content).hexdigest())
|
||||
|
||||
# 5. GET /images
|
||||
@ -546,7 +546,7 @@ class TestApi(functional.FunctionalTest):
|
||||
# 18. POST /images with another public image named Image2
|
||||
# attribute and three custom properties, "distro", "arch" & "foo".
|
||||
# Verify a 200 OK is returned
|
||||
image_data = "*" * FIVE_KB
|
||||
image_data = b"*" * FIVE_KB
|
||||
headers = minimal_headers('Image2')
|
||||
headers['X-Image-Meta-Property-Distro'] = 'Ubuntu'
|
||||
headers['X-Image-Meta-Property-Arch'] = 'i386'
|
||||
@ -735,7 +735,7 @@ class TestApi(functional.FunctionalTest):
|
||||
self.cleanup()
|
||||
self.start_servers(**self.__dict__.copy())
|
||||
|
||||
image_data = "*" * FIVE_KB
|
||||
image_data = b"*" * FIVE_KB
|
||||
headers = minimal_headers('Image1')
|
||||
path = "http://%s:%d/v1/images" % ("127.0.0.1", self.api_port)
|
||||
http = httplib2.Http()
|
||||
@ -814,7 +814,7 @@ class TestApi(functional.FunctionalTest):
|
||||
self.cleanup()
|
||||
self.start_servers(**self.__dict__.copy())
|
||||
|
||||
image_data = "*" * FIVE_KB
|
||||
image_data = b"*" * FIVE_KB
|
||||
headers = minimal_headers('Image1')
|
||||
path = "http://%s:%d/v1/images" % ("127.0.0.1", self.api_port)
|
||||
http = httplib2.Http()
|
||||
|
@ -56,7 +56,7 @@ class TestCopyToFile(functional.FunctionalTest):
|
||||
|
||||
# POST /images with public image to be stored in from_store,
|
||||
# to stand in for the 'external' image
|
||||
image_data = "*" * FIVE_KB
|
||||
image_data = b"*" * FIVE_KB
|
||||
headers = {'Content-Type': 'application/octet-stream',
|
||||
'X-Image-Meta-Name': 'external',
|
||||
'X-Image-Meta-Store': from_store,
|
||||
@ -110,8 +110,8 @@ class TestCopyToFile(functional.FunctionalTest):
|
||||
self.assertEqual(http_client.OK, response.status)
|
||||
self.assertEqual(str(FIVE_KB), response['content-length'])
|
||||
|
||||
self.assertEqual("*" * FIVE_KB, content)
|
||||
self.assertEqual(hashlib.md5("*" * FIVE_KB).hexdigest(),
|
||||
self.assertEqual(image_data, content)
|
||||
self.assertEqual(hashlib.md5(image_data).hexdigest(),
|
||||
hashlib.md5(content).hexdigest())
|
||||
self.assertEqual(FIVE_KB, data['image']['size'])
|
||||
self.assertEqual("copied", data['image']['name'])
|
||||
@ -132,8 +132,8 @@ class TestCopyToFile(functional.FunctionalTest):
|
||||
self.assertEqual(http_client.OK, response.status)
|
||||
self.assertEqual(str(FIVE_KB), response['content-length'])
|
||||
|
||||
self.assertEqual("*" * FIVE_KB, content)
|
||||
self.assertEqual(hashlib.md5("*" * FIVE_KB).hexdigest(),
|
||||
self.assertEqual(image_data, content)
|
||||
self.assertEqual(hashlib.md5(image_data).hexdigest(),
|
||||
hashlib.md5(content).hexdigest())
|
||||
self.assertEqual(FIVE_KB, data['image']['size'])
|
||||
self.assertEqual("copied", data['image']['name'])
|
||||
@ -202,8 +202,8 @@ class TestCopyToFile(functional.FunctionalTest):
|
||||
self.assertEqual(http_client.OK, response.status)
|
||||
|
||||
self.assertEqual(str(FIVE_KB), response['content-length'])
|
||||
self.assertEqual("*" * FIVE_KB, content)
|
||||
self.assertEqual(hashlib.md5("*" * FIVE_KB).hexdigest(),
|
||||
self.assertEqual(b"*" * FIVE_KB, content)
|
||||
self.assertEqual(hashlib.md5(b"*" * FIVE_KB).hexdigest(),
|
||||
hashlib.md5(content).hexdigest())
|
||||
|
||||
# DELETE copied image
|
||||
@ -238,7 +238,7 @@ class TestCopyToFile(functional.FunctionalTest):
|
||||
self.assertEqual(http_client.NOT_FOUND, response.status, content)
|
||||
|
||||
expected = 'HTTP datastore could not find image at URI.'
|
||||
self.assertIn(expected, content)
|
||||
self.assertIn(expected, content.decode())
|
||||
|
||||
self.stop_servers()
|
||||
|
||||
@ -252,7 +252,7 @@ class TestCopyToFile(functional.FunctionalTest):
|
||||
self.start_servers(**self.__dict__.copy())
|
||||
|
||||
with tempfile.NamedTemporaryFile() as image_file:
|
||||
image_file.write("XXX")
|
||||
image_file.write(b"XXX")
|
||||
image_file.flush()
|
||||
copy_from = 'file://' + image_file.name
|
||||
|
||||
@ -269,7 +269,7 @@ class TestCopyToFile(functional.FunctionalTest):
|
||||
|
||||
expected = 'External sources are not supported: \'%s\'' % copy_from
|
||||
msg = 'expected "%s" in "%s"' % (expected, content)
|
||||
self.assertIn(expected, content, msg)
|
||||
self.assertIn(expected, content.decode(), msg)
|
||||
|
||||
self.stop_servers()
|
||||
|
||||
@ -295,6 +295,6 @@ class TestCopyToFile(functional.FunctionalTest):
|
||||
|
||||
expected = 'External sources are not supported: \'swift+config://xxx\''
|
||||
msg = 'expected "%s" in "%s"' % (expected, content)
|
||||
self.assertIn(expected, content, msg)
|
||||
self.assertIn(expected, content.decode(), msg)
|
||||
|
||||
self.stop_servers()
|
||||
|
2
tox.ini
2
tox.ini
@ -52,6 +52,8 @@ commands =
|
||||
glance.tests.functional.db.test_simple \
|
||||
glance.tests.functional.db.test_sqlalchemy \
|
||||
glance.tests.functional.db.test_rpc_endpoint \
|
||||
glance.tests.functional.v1.test_api \
|
||||
glance.tests.functional.v1.test_copy_to_file \
|
||||
glance.tests.functional.v1.test_misc \
|
||||
glance.tests.functional.v1.test_multiprocessing \
|
||||
glance.tests.functional.v2.test_metadef_objects \
|
||||
|
Loading…
x
Reference in New Issue
Block a user