Fix assertEqual arguments order
assertEqual method's arguments should be in ('expected', 'actual') order. Change-Id: I88b5b0558720a91236b62b6e4a3590901e817f85 Closes-bug: 1277104
This commit is contained in:
parent
e33667e9bb
commit
2365a3fb5f
|
@ -107,7 +107,7 @@ class TestSqlAlchemyDBDataIntegrity(base.TestDriver):
|
|||
|
||||
def fake_paginate_query(query, model, limit,
|
||||
sort_keys, marker, sort_dir):
|
||||
self.assertEqual(sort_keys, ['created_at', 'id'])
|
||||
self.assertEqual(['created_at', 'id'], sort_keys)
|
||||
return original_method(query, model, limit,
|
||||
sort_keys, marker, sort_dir)
|
||||
|
||||
|
@ -120,7 +120,7 @@ class TestSqlAlchemyDBDataIntegrity(base.TestDriver):
|
|||
|
||||
def fake_paginate_query(query, model, limit,
|
||||
sort_keys, marker, sort_dir):
|
||||
self.assertEqual(sort_keys, ['name', 'created_at', 'id'])
|
||||
self.assertEqual(['name', 'created_at', 'id'], sort_keys)
|
||||
return original_method(query, model, limit,
|
||||
sort_keys, marker, sort_dir)
|
||||
|
||||
|
|
|
@ -65,8 +65,8 @@ class TestRootApi(functional.FunctionalTest):
|
|||
path = 'http://%s:%d' % ('127.0.0.1', self.api_port)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(response.status, 300)
|
||||
self.assertEqual(content, versions_json)
|
||||
self.assertEqual(300, response.status)
|
||||
self.assertEqual(versions_json, content)
|
||||
self.stop_servers()
|
||||
|
||||
# v2 api enabled
|
||||
|
@ -99,8 +99,8 @@ class TestRootApi(functional.FunctionalTest):
|
|||
path = 'http://%s:%d' % ('127.0.0.1', self.api_port)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(response.status, 300)
|
||||
self.assertEqual(content, versions_json)
|
||||
self.assertEqual(300, response.status)
|
||||
self.assertEqual(versions_json, content)
|
||||
self.stop_servers()
|
||||
|
||||
# v1 api enabled
|
||||
|
@ -128,8 +128,8 @@ class TestRootApi(functional.FunctionalTest):
|
|||
path = 'http://%s:%d' % ('127.0.0.1', self.api_port)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(response.status, 300)
|
||||
self.assertEqual(content, versions_json)
|
||||
self.assertEqual(300, response.status)
|
||||
self.assertEqual(versions_json, content)
|
||||
self.stop_servers()
|
||||
|
||||
def test_version_variations(self):
|
||||
|
@ -176,16 +176,16 @@ class TestRootApi(functional.FunctionalTest):
|
|||
path = 'http://%s:%d' % ('127.0.0.1', self.api_port)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(response.status, 300)
|
||||
self.assertEqual(content, versions_json)
|
||||
self.assertEqual(300, response.status)
|
||||
self.assertEqual(versions_json, content)
|
||||
|
||||
# 1. GET /images with no Accept: header
|
||||
# Verify version choices returned.
|
||||
path = 'http://%s:%d/images' % ('127.0.0.1', self.api_port)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(response.status, 300)
|
||||
self.assertEqual(content, versions_json)
|
||||
self.assertEqual(300, response.status)
|
||||
self.assertEqual(versions_json, content)
|
||||
|
||||
# 2. GET /v1/images with no Accept: header
|
||||
# Verify empty images list returned.
|
||||
|
@ -202,8 +202,8 @@ class TestRootApi(functional.FunctionalTest):
|
|||
http = httplib2.Http()
|
||||
headers = {'Accept': 'unknown'}
|
||||
response, content = http.request(path, 'GET', headers=headers)
|
||||
self.assertEqual(response.status, 300)
|
||||
self.assertEqual(content, versions_json)
|
||||
self.assertEqual(300, response.status)
|
||||
self.assertEqual(versions_json, content)
|
||||
|
||||
# 4. GET / with an Accept: application/vnd.openstack.images-v1
|
||||
# Verify empty image list returned
|
||||
|
@ -221,38 +221,38 @@ class TestRootApi(functional.FunctionalTest):
|
|||
http = httplib2.Http()
|
||||
headers = {'Accept': 'application/vnd.openstack.compute-v1'}
|
||||
response, content = http.request(path, 'GET', headers=headers)
|
||||
self.assertEqual(response.status, 300)
|
||||
self.assertEqual(content, versions_json)
|
||||
self.assertEqual(300, response.status)
|
||||
self.assertEqual(versions_json, content)
|
||||
|
||||
# 6. GET /v1.0/images with no Accept: header
|
||||
# Verify version choices returned
|
||||
path = 'http://%s:%d/v1.a/images' % ('127.0.0.1', self.api_port)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(response.status, 300)
|
||||
self.assertEqual(300, response.status)
|
||||
|
||||
# 7. GET /v1.a/images with no Accept: header
|
||||
# Verify version choices returned
|
||||
path = 'http://%s:%d/v1.a/images' % ('127.0.0.1', self.api_port)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(response.status, 300)
|
||||
self.assertEqual(300, response.status)
|
||||
|
||||
# 8. GET /va.1/images with no Accept: header
|
||||
# Verify version choices returned
|
||||
path = 'http://%s:%d/va.1/images' % ('127.0.0.1', self.api_port)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(response.status, 300)
|
||||
self.assertEqual(content, versions_json)
|
||||
self.assertEqual(300, response.status)
|
||||
self.assertEqual(versions_json, content)
|
||||
|
||||
# 9. GET /versions with no Accept: header
|
||||
# Verify version choices returned
|
||||
path = 'http://%s:%d/versions' % ('127.0.0.1', self.api_port)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(response.status, 300)
|
||||
self.assertEqual(content, versions_json)
|
||||
self.assertEqual(300, response.status)
|
||||
self.assertEqual(versions_json, content)
|
||||
|
||||
# 10. GET /versions with a Accept: application/vnd.openstack.images-v1
|
||||
# header. Verify version choices returned.
|
||||
|
@ -260,8 +260,8 @@ class TestRootApi(functional.FunctionalTest):
|
|||
http = httplib2.Http()
|
||||
headers = {'Accept': 'application/vnd.openstack.images-v1'}
|
||||
response, content = http.request(path, 'GET', headers=headers)
|
||||
self.assertEqual(response.status, 300)
|
||||
self.assertEqual(content, versions_json)
|
||||
self.assertEqual(300, response.status)
|
||||
self.assertEqual(versions_json, content)
|
||||
|
||||
# 11. GET /v1/versions with no Accept: header
|
||||
# Verify 404 returned
|
||||
|
@ -274,8 +274,8 @@ class TestRootApi(functional.FunctionalTest):
|
|||
path = 'http://%s:%d/v10' % ('127.0.0.1', self.api_port)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(response.status, 300)
|
||||
self.assertEqual(content, versions_json)
|
||||
self.assertEqual(300, response.status)
|
||||
self.assertEqual(versions_json, content)
|
||||
|
||||
# 13. GET /images with a Accept: application/vnd.openstack.compute-v2
|
||||
# header. Verify version choices returned. Verify message in API log
|
||||
|
@ -284,15 +284,15 @@ class TestRootApi(functional.FunctionalTest):
|
|||
http = httplib2.Http()
|
||||
headers = {'Accept': 'application/vnd.openstack.images-v10'}
|
||||
response, content = http.request(path, 'GET', headers=headers)
|
||||
self.assertEqual(response.status, 300)
|
||||
self.assertEqual(content, versions_json)
|
||||
self.assertEqual(300, response.status)
|
||||
self.assertEqual(versions_json, content)
|
||||
|
||||
# 14. GET /v1.2/images with no Accept: header
|
||||
# Verify version choices returned
|
||||
path = 'http://%s:%d/v1.2/images' % ('127.0.0.1', self.api_port)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(response.status, 300)
|
||||
self.assertEqual(content, versions_json)
|
||||
self.assertEqual(300, response.status)
|
||||
self.assertEqual(versions_json, content)
|
||||
|
||||
self.stop_servers()
|
||||
|
|
|
@ -60,7 +60,7 @@ class TestBinGlanceCacheManage(functional.FunctionalTest):
|
|||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'POST', headers=headers,
|
||||
body=image_data)
|
||||
self.assertEqual(response.status, 201)
|
||||
self.assertEqual(201, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
self.assertEqual(data['image']['checksum'],
|
||||
hashlib.md5(image_data).hexdigest())
|
||||
|
@ -143,7 +143,7 @@ class TestBinGlanceCacheManage(functional.FunctionalTest):
|
|||
ids[1])
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
self.assertTrue(self.is_image_cached(ids[1]),
|
||||
"%s is not cached." % ids[1])
|
||||
|
|
|
@ -60,7 +60,7 @@ class BaseCacheMiddlewareTest(object):
|
|||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'POST', headers=headers,
|
||||
body=image_data)
|
||||
self.assertEqual(response.status, 201)
|
||||
self.assertEqual(201, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
self.assertEqual(data['image']['checksum'],
|
||||
hashlib.md5(image_data).hexdigest())
|
||||
|
@ -80,7 +80,7 @@ class BaseCacheMiddlewareTest(object):
|
|||
image_id)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
# Verify image now in cache
|
||||
image_cached_path = os.path.join(self.api_server.image_cache_dir,
|
||||
|
@ -110,7 +110,7 @@ class BaseCacheMiddlewareTest(object):
|
|||
image_id)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'DELETE')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
self.assertFalse(os.path.exists(image_cached_path))
|
||||
|
||||
|
@ -135,7 +135,7 @@ class BaseCacheMiddlewareTest(object):
|
|||
response, content = http.request(path, 'POST',
|
||||
headers=headers,
|
||||
body=jsonutils.dumps(image_entity))
|
||||
self.assertEqual(response.status, 201)
|
||||
self.assertEqual(201, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
image_id = data['id']
|
||||
|
||||
|
@ -146,7 +146,7 @@ class BaseCacheMiddlewareTest(object):
|
|||
response, content = http.request(path, 'PUT',
|
||||
headers=headers,
|
||||
body=image_data)
|
||||
self.assertEqual(response.status, 204)
|
||||
self.assertEqual(204, response.status)
|
||||
|
||||
# Verify image not in cache
|
||||
image_cached_path = os.path.join(self.api_server.image_cache_dir,
|
||||
|
@ -156,7 +156,7 @@ class BaseCacheMiddlewareTest(object):
|
|||
# Grab the image
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
# Verify image now in cache
|
||||
image_cached_path = os.path.join(self.api_server.image_cache_dir,
|
||||
|
@ -168,7 +168,7 @@ class BaseCacheMiddlewareTest(object):
|
|||
image_id)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'DELETE')
|
||||
self.assertEqual(response.status, 204)
|
||||
self.assertEqual(204, response.status)
|
||||
|
||||
self.assertFalse(os.path.exists(image_cached_path))
|
||||
|
||||
|
@ -194,9 +194,9 @@ class BaseCacheMiddlewareTest(object):
|
|||
path = "http://%s:%d/v1/images" % ("127.0.0.1", self.api_port)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'POST', headers=headers)
|
||||
self.assertEqual(response.status, 201)
|
||||
self.assertEqual(201, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
self.assertEqual(data['image']['size'], FIVE_KB)
|
||||
self.assertEqual(FIVE_KB, data['image']['size'])
|
||||
|
||||
image_id = data['image']['id']
|
||||
path = "http://%s:%d/v1/images/%s" % ("127.0.0.1", self.api_port,
|
||||
|
@ -205,14 +205,14 @@ class BaseCacheMiddlewareTest(object):
|
|||
# Grab the image
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
# Grab the image again to ensure it can be served out from
|
||||
# cache with the correct size
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(int(response['content-length']), FIVE_KB)
|
||||
self.assertEqual(200, response.status)
|
||||
self.assertEqual(FIVE_KB, int(response['content-length']))
|
||||
|
||||
self.stop_servers()
|
||||
|
||||
|
@ -232,7 +232,7 @@ class BaseCacheMiddlewareTest(object):
|
|||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'POST', headers=headers,
|
||||
body=image_data)
|
||||
self.assertEqual(response.status, 201)
|
||||
self.assertEqual(201, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
self.assertEqual(data['image']['checksum'],
|
||||
hashlib.md5(image_data).hexdigest())
|
||||
|
@ -256,7 +256,7 @@ class BaseCacheMiddlewareTest(object):
|
|||
image_id)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(response.status, 403)
|
||||
self.assertEqual(403, response.status)
|
||||
|
||||
# Now, we delete the image from the server and verify that
|
||||
# the image cache no longer contains the deleted image
|
||||
|
@ -264,7 +264,7 @@ class BaseCacheMiddlewareTest(object):
|
|||
image_id)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'DELETE')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
self.assertFalse(os.path.exists(image_cached_path))
|
||||
|
||||
|
@ -292,7 +292,7 @@ class BaseCacheMiddlewareTest(object):
|
|||
response, content = http.request(path, 'POST',
|
||||
headers=headers,
|
||||
body=jsonutils.dumps(image_entity))
|
||||
self.assertEqual(response.status, 201)
|
||||
self.assertEqual(201, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
image_id = data['id']
|
||||
|
||||
|
@ -303,7 +303,7 @@ class BaseCacheMiddlewareTest(object):
|
|||
response, content = http.request(path, 'PUT',
|
||||
headers=headers,
|
||||
body=image_data)
|
||||
self.assertEqual(response.status, 204)
|
||||
self.assertEqual(204, response.status)
|
||||
|
||||
# Verify image not in cache
|
||||
image_cached_path = os.path.join(self.api_server.image_cache_dir,
|
||||
|
@ -317,7 +317,7 @@ class BaseCacheMiddlewareTest(object):
|
|||
# Grab the image
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(response.status, 403)
|
||||
self.assertEqual(403, response.status)
|
||||
|
||||
# Now, we delete the image from the server and verify that
|
||||
# the image cache no longer contains the deleted image
|
||||
|
@ -325,7 +325,7 @@ class BaseCacheMiddlewareTest(object):
|
|||
image_id)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'DELETE')
|
||||
self.assertEqual(response.status, 204)
|
||||
self.assertEqual(204, response.status)
|
||||
|
||||
self.assertFalse(os.path.exists(image_cached_path))
|
||||
|
||||
|
@ -340,7 +340,7 @@ class BaseCacheManageMiddlewareTest(object):
|
|||
path = "http://%s:%d/v1/images" % ("127.0.0.1", self.api_port)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
self.assertTrue('images' in data)
|
||||
self.assertEqual(0, len(data['images']))
|
||||
|
@ -357,7 +357,7 @@ class BaseCacheManageMiddlewareTest(object):
|
|||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'POST', headers=headers,
|
||||
body=image_data)
|
||||
self.assertEqual(response.status, 201)
|
||||
self.assertEqual(201, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
self.assertEqual(data['image']['checksum'],
|
||||
hashlib.md5(image_data).hexdigest())
|
||||
|
@ -373,11 +373,11 @@ class BaseCacheManageMiddlewareTest(object):
|
|||
path = "http://%s:%d/v1/cached_images" % ("127.0.0.1", self.api_port)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
data = jsonutils.loads(content)
|
||||
self.assertTrue('cached_images' in data)
|
||||
self.assertEqual(data['cached_images'], [])
|
||||
self.assertEqual([], data['cached_images'])
|
||||
|
||||
@skip_if_disabled
|
||||
def test_user_not_authorized(self):
|
||||
|
@ -397,13 +397,13 @@ class BaseCacheManageMiddlewareTest(object):
|
|||
image_id1)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
# Verify image now in cache
|
||||
path = "http://%s:%d/v1/cached_images" % ("127.0.0.1", self.api_port)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
data = jsonutils.loads(content)
|
||||
self.assertTrue('cached_images' in data)
|
||||
|
@ -420,27 +420,27 @@ class BaseCacheManageMiddlewareTest(object):
|
|||
path = "http://%s:%d/v1/cached_images" % ("127.0.0.1", self.api_port)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(response.status, 403)
|
||||
self.assertEqual(403, response.status)
|
||||
|
||||
# Verify an unprivileged user cannot delete images from the cache
|
||||
path = "http://%s:%d/v1/cached_images/%s" % ("127.0.0.1",
|
||||
self.api_port, image_id1)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'DELETE')
|
||||
self.assertEqual(response.status, 403)
|
||||
self.assertEqual(403, response.status)
|
||||
|
||||
# Verify an unprivileged user cannot delete all cached images
|
||||
path = "http://%s:%d/v1/cached_images" % ("127.0.0.1", self.api_port)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'DELETE')
|
||||
self.assertEqual(response.status, 403)
|
||||
self.assertEqual(403, response.status)
|
||||
|
||||
# Verify an unprivileged user cannot queue an image
|
||||
path = "http://%s:%d/v1/queued_images/%s" % ("127.0.0.1",
|
||||
self.api_port, image_id2)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'PUT')
|
||||
self.assertEqual(response.status, 403)
|
||||
self.assertEqual(403, response.status)
|
||||
|
||||
self.stop_servers()
|
||||
|
||||
|
@ -465,13 +465,13 @@ class BaseCacheManageMiddlewareTest(object):
|
|||
image_id)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
# Verify image now in cache
|
||||
path = "http://%s:%d/v1/cached_images" % ("127.0.0.1", self.api_port)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
data = jsonutils.loads(content)
|
||||
self.assertTrue('cached_images' in data)
|
||||
|
@ -497,13 +497,13 @@ class BaseCacheManageMiddlewareTest(object):
|
|||
image_id)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
# Verify image hits increased in output of manage GET
|
||||
path = "http://%s:%d/v1/cached_images" % ("127.0.0.1", self.api_port)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
data = jsonutils.loads(content)
|
||||
self.assertTrue('cached_images' in data)
|
||||
|
@ -548,7 +548,7 @@ class BaseCacheManageMiddlewareTest(object):
|
|||
path = "http://%s:%d/v1/cached_images" % ("127.0.0.1", self.api_port)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
data = jsonutils.loads(content)
|
||||
self.assertTrue('cached_images' in data)
|
||||
|
@ -565,12 +565,12 @@ class BaseCacheManageMiddlewareTest(object):
|
|||
self.api_port, ids[2])
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'DELETE')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
path = "http://%s:%d/v1/cached_images" % ("127.0.0.1", self.api_port)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
data = jsonutils.loads(content)
|
||||
self.assertTrue('cached_images' in data)
|
||||
|
@ -583,12 +583,12 @@ class BaseCacheManageMiddlewareTest(object):
|
|||
path = "http://%s:%d/v1/cached_images" % ("127.0.0.1", self.api_port)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'DELETE')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
path = "http://%s:%d/v1/cached_images" % ("127.0.0.1", self.api_port)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
data = jsonutils.loads(content)
|
||||
self.assertTrue('cached_images' in data)
|
||||
|
@ -618,13 +618,13 @@ class BaseCacheManageMiddlewareTest(object):
|
|||
self.api_port, ids[x])
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'PUT')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
# Delete all queued images
|
||||
path = "http://%s:%d/v1/queued_images" % ("127.0.0.1", self.api_port)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'DELETE')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
data = jsonutils.loads(content)
|
||||
num_deleted = data['num_deleted']
|
||||
|
@ -634,7 +634,7 @@ class BaseCacheManageMiddlewareTest(object):
|
|||
path = "http://%s:%d/v1/queued_images" % ("127.0.0.1", self.api_port)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'DELETE')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
data = jsonutils.loads(content)
|
||||
num_deleted = data['num_deleted']
|
||||
|
@ -686,7 +686,7 @@ log_file = %(log_file)s
|
|||
self.api_port, ids[0])
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'PUT')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
self.verify_no_cached_images()
|
||||
|
||||
|
@ -702,7 +702,7 @@ log_file = %(log_file)s
|
|||
path = "http://%s:%d/v1/cached_images" % ("127.0.0.1", self.api_port)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
data = jsonutils.loads(content)
|
||||
self.assertTrue('cached_images' in data)
|
||||
|
|
|
@ -82,7 +82,7 @@ class TestClientExceptions(functional.FunctionalTest):
|
|||
self.fail('expected %s' % exc_type)
|
||||
except exc_type as e:
|
||||
if 'retry' in path:
|
||||
self.assertEqual(e.retry_after, 10)
|
||||
self.assertEqual(10, e.retry_after)
|
||||
|
||||
def test_rate_limited(self):
|
||||
"""
|
||||
|
@ -134,4 +134,4 @@ class TestClientExceptions(functional.FunctionalTest):
|
|||
('127.0.0.1', self.port))
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertTrue('ServerError' not in content)
|
||||
self.assertEqual(response.status, 500)
|
||||
self.assertEqual(500, response.status)
|
||||
|
|
|
@ -43,6 +43,6 @@ class GzipMiddlewareTest(functional.FunctionalTest):
|
|||
# Accept-Encoding: gzip
|
||||
headers = {'Accept-Encoding': 'gzip'}
|
||||
response, content = request('images', headers=headers)
|
||||
self.assertEqual(response.get("-content-encoding"), 'gzip')
|
||||
self.assertEqual('gzip', response.get("-content-encoding"))
|
||||
|
||||
self.stop_servers()
|
||||
|
|
|
@ -92,7 +92,7 @@ class TestLogging(functional.FunctionalTest):
|
|||
|
||||
path = "http://%s:%d/" % ("127.0.0.1", self.api_port)
|
||||
response, content = httplib2.Http().request(path, 'GET')
|
||||
self.assertEqual(response.status, 300)
|
||||
self.assertEqual(300, response.status)
|
||||
|
||||
self.assertNotEmptyFile(self.api_server.log_file)
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ class TestScrubber(functional.FunctionalTest):
|
|||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'POST', body='XXX',
|
||||
headers=headers)
|
||||
self.assertEqual(response.status, 201)
|
||||
self.assertEqual(201, response.status)
|
||||
image = jsonutils.loads(content)['image']
|
||||
self.assertEqual('active', image['status'])
|
||||
image_id = image['id']
|
||||
|
@ -70,10 +70,10 @@ class TestScrubber(functional.FunctionalTest):
|
|||
image_id)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'DELETE')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
response, content = http.request(path, 'HEAD')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
self.assertEqual('pending_delete', response['x-image-meta-status'])
|
||||
|
||||
self.wait_for_scrub(path)
|
||||
|
@ -100,7 +100,7 @@ class TestScrubber(functional.FunctionalTest):
|
|||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'POST', body='XXX',
|
||||
headers=headers)
|
||||
self.assertEqual(response.status, 201)
|
||||
self.assertEqual(201, response.status)
|
||||
image = jsonutils.loads(content)['image']
|
||||
self.assertEqual('active', image['status'])
|
||||
image_id = image['id']
|
||||
|
@ -109,10 +109,10 @@ class TestScrubber(functional.FunctionalTest):
|
|||
image_id)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'DELETE')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
response, content = http.request(path, 'HEAD')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
self.assertEqual('pending_delete', response['x-image-meta-status'])
|
||||
|
||||
# wait for the scrub time on the image to pass
|
||||
|
@ -157,7 +157,7 @@ class TestScrubber(functional.FunctionalTest):
|
|||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'POST', body='XXX',
|
||||
headers=headers)
|
||||
self.assertEqual(response.status, 201)
|
||||
self.assertEqual(201, response.status)
|
||||
image = jsonutils.loads(content)['image']
|
||||
self.assertEqual('active', image['status'])
|
||||
image_id = image['id']
|
||||
|
@ -168,10 +168,10 @@ class TestScrubber(functional.FunctionalTest):
|
|||
image_id)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'DELETE')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
response, content = http.request(path, 'HEAD')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
self.assertEqual('pending_delete', response['x-image-meta-status'])
|
||||
|
||||
# ensure the marker file has encrypted the image location by decrypting
|
||||
|
@ -188,7 +188,7 @@ class TestScrubber(functional.FunctionalTest):
|
|||
loc = glance_store.location.StoreLocation({})
|
||||
loc.parse_uri(decrypted_uri)
|
||||
|
||||
self.assertEqual(loc.scheme, "file")
|
||||
self.assertEqual("file", loc.scheme)
|
||||
self.assertEqual(image['id'], loc.obj)
|
||||
|
||||
self.wait_for_scrub(path)
|
||||
|
@ -221,7 +221,7 @@ class TestScrubber(functional.FunctionalTest):
|
|||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'POST', body='XXX',
|
||||
headers=headers)
|
||||
self.assertEqual(response.status, 201)
|
||||
self.assertEqual(201, response.status)
|
||||
image = jsonutils.loads(content)['image']
|
||||
self.assertEqual('active', image['status'])
|
||||
image_id = image['id']
|
||||
|
@ -231,11 +231,11 @@ class TestScrubber(functional.FunctionalTest):
|
|||
image_id)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'DELETE')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
# ensure the image is marked pending delete
|
||||
response, content = http.request(path, 'HEAD')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
self.assertEqual('pending_delete', response['x-image-meta-status'])
|
||||
|
||||
# Remove the file from the backend.
|
||||
|
|
|
@ -117,16 +117,16 @@ class TestApi(functional.FunctionalTest):
|
|||
path = "http://%s:%d/v1/images" % ("127.0.0.1", self.api_port)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(content, '{"images": []}')
|
||||
self.assertEqual(200, response.status)
|
||||
self.assertEqual('{"images": []}', content)
|
||||
|
||||
# 1. GET /images/detail
|
||||
# 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(response.status, 200)
|
||||
self.assertEqual(content, '{"images": []}')
|
||||
self.assertEqual(200, response.status)
|
||||
self.assertEqual('{"images": []}', content)
|
||||
|
||||
# 2. POST /images with public image named Image1
|
||||
# attribute and no custom properties. Verify a 200 OK is returned
|
||||
|
@ -136,7 +136,7 @@ class TestApi(functional.FunctionalTest):
|
|||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'POST', headers=headers,
|
||||
body=image_data)
|
||||
self.assertEqual(response.status, 201)
|
||||
self.assertEqual(201, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
image_id = data['image']['id']
|
||||
self.assertEqual(data['image']['checksum'],
|
||||
|
@ -151,8 +151,8 @@ class TestApi(functional.FunctionalTest):
|
|||
image_id)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'HEAD')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(response['x-image-meta-name'], "Image1")
|
||||
self.assertEqual(200, response.status)
|
||||
self.assertEqual("Image1", response['x-image-meta-name'])
|
||||
|
||||
# 4. GET image
|
||||
# Verify all information on image we just added is correct
|
||||
|
@ -160,7 +160,7 @@ class TestApi(functional.FunctionalTest):
|
|||
image_id)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
expected_image_headers = {
|
||||
'x-image-meta-id': image_id,
|
||||
|
@ -189,16 +189,16 @@ class TestApi(functional.FunctionalTest):
|
|||
expected_value,
|
||||
response[expected_key]))
|
||||
|
||||
self.assertEqual(content, "*" * FIVE_KB)
|
||||
self.assertEqual(hashlib.md5(content).hexdigest(),
|
||||
hashlib.md5("*" * FIVE_KB).hexdigest())
|
||||
self.assertEqual("*" * FIVE_KB, content)
|
||||
self.assertEqual(hashlib.md5("*" * FIVE_KB).hexdigest(),
|
||||
hashlib.md5(content).hexdigest())
|
||||
|
||||
# 5. GET /images
|
||||
# Verify one public image
|
||||
path = "http://%s:%d/v1/images" % ("127.0.0.1", self.api_port)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
expected_result = {"images": [
|
||||
{"container_format": "ovf",
|
||||
|
@ -207,14 +207,14 @@ class TestApi(functional.FunctionalTest):
|
|||
"name": "Image1",
|
||||
"checksum": "c2e5db72bd7fd153f53ede5da5a06de3",
|
||||
"size": 5120}]}
|
||||
self.assertEqual(jsonutils.loads(content), expected_result)
|
||||
self.assertEqual(expected_result, jsonutils.loads(content))
|
||||
|
||||
# 6. GET /images/detail
|
||||
# Verify image and all its metadata
|
||||
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(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
expected_image = {
|
||||
"status": "active",
|
||||
|
@ -245,10 +245,10 @@ class TestApi(functional.FunctionalTest):
|
|||
image_id)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'PUT', headers=headers)
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
self.assertEqual(data['image']['properties']['arch'], "x86_64")
|
||||
self.assertEqual(data['image']['properties']['distro'], "Ubuntu")
|
||||
self.assertEqual("x86_64", data['image']['properties']['arch'])
|
||||
self.assertEqual("Ubuntu", data['image']['properties']['distro'])
|
||||
|
||||
# 8. PUT image with too many custom properties
|
||||
# Verify 413 returned
|
||||
|
@ -259,14 +259,14 @@ class TestApi(functional.FunctionalTest):
|
|||
image_id)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'PUT', headers=headers)
|
||||
self.assertEqual(response.status, 413)
|
||||
self.assertEqual(413, response.status)
|
||||
|
||||
# 9. GET /images/detail
|
||||
# Verify image and all its metadata
|
||||
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(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
expected_image = {
|
||||
"status": "active",
|
||||
|
@ -295,14 +295,14 @@ class TestApi(functional.FunctionalTest):
|
|||
image_id)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'PUT', headers=headers)
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
path = "http://%s:%d/v1/images/detail" % ("127.0.0.1", self.api_port)
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
data = jsonutils.loads(content)['images'][0]
|
||||
self.assertEqual(len(data['properties']), 1)
|
||||
self.assertEqual(data['properties']['arch'], "x86_64")
|
||||
self.assertEqual(1, len(data['properties']))
|
||||
self.assertEqual("x86_64", data['properties']['arch'])
|
||||
|
||||
# 11. PUT image and add a previously deleted property.
|
||||
headers = {'X-Image-Meta-Property-Distro': 'Ubuntu',
|
||||
|
@ -311,16 +311,16 @@ class TestApi(functional.FunctionalTest):
|
|||
image_id)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'PUT', headers=headers)
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
|
||||
path = "http://%s:%d/v1/images/detail" % ("127.0.0.1", self.api_port)
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
data = jsonutils.loads(content)['images'][0]
|
||||
self.assertEqual(len(data['properties']), 2)
|
||||
self.assertEqual(data['properties']['arch'], "x86_64")
|
||||
self.assertEqual(data['properties']['distro'], "Ubuntu")
|
||||
self.assertEqual(2, len(data['properties']))
|
||||
self.assertEqual("x86_64", data['properties']['arch'])
|
||||
self.assertEqual("Ubuntu", data['properties']['distro'])
|
||||
self.assertNotEqual(data['created_at'], data['updated_at'])
|
||||
|
||||
# 12. Add member to image
|
||||
|
@ -328,32 +328,32 @@ class TestApi(functional.FunctionalTest):
|
|||
("127.0.0.1", self.api_port, image_id))
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'PUT')
|
||||
self.assertEqual(response.status, 204)
|
||||
self.assertEqual(204, response.status)
|
||||
|
||||
# 13. Add member to image
|
||||
path = ("http://%s:%d/v1/images/%s/members/pattiewhite" %
|
||||
("127.0.0.1", self.api_port, image_id))
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'PUT')
|
||||
self.assertEqual(response.status, 204)
|
||||
self.assertEqual(204, response.status)
|
||||
|
||||
# 14. List image members
|
||||
path = ("http://%s:%d/v1/images/%s/members" %
|
||||
("127.0.0.1", self.api_port, image_id))
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
self.assertEqual(len(data['members']), 2)
|
||||
self.assertEqual(data['members'][0]['member_id'], 'pattieblack')
|
||||
self.assertEqual(data['members'][1]['member_id'], 'pattiewhite')
|
||||
self.assertEqual(2, len(data['members']))
|
||||
self.assertEqual('pattieblack', data['members'][0]['member_id'])
|
||||
self.assertEqual('pattiewhite', data['members'][1]['member_id'])
|
||||
|
||||
# 15. Delete image member
|
||||
path = ("http://%s:%d/v1/images/%s/members/pattieblack" %
|
||||
("127.0.0.1", self.api_port, image_id))
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'DELETE')
|
||||
self.assertEqual(response.status, 204)
|
||||
self.assertEqual(204, response.status)
|
||||
|
||||
# 16. Attempt to replace members with an overlimit amount
|
||||
# Adding 11 image members should fail since configured limit is 10
|
||||
|
@ -366,7 +366,7 @@ class TestApi(functional.FunctionalTest):
|
|||
http = httplib2.Http()
|
||||
body = jsonutils.dumps(dict(memberships=memberships))
|
||||
response, content = http.request(path, 'PUT', body=body)
|
||||
self.assertEqual(response.status, 413)
|
||||
self.assertEqual(413, response.status)
|
||||
|
||||
# 17. Attempt to add a member while at limit
|
||||
# Adding an 11th member should fail since configured limit is 10
|
||||
|
@ -379,13 +379,13 @@ class TestApi(functional.FunctionalTest):
|
|||
http = httplib2.Http()
|
||||
body = jsonutils.dumps(dict(memberships=memberships))
|
||||
response, content = http.request(path, 'PUT', body=body)
|
||||
self.assertEqual(response.status, 204)
|
||||
self.assertEqual(204, response.status)
|
||||
|
||||
path = ("http://%s:%d/v1/images/%s/members/fail_me" %
|
||||
("127.0.0.1", self.api_port, image_id))
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'PUT')
|
||||
self.assertEqual(response.status, 413)
|
||||
self.assertEqual(413, response.status)
|
||||
|
||||
# 18. POST /images with another public image named Image2
|
||||
# attribute and three custom properties, "distro", "arch" & "foo".
|
||||
|
@ -399,7 +399,7 @@ class TestApi(functional.FunctionalTest):
|
|||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'POST', headers=headers,
|
||||
body=image_data)
|
||||
self.assertEqual(response.status, 201)
|
||||
self.assertEqual(201, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
image2_id = data['image']['id']
|
||||
self.assertEqual(data['image']['checksum'],
|
||||
|
@ -417,19 +417,19 @@ class TestApi(functional.FunctionalTest):
|
|||
image2_id)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'HEAD')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(response['x-image-meta-name'], "Image2")
|
||||
self.assertEqual(200, response.status)
|
||||
self.assertEqual("Image2", response['x-image-meta-name'])
|
||||
|
||||
# 20. GET /images
|
||||
# Verify 2 public images
|
||||
path = "http://%s:%d/v1/images" % ("127.0.0.1", self.api_port)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
images = jsonutils.loads(content)['images']
|
||||
self.assertEqual(len(images), 2)
|
||||
self.assertEqual(images[0]['id'], image2_id)
|
||||
self.assertEqual(images[1]['id'], image_id)
|
||||
self.assertEqual(2, len(images))
|
||||
self.assertEqual(image2_id, images[0]['id'])
|
||||
self.assertEqual(image_id, images[1]['id'])
|
||||
|
||||
# 21. GET /images with filter on user-defined property 'distro'.
|
||||
# Verify both images are returned
|
||||
|
@ -437,11 +437,11 @@ class TestApi(functional.FunctionalTest):
|
|||
"127.0.0.1", self.api_port)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
images = jsonutils.loads(content)['images']
|
||||
self.assertEqual(len(images), 2)
|
||||
self.assertEqual(images[0]['id'], image2_id)
|
||||
self.assertEqual(images[1]['id'], image_id)
|
||||
self.assertEqual(2, len(images))
|
||||
self.assertEqual(image2_id, images[0]['id'])
|
||||
self.assertEqual(image_id, images[1]['id'])
|
||||
|
||||
# 22. GET /images with filter on user-defined property 'distro' but
|
||||
# with non-existent value. Verify no images are returned
|
||||
|
@ -449,9 +449,9 @@ class TestApi(functional.FunctionalTest):
|
|||
"127.0.0.1", self.api_port)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
images = jsonutils.loads(content)['images']
|
||||
self.assertEqual(len(images), 0)
|
||||
self.assertEqual(0, len(images))
|
||||
|
||||
# 23. GET /images with filter on non-existent user-defined property
|
||||
# 'boo'. Verify no images are returned
|
||||
|
@ -459,9 +459,9 @@ class TestApi(functional.FunctionalTest):
|
|||
self.api_port)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
images = jsonutils.loads(content)['images']
|
||||
self.assertEqual(len(images), 0)
|
||||
self.assertEqual(0, len(images))
|
||||
|
||||
# 24. GET /images with filter 'arch=i386'
|
||||
# Verify only image2 is returned
|
||||
|
@ -469,10 +469,10 @@ class TestApi(functional.FunctionalTest):
|
|||
self.api_port)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
images = jsonutils.loads(content)['images']
|
||||
self.assertEqual(len(images), 1)
|
||||
self.assertEqual(images[0]['id'], image2_id)
|
||||
self.assertEqual(1, len(images))
|
||||
self.assertEqual(image2_id, images[0]['id'])
|
||||
|
||||
# 25. GET /images with filter 'arch=x86_64'
|
||||
# Verify only image1 is returned
|
||||
|
@ -480,10 +480,10 @@ class TestApi(functional.FunctionalTest):
|
|||
self.api_port)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
images = jsonutils.loads(content)['images']
|
||||
self.assertEqual(len(images), 1)
|
||||
self.assertEqual(images[0]['id'], image_id)
|
||||
self.assertEqual(1, len(images))
|
||||
self.assertEqual(image_id, images[0]['id'])
|
||||
|
||||
# 26. GET /images with filter 'foo=bar'
|
||||
# Verify only image2 is returned
|
||||
|
@ -491,24 +491,24 @@ class TestApi(functional.FunctionalTest):
|
|||
self.api_port)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
images = jsonutils.loads(content)['images']
|
||||
self.assertEqual(len(images), 1)
|
||||
self.assertEqual(images[0]['id'], image2_id)
|
||||
self.assertEqual(1, len(images))
|
||||
self.assertEqual(image2_id, images[0]['id'])
|
||||
|
||||
# 27. DELETE image1
|
||||
path = "http://%s:%d/v1/images/%s" % ("127.0.0.1", self.api_port,
|
||||
image_id)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'DELETE')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
# 28. Try to list members of deleted image
|
||||
path = ("http://%s:%d/v1/images/%s/members" %
|
||||
("127.0.0.1", self.api_port, image_id))
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(response.status, 404)
|
||||
self.assertEqual(404, response.status)
|
||||
|
||||
# 29. Try to update member of deleted image
|
||||
path = ("http://%s:%d/v1/images/%s/members" %
|
||||
|
@ -517,37 +517,37 @@ class TestApi(functional.FunctionalTest):
|
|||
fixture = [{'member_id': 'pattieblack', 'can_share': 'false'}]
|
||||
body = jsonutils.dumps(dict(memberships=fixture))
|
||||
response, content = http.request(path, 'PUT', body=body)
|
||||
self.assertEqual(response.status, 404)
|
||||
self.assertEqual(404, response.status)
|
||||
|
||||
# 30. Try to add member to deleted image
|
||||
path = ("http://%s:%d/v1/images/%s/members/chickenpattie" %
|
||||
("127.0.0.1", self.api_port, image_id))
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'PUT')
|
||||
self.assertEqual(response.status, 404)
|
||||
self.assertEqual(404, response.status)
|
||||
|
||||
# 31. Try to delete member of deleted image
|
||||
path = ("http://%s:%d/v1/images/%s/members/pattieblack" %
|
||||
("127.0.0.1", self.api_port, image_id))
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'DELETE')
|
||||
self.assertEqual(response.status, 404)
|
||||
self.assertEqual(404, response.status)
|
||||
|
||||
# 32. DELETE image2
|
||||
path = "http://%s:%d/v1/images/%s" % ("127.0.0.1", self.api_port,
|
||||
image2_id)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'DELETE')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
# 33. GET /images
|
||||
# Verify no images are listed
|
||||
path = "http://%s:%d/v1/images" % ("127.0.0.1", self.api_port)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
images = jsonutils.loads(content)['images']
|
||||
self.assertEqual(len(images), 0)
|
||||
self.assertEqual(0, len(images))
|
||||
|
||||
# 34. HEAD /images/detail
|
||||
path = "http://%s:%d/v1/images/detail" % ("127.0.0.1", self.api_port)
|
||||
|
@ -584,7 +584,7 @@ class TestApi(functional.FunctionalTest):
|
|||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'POST', headers=headers,
|
||||
body=image_data)
|
||||
self.assertEqual(response.status, 201)
|
||||
self.assertEqual(201, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
image_id = data['image']['id']
|
||||
self.assertEqual(data['image']['checksum'],
|
||||
|
@ -599,15 +599,15 @@ class TestApi(functional.FunctionalTest):
|
|||
image_id)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'HEAD')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(response['x-image-meta-name'], "Image1")
|
||||
self.assertEqual(200, response.status)
|
||||
self.assertEqual("Image1", response['x-image-meta-name'])
|
||||
|
||||
# 2. GET /images
|
||||
# Verify one public image
|
||||
path = "http://%s:%d/v1/images" % ("127.0.0.1", self.api_port)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
expected_result = {"images": [
|
||||
{"container_format": "ovf",
|
||||
|
@ -616,14 +616,14 @@ class TestApi(functional.FunctionalTest):
|
|||
"name": "Image1",
|
||||
"checksum": "c2e5db72bd7fd153f53ede5da5a06de3",
|
||||
"size": 5120}]}
|
||||
self.assertEqual(jsonutils.loads(content), expected_result)
|
||||
self.assertEqual(expected_result, jsonutils.loads(content))
|
||||
|
||||
# 3. DELETE image1
|
||||
path = "http://%s:%d/v1/images/%s" % ("127.0.0.1", self.api_port,
|
||||
image_id)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'DELETE')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
# 4. GET image
|
||||
# Verify that 403 HTTPForbidden exception is raised prior to
|
||||
|
@ -634,7 +634,7 @@ class TestApi(functional.FunctionalTest):
|
|||
image_id)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(response.status, 403)
|
||||
self.assertEqual(403, response.status)
|
||||
|
||||
self.stop_servers()
|
||||
|
||||
|
@ -663,7 +663,7 @@ class TestApi(functional.FunctionalTest):
|
|||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'POST', headers=headers,
|
||||
body=image_data)
|
||||
self.assertEqual(response.status, 201)
|
||||
self.assertEqual(201, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
image_id = data['image']['id']
|
||||
self.assertEqual(data['image']['checksum'],
|
||||
|
@ -678,15 +678,15 @@ class TestApi(functional.FunctionalTest):
|
|||
image_id)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'HEAD')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(response['x-image-meta-name'], "Image1")
|
||||
self.assertEqual(200, response.status)
|
||||
self.assertEqual("Image1", response['x-image-meta-name'])
|
||||
|
||||
# 2. GET /images
|
||||
# Verify one public image
|
||||
path = "http://%s:%d/v1/images" % ("127.0.0.1", self.api_port)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
expected_result = {"images": [
|
||||
{"container_format": "ovf",
|
||||
|
@ -695,14 +695,14 @@ class TestApi(functional.FunctionalTest):
|
|||
"name": "Image1",
|
||||
"checksum": "c2e5db72bd7fd153f53ede5da5a06de3",
|
||||
"size": 5120}]}
|
||||
self.assertEqual(jsonutils.loads(content), expected_result)
|
||||
self.assertEqual(expected_result, jsonutils.loads(content))
|
||||
|
||||
# 3. DELETE image1
|
||||
path = "http://%s:%d/v1/images/%s" % ("127.0.0.1", self.api_port,
|
||||
image_id)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'DELETE')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
# 4. GET image
|
||||
# Verify that 404 HTTPNotFound exception is raised
|
||||
|
@ -710,6 +710,6 @@ class TestApi(functional.FunctionalTest):
|
|||
image_id)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(response.status, 404)
|
||||
self.assertEqual(404, response.status)
|
||||
|
||||
self.stop_servers()
|
||||
|
|
|
@ -96,7 +96,7 @@ class TestCopyToFile(functional.FunctionalTest):
|
|||
time.sleep(0.01)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'HEAD')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
if response['x-image-meta-status'] == expected_status:
|
||||
return
|
||||
self.fail('unexpected image status %s' %
|
||||
|
@ -105,21 +105,21 @@ class TestCopyToFile(functional.FunctionalTest):
|
|||
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(response['content-length'], str(FIVE_KB))
|
||||
self.assertEqual(200, response.status)
|
||||
self.assertEqual(str(FIVE_KB), response['content-length'])
|
||||
|
||||
self.assertEqual(content, "*" * FIVE_KB)
|
||||
self.assertEqual(hashlib.md5(content).hexdigest(),
|
||||
hashlib.md5("*" * FIVE_KB).hexdigest())
|
||||
self.assertEqual(data['image']['size'], FIVE_KB)
|
||||
self.assertEqual(data['image']['name'], "copied")
|
||||
self.assertEqual("*" * FIVE_KB, content)
|
||||
self.assertEqual(hashlib.md5("*" * FIVE_KB).hexdigest(),
|
||||
hashlib.md5(content).hexdigest())
|
||||
self.assertEqual(FIVE_KB, data['image']['size'])
|
||||
self.assertEqual("copied", data['image']['name'])
|
||||
|
||||
# DELETE original image
|
||||
path = "http://%s:%d/v1/images/%s" % ("127.0.0.1", self.api_port,
|
||||
original_image_id)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'DELETE')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
# GET image again to make sure the existence of the original
|
||||
# image in from_store is not depended on
|
||||
|
@ -127,21 +127,21 @@ class TestCopyToFile(functional.FunctionalTest):
|
|||
copy_image_id)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(response['content-length'], str(FIVE_KB))
|
||||
self.assertEqual(200, response.status)
|
||||
self.assertEqual(str(FIVE_KB), response['content-length'])
|
||||
|
||||
self.assertEqual(content, "*" * FIVE_KB)
|
||||
self.assertEqual(hashlib.md5(content).hexdigest(),
|
||||
hashlib.md5("*" * FIVE_KB).hexdigest())
|
||||
self.assertEqual(data['image']['size'], FIVE_KB)
|
||||
self.assertEqual(data['image']['name'], "copied")
|
||||
self.assertEqual("*" * FIVE_KB, content)
|
||||
self.assertEqual(hashlib.md5("*" * FIVE_KB).hexdigest(),
|
||||
hashlib.md5(content).hexdigest())
|
||||
self.assertEqual(FIVE_KB, data['image']['size'])
|
||||
self.assertEqual("copied", data['image']['name'])
|
||||
|
||||
# DELETE copied image
|
||||
path = "http://%s:%d/v1/images/%s" % ("127.0.0.1", self.api_port,
|
||||
copy_image_id)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'DELETE')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
self.stop_servers()
|
||||
|
||||
|
@ -191,7 +191,7 @@ class TestCopyToFile(functional.FunctionalTest):
|
|||
time.sleep(0.01)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'HEAD')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
if response['x-image-meta-status'] == expected_status:
|
||||
return
|
||||
self.fail('unexpected image status %s' %
|
||||
|
@ -205,15 +205,15 @@ class TestCopyToFile(functional.FunctionalTest):
|
|||
self.assertEqual(response.status, 200 if exists else 404)
|
||||
|
||||
if exists:
|
||||
self.assertEqual(response['content-length'], str(FIVE_KB))
|
||||
self.assertEqual(content, "*" * FIVE_KB)
|
||||
self.assertEqual(hashlib.md5(content).hexdigest(),
|
||||
hashlib.md5("*" * FIVE_KB).hexdigest())
|
||||
self.assertEqual(str(FIVE_KB), response['content-length'])
|
||||
self.assertEqual("*" * FIVE_KB, content)
|
||||
self.assertEqual(hashlib.md5("*" * FIVE_KB).hexdigest(),
|
||||
hashlib.md5(content).hexdigest())
|
||||
|
||||
# DELETE copied image
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'DELETE')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
self.stop_servers()
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ class TestMiscellaneous(functional.FunctionalTest):
|
|||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'POST', headers=headers,
|
||||
body=image_data)
|
||||
self.assertEqual(response.status, 201)
|
||||
self.assertEqual(201, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
self.assertEqual(data['image']['checksum'],
|
||||
hashlib.md5(image_data).hexdigest())
|
||||
|
@ -76,15 +76,15 @@ class TestMiscellaneous(functional.FunctionalTest):
|
|||
data['image']['id'])
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'HEAD')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(response['x-image-meta-name'], "Image1")
|
||||
self.assertEqual(200, response.status)
|
||||
self.assertEqual("Image1", response['x-image-meta-name'])
|
||||
|
||||
# 4. GET /images/1
|
||||
# Verify the api throws the appropriate 404 error
|
||||
path = "http://%s:%d/v1/images/1" % ("127.0.0.1", self.api_port)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(response.status, 404)
|
||||
self.assertEqual(404, response.status)
|
||||
|
||||
self.stop_servers()
|
||||
|
||||
|
|
|
@ -37,8 +37,8 @@ class TestMultiprocessing(functional.FunctionalTest):
|
|||
path = "http://%s:%d/v1/images" % ("127.0.0.1", self.api_port)
|
||||
http = httplib2.Http()
|
||||
response, content = http.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(content, '{"images": []}')
|
||||
self.assertEqual(200, response.status)
|
||||
self.assertEqual('{"images": []}', content)
|
||||
self.stop_servers()
|
||||
|
||||
def _get_children(self):
|
||||
|
|
|
@ -133,16 +133,16 @@ class TestSSL(functional.FunctionalTest):
|
|||
path = "https://%s:%d/v1/images" % ("127.0.0.1", self.api_port)
|
||||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
response, content = https.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(content, '{"images": []}')
|
||||
self.assertEqual(200, response.status)
|
||||
self.assertEqual('{"images": []}', content)
|
||||
|
||||
# 1. GET /images/detail
|
||||
# Verify no public images
|
||||
path = "https://%s:%d/v1/images/detail" % ("127.0.0.1", self.api_port)
|
||||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
response, content = https.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(content, '{"images": []}')
|
||||
self.assertEqual(200, response.status)
|
||||
self.assertEqual('{"images": []}', content)
|
||||
|
||||
# 2. POST /images with public image named Image1
|
||||
# attribute and no custom properties. Verify a 200 OK is returned
|
||||
|
@ -154,7 +154,7 @@ class TestSSL(functional.FunctionalTest):
|
|||
'POST',
|
||||
headers=headers,
|
||||
body=image_data)
|
||||
self.assertEqual(response.status, 201)
|
||||
self.assertEqual(201, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
self.assertEqual(data['image']['checksum'],
|
||||
hashlib.md5(image_data).hexdigest())
|
||||
|
@ -170,8 +170,8 @@ class TestSSL(functional.FunctionalTest):
|
|||
image_id)
|
||||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
response, content = https.request(path, 'HEAD')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(response['x-image-meta-name'], "Image1")
|
||||
self.assertEqual(200, response.status)
|
||||
self.assertEqual("Image1", response['x-image-meta-name'])
|
||||
|
||||
# 4. GET image
|
||||
# Verify all information on image we just added is correct
|
||||
|
@ -179,7 +179,7 @@ class TestSSL(functional.FunctionalTest):
|
|||
image_id)
|
||||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
response, content = https.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
expected_image_headers = {
|
||||
'x-image-meta-id': image_id,
|
||||
|
@ -208,7 +208,7 @@ class TestSSL(functional.FunctionalTest):
|
|||
expected_value,
|
||||
response[expected_key]))
|
||||
|
||||
self.assertEqual(content, "*" * FIVE_KB)
|
||||
self.assertEqual("*" * FIVE_KB, content)
|
||||
self.assertEqual(hashlib.md5(content).hexdigest(),
|
||||
hashlib.md5("*" * FIVE_KB).hexdigest())
|
||||
|
||||
|
@ -217,7 +217,7 @@ class TestSSL(functional.FunctionalTest):
|
|||
path = "https://%s:%d/v1/images" % ("127.0.0.1", self.api_port)
|
||||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
response, content = https.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
expected_result = {"images": [
|
||||
{"container_format": "ovf",
|
||||
|
@ -226,14 +226,14 @@ class TestSSL(functional.FunctionalTest):
|
|||
"name": "Image1",
|
||||
"checksum": "c2e5db72bd7fd153f53ede5da5a06de3",
|
||||
"size": 5120}]}
|
||||
self.assertEqual(jsonutils.loads(content), expected_result)
|
||||
self.assertEqual(expected_result, jsonutils.loads(content))
|
||||
|
||||
# 6. GET /images/detail
|
||||
# Verify image and all its metadata
|
||||
path = "https://%s:%d/v1/images/detail" % ("127.0.0.1", self.api_port)
|
||||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
response, content = https.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
expected_image = {
|
||||
"status": "active",
|
||||
|
@ -265,17 +265,17 @@ class TestSSL(functional.FunctionalTest):
|
|||
image_id)
|
||||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
response, content = https.request(path, 'PUT', headers=headers)
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
self.assertEqual(data['image']['properties']['arch'], "x86_64")
|
||||
self.assertEqual(data['image']['properties']['distro'], "Ubuntu")
|
||||
self.assertEqual("x86_64", data['image']['properties']['arch'])
|
||||
self.assertEqual("Ubuntu", data['image']['properties']['distro'])
|
||||
|
||||
# 8. GET /images/detail
|
||||
# Verify image and all its metadata
|
||||
path = "https://%s:%d/v1/images/detail" % ("127.0.0.1", self.api_port)
|
||||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
response, content = https.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
expected_image = {
|
||||
"status": "active",
|
||||
|
@ -305,14 +305,14 @@ class TestSSL(functional.FunctionalTest):
|
|||
image_id)
|
||||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
response, content = https.request(path, 'PUT', headers=headers)
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
path = "https://%s:%d/v1/images/detail" % ("127.0.0.1", self.api_port)
|
||||
response, content = https.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
data = jsonutils.loads(content)['images'][0]
|
||||
self.assertEqual(len(data['properties']), 1)
|
||||
self.assertEqual(data['properties']['arch'], "x86_64")
|
||||
self.assertEqual(1, len(data['properties']))
|
||||
self.assertEqual("x86_64", data['properties']['arch'])
|
||||
|
||||
# 10. PUT image and add a previously deleted property.
|
||||
headers = {'X-Image-Meta-Property-Distro': 'Ubuntu',
|
||||
|
@ -321,16 +321,16 @@ class TestSSL(functional.FunctionalTest):
|
|||
image_id)
|
||||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
response, content = https.request(path, 'PUT', headers=headers)
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
|
||||
path = "https://%s:%d/v1/images/detail" % ("127.0.0.1", self.api_port)
|
||||
response, content = https.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
data = jsonutils.loads(content)['images'][0]
|
||||
self.assertEqual(len(data['properties']), 2)
|
||||
self.assertEqual(data['properties']['arch'], "x86_64")
|
||||
self.assertEqual(data['properties']['distro'], "Ubuntu")
|
||||
self.assertEqual(2, len(data['properties']))
|
||||
self.assertEqual("x86_64", data['properties']['arch'])
|
||||
self.assertEqual("Ubuntu", data['properties']['distro'])
|
||||
|
||||
self.stop_servers()
|
||||
|
||||
|
@ -367,8 +367,8 @@ class TestSSL(functional.FunctionalTest):
|
|||
path = "https://%s:%d/v1/images" % ("127.0.0.1", self.api_port)
|
||||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
response, content = https.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(content, '{"images": []}')
|
||||
self.assertEqual(200, response.status)
|
||||
self.assertEqual('{"images": []}', content)
|
||||
|
||||
# 1. POST /images with public image named Image1
|
||||
# with no location or image data
|
||||
|
@ -376,7 +376,7 @@ class TestSSL(functional.FunctionalTest):
|
|||
path = "https://%s:%d/v1/images" % ("127.0.0.1", self.api_port)
|
||||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
response, content = https.request(path, 'POST', headers=headers)
|
||||
self.assertEqual(response.status, 201)
|
||||
self.assertEqual(201, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
self.assertIsNone(data['image']['checksum'])
|
||||
self.assertEqual(data['image']['size'], 0)
|
||||
|
@ -392,14 +392,14 @@ class TestSSL(functional.FunctionalTest):
|
|||
path = "https://%s:%d/v1/images" % ("127.0.0.1", self.api_port)
|
||||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
response, content = https.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
self.assertEqual(data['images'][0]['id'], image_id)
|
||||
self.assertEqual(image_id, data['images'][0]['id'])
|
||||
self.assertIsNone(data['images'][0]['checksum'])
|
||||
self.assertEqual(data['images'][0]['size'], 0)
|
||||
self.assertEqual(data['images'][0]['container_format'], 'ovf')
|
||||
self.assertEqual(data['images'][0]['disk_format'], 'raw')
|
||||
self.assertEqual(data['images'][0]['name'], "Image1")
|
||||
self.assertEqual(0, data['images'][0]['size'])
|
||||
self.assertEqual('ovf', data['images'][0]['container_format'])
|
||||
self.assertEqual('raw', data['images'][0]['disk_format'])
|
||||
self.assertEqual("Image1", data['images'][0]['name'])
|
||||
|
||||
# 3. HEAD /images
|
||||
# Verify status is in queued
|
||||
|
@ -407,11 +407,11 @@ class TestSSL(functional.FunctionalTest):
|
|||
image_id)
|
||||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
response, content = https.request(path, 'HEAD')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(response['x-image-meta-name'], "Image1")
|
||||
self.assertEqual(response['x-image-meta-status'], "queued")
|
||||
self.assertEqual(response['x-image-meta-size'], '0')
|
||||
self.assertEqual(response['x-image-meta-id'], image_id)
|
||||
self.assertEqual(200, response.status)
|
||||
self.assertEqual("Image1", response['x-image-meta-name'])
|
||||
self.assertEqual("queued", response['x-image-meta-status'])
|
||||
self.assertEqual('0', response['x-image-meta-size'])
|
||||
self.assertEqual(image_id, response['x-image-meta-id'])
|
||||
|
||||
# 4. PUT image with image data, verify 200 returned
|
||||
image_data = "*" * FIVE_KB
|
||||
|
@ -423,7 +423,7 @@ class TestSSL(functional.FunctionalTest):
|
|||
'PUT',
|
||||
headers=headers,
|
||||
body=image_data)
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
self.assertEqual(data['image']['checksum'],
|
||||
hashlib.md5(image_data).hexdigest())
|
||||
|
@ -437,24 +437,24 @@ class TestSSL(functional.FunctionalTest):
|
|||
image_id)
|
||||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
response, content = https.request(path, 'HEAD')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(response['x-image-meta-name'], "Image1")
|
||||
self.assertEqual(response['x-image-meta-status'], "active")
|
||||
self.assertEqual(200, response.status)
|
||||
self.assertEqual('Image1', response['x-image-meta-name'])
|
||||
self.assertEqual("active", response['x-image-meta-status'])
|
||||
|
||||
# 6. GET /images
|
||||
# Verify 1 public image still...
|
||||
path = "https://%s:%d/v1/images" % ("127.0.0.1", self.api_port)
|
||||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
response, content = https.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
self.assertEqual(data['images'][0]['checksum'],
|
||||
hashlib.md5(image_data).hexdigest())
|
||||
self.assertEqual(data['images'][0]['id'], image_id)
|
||||
self.assertEqual(data['images'][0]['size'], FIVE_KB)
|
||||
self.assertEqual(data['images'][0]['container_format'], 'ovf')
|
||||
self.assertEqual(data['images'][0]['disk_format'], 'raw')
|
||||
self.assertEqual(data['images'][0]['name'], "Image1")
|
||||
self.assertEqual(hashlib.md5(image_data).hexdigest(),
|
||||
data['images'][0]['checksum'])
|
||||
self.assertEqual(image_id, data['images'][0]['id'])
|
||||
self.assertEqual(FIVE_KB, data['images'][0]['size'])
|
||||
self.assertEqual('ovf', data['images'][0]['container_format'])
|
||||
self.assertEqual('raw', data['images'][0]['disk_format'])
|
||||
self.assertEqual("Image1", data['images'][0]['name'])
|
||||
|
||||
self.stop_servers()
|
||||
|
||||
|
@ -505,7 +505,7 @@ class TestSSL(functional.FunctionalTest):
|
|||
path = "https://%s:%d/" % ("127.0.0.1", self.api_port)
|
||||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
response, content = https.request(path, 'GET')
|
||||
self.assertEqual(response.status, 300)
|
||||
self.assertEqual(300, response.status)
|
||||
self.assertEqual(content, versions_json)
|
||||
|
||||
# 1. GET /images with no Accept: header
|
||||
|
@ -513,7 +513,7 @@ class TestSSL(functional.FunctionalTest):
|
|||
path = "https://%s:%d/images" % ("127.0.0.1", self.api_port)
|
||||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
response, content = https.request(path, 'GET')
|
||||
self.assertEqual(response.status, 300)
|
||||
self.assertEqual(300, response.status)
|
||||
self.assertEqual(content, versions_json)
|
||||
|
||||
# 2. GET /v1/images with no Accept: header
|
||||
|
@ -521,7 +521,7 @@ class TestSSL(functional.FunctionalTest):
|
|||
path = "https://%s:%d/v1/images" % ("127.0.0.1", self.api_port)
|
||||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
response, content = https.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
self.assertEqual(content, images_json)
|
||||
|
||||
# 3. GET / with Accept: unknown header
|
||||
|
@ -531,7 +531,7 @@ class TestSSL(functional.FunctionalTest):
|
|||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
headers = {'Accept': 'unknown'}
|
||||
response, content = https.request(path, 'GET', headers=headers)
|
||||
self.assertEqual(response.status, 300)
|
||||
self.assertEqual(300, response.status)
|
||||
self.assertEqual(content, versions_json)
|
||||
self.assertTrue('Unknown version. Returning version choices'
|
||||
in open(self.api_server.log_file).read())
|
||||
|
@ -542,7 +542,7 @@ class TestSSL(functional.FunctionalTest):
|
|||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
headers = {'Accept': 'application/vnd.openstack.images-v1'}
|
||||
response, content = https.request(path, 'GET', headers=headers)
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
self.assertEqual(content, images_json)
|
||||
|
||||
# 5. GET /images with a Accept: application/vnd.openstack.compute-v1
|
||||
|
@ -552,7 +552,7 @@ class TestSSL(functional.FunctionalTest):
|
|||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
headers = {'Accept': 'application/vnd.openstack.compute-v1'}
|
||||
response, content = https.request(path, 'GET', headers=headers)
|
||||
self.assertEqual(response.status, 300)
|
||||
self.assertEqual(300, response.status)
|
||||
self.assertEqual(content, versions_json)
|
||||
self.assertTrue('Unknown version. Returning version choices'
|
||||
in open(self.api_server.log_file).read())
|
||||
|
@ -562,7 +562,7 @@ class TestSSL(functional.FunctionalTest):
|
|||
path = "https://%s:%d/v1.0/images" % ("127.0.0.1", self.api_port)
|
||||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
response, content = https.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
self.assertEqual(content, images_json)
|
||||
|
||||
# 7. GET /v1.a/images with no Accept: header
|
||||
|
@ -570,7 +570,7 @@ class TestSSL(functional.FunctionalTest):
|
|||
path = "https://%s:%d/v1.a/images" % ("127.0.0.1", self.api_port)
|
||||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
response, content = https.request(path, 'GET')
|
||||
self.assertEqual(response.status, 300)
|
||||
self.assertEqual(300, response.status)
|
||||
self.assertEqual(content, versions_json)
|
||||
|
||||
# 8. GET /va.1/images with no Accept: header
|
||||
|
@ -578,7 +578,7 @@ class TestSSL(functional.FunctionalTest):
|
|||
path = "https://%s:%d/va.1/images" % ("127.0.0.1", self.api_port)
|
||||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
response, content = https.request(path, 'GET')
|
||||
self.assertEqual(response.status, 300)
|
||||
self.assertEqual(300, response.status)
|
||||
self.assertEqual(content, versions_json)
|
||||
|
||||
# 9. GET /versions with no Accept: header
|
||||
|
@ -586,7 +586,7 @@ class TestSSL(functional.FunctionalTest):
|
|||
path = "https://%s:%d/versions" % ("127.0.0.1", self.api_port)
|
||||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
response, content = https.request(path, 'GET')
|
||||
self.assertEqual(response.status, 300)
|
||||
self.assertEqual(300, response.status)
|
||||
self.assertEqual(content, versions_json)
|
||||
|
||||
# 10. GET /versions with a Accept: application/vnd.openstack.images-v1
|
||||
|
@ -595,7 +595,7 @@ class TestSSL(functional.FunctionalTest):
|
|||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
headers = {'Accept': 'application/vnd.openstack.images-v1'}
|
||||
response, content = https.request(path, 'GET', headers=headers)
|
||||
self.assertEqual(response.status, 300)
|
||||
self.assertEqual(300, response.status)
|
||||
self.assertEqual(content, versions_json)
|
||||
|
||||
# 11. GET /v1/versions with no Accept: header
|
||||
|
@ -603,21 +603,21 @@ class TestSSL(functional.FunctionalTest):
|
|||
path = "https://%s:%d/v1/versions" % ("127.0.0.1", self.api_port)
|
||||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
response, content = https.request(path, 'GET')
|
||||
self.assertEqual(response.status, 404)
|
||||
self.assertEqual(404, response.status)
|
||||
|
||||
# 12. GET /v2/versions with no Accept: header
|
||||
# Verify version choices returned
|
||||
path = "https://%s:%d/v2/versions" % ("127.0.0.1", self.api_port)
|
||||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
response, content = https.request(path, 'GET')
|
||||
self.assertEqual(response.status, 404)
|
||||
self.assertEqual(404, response.status)
|
||||
|
||||
# 12b. GET /v3/versions with no Accept: header (where v3 in unknown)
|
||||
# Verify version choices returned
|
||||
path = "https://%s:%d/v3/versions" % ("127.0.0.1", self.api_port)
|
||||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
response, content = https.request(path, 'GET')
|
||||
self.assertEqual(response.status, 300)
|
||||
self.assertEqual(300, response.status)
|
||||
self.assertEqual(content, versions_json)
|
||||
|
||||
# 13. GET /images with a Accept: application/vnd.openstack.compute-v3
|
||||
|
@ -627,7 +627,7 @@ class TestSSL(functional.FunctionalTest):
|
|||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
headers = {'Accept': 'application/vnd.openstack.images-v3'}
|
||||
response, content = https.request(path, 'GET', headers=headers)
|
||||
self.assertEqual(response.status, 300)
|
||||
self.assertEqual(300, response.status)
|
||||
self.assertEqual(content, versions_json)
|
||||
self.assertTrue('Unknown version. Returning version choices'
|
||||
in open(self.api_server.log_file).read())
|
||||
|
@ -637,7 +637,7 @@ class TestSSL(functional.FunctionalTest):
|
|||
path = "https://%s:%d/v1.2/images" % ("127.0.0.1", self.api_port)
|
||||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
response, content = https.request(path, 'GET')
|
||||
self.assertEqual(response.status, 300)
|
||||
self.assertEqual(300, response.status)
|
||||
self.assertEqual(content, versions_json)
|
||||
|
||||
self.stop_servers()
|
||||
|
@ -669,7 +669,7 @@ class TestSSL(functional.FunctionalTest):
|
|||
'POST',
|
||||
headers=headers,
|
||||
body=test_data_file.name)
|
||||
self.assertEqual(response.status, 400)
|
||||
self.assertEqual(400, response.status)
|
||||
expected = "Content-Type must be application/octet-stream"
|
||||
self.assertTrue(expected in content,
|
||||
"Could not find '%s' in '%s'" % (expected, content))
|
||||
|
@ -689,8 +689,8 @@ class TestSSL(functional.FunctionalTest):
|
|||
path = "https://%s:%d/v1/images" % ("127.0.0.1", self.api_port)
|
||||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
response, content = https.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(content, '{"images": []}')
|
||||
self.assertEqual(200, response.status)
|
||||
self.assertEqual('{"images": []}', content)
|
||||
|
||||
# 1. POST /images with three public images, and one private image
|
||||
# with various attributes
|
||||
|
@ -705,7 +705,7 @@ class TestSSL(functional.FunctionalTest):
|
|||
path = "https://%s:%d/v1/images" % ("127.0.0.1", self.api_port)
|
||||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
response, content = https.request(path, 'POST', headers=headers)
|
||||
self.assertEqual(response.status, 201)
|
||||
self.assertEqual(201, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
self.assertEqual(data['image']['properties']['pants'], "are on")
|
||||
self.assertTrue(data['image']['is_public'])
|
||||
|
@ -721,7 +721,7 @@ class TestSSL(functional.FunctionalTest):
|
|||
path = "https://%s:%d/v1/images" % ("127.0.0.1", self.api_port)
|
||||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
response, content = https.request(path, 'POST', headers=headers)
|
||||
self.assertEqual(response.status, 201)
|
||||
self.assertEqual(201, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
self.assertEqual(data['image']['properties']['pants'], "are on")
|
||||
self.assertTrue(data['image']['is_public'])
|
||||
|
@ -737,7 +737,7 @@ class TestSSL(functional.FunctionalTest):
|
|||
path = "https://%s:%d/v1/images" % ("127.0.0.1", self.api_port)
|
||||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
response, content = https.request(path, 'POST', headers=headers)
|
||||
self.assertEqual(response.status, 201)
|
||||
self.assertEqual(201, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
self.assertEqual(data['image']['properties']['pants'], "are off")
|
||||
self.assertTrue(data['image']['is_public'])
|
||||
|
@ -752,7 +752,7 @@ class TestSSL(functional.FunctionalTest):
|
|||
path = "https://%s:%d/v1/images" % ("127.0.0.1", self.api_port)
|
||||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
response, content = https.request(path, 'POST', headers=headers)
|
||||
self.assertEqual(response.status, 201)
|
||||
self.assertEqual(201, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
self.assertFalse(data['image']['is_public'])
|
||||
|
||||
|
@ -760,9 +760,9 @@ class TestSSL(functional.FunctionalTest):
|
|||
# Verify three public images
|
||||
path = "https://%s:%d/v1/images" % ("127.0.0.1", self.api_port)
|
||||
response, content = https.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
self.assertEqual(len(data['images']), 3)
|
||||
self.assertEqual(3, len(data['images']))
|
||||
|
||||
# 3. GET /images with name filter
|
||||
# Verify correct images returned with name
|
||||
|
@ -770,11 +770,11 @@ class TestSSL(functional.FunctionalTest):
|
|||
path = "https://%s:%d/v1/images?%s" % (
|
||||
"127.0.0.1", self.api_port, params)
|
||||
response, content = https.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
self.assertEqual(len(data['images']), 2)
|
||||
self.assertEqual(2, len(data['images']))
|
||||
for image in data['images']:
|
||||
self.assertEqual(image['name'], "My Image!")
|
||||
self.assertEqual("My Image!", image['name'])
|
||||
|
||||
# 4. GET /images with status filter
|
||||
# Verify correct images returned with status
|
||||
|
@ -782,19 +782,19 @@ class TestSSL(functional.FunctionalTest):
|
|||
path = "https://%s:%d/v1/images/detail?%s" % (
|
||||
"127.0.0.1", self.api_port, params)
|
||||
response, content = https.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
self.assertEqual(len(data['images']), 3)
|
||||
self.assertEqual(3, len(data['images']))
|
||||
for image in data['images']:
|
||||
self.assertEqual(image['status'], "queued")
|
||||
self.assertEqual("queued", image['status'])
|
||||
|
||||
params = "status=active"
|
||||
path = "https://%s:%d/v1/images/detail?%s" % (
|
||||
"127.0.0.1", self.api_port, params)
|
||||
response, content = https.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
self.assertEqual(len(data['images']), 0)
|
||||
self.assertEqual(0, len(data['images']))
|
||||
|
||||
# 5. GET /images with container_format filter
|
||||
# Verify correct images returned with container_format
|
||||
|
@ -802,11 +802,11 @@ class TestSSL(functional.FunctionalTest):
|
|||
path = "https://%s:%d/v1/images?%s" % (
|
||||
"127.0.0.1", self.api_port, params)
|
||||
response, content = https.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
self.assertEqual(len(data['images']), 2)
|
||||
self.assertEqual(2, len(data['images']))
|
||||
for image in data['images']:
|
||||
self.assertEqual(image['container_format'], "ovf")
|
||||
self.assertEqual("ovf", image['container_format'])
|
||||
|
||||
# 6. GET /images with disk_format filter
|
||||
# Verify correct images returned with disk_format
|
||||
|
@ -814,11 +814,11 @@ class TestSSL(functional.FunctionalTest):
|
|||
path = "https://%s:%d/v1/images?%s" % (
|
||||
"127.0.0.1", self.api_port, params)
|
||||
response, content = https.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
self.assertEqual(len(data['images']), 1)
|
||||
self.assertEqual(1, len(data['images']))
|
||||
for image in data['images']:
|
||||
self.assertEqual(image['disk_format'], "vdi")
|
||||
self.assertEqual("vdi", image['disk_format'])
|
||||
|
||||
# 7. GET /images with size_max filter
|
||||
# Verify correct images returned with size <= expected
|
||||
|
@ -826,9 +826,9 @@ class TestSSL(functional.FunctionalTest):
|
|||
path = "https://%s:%d/v1/images?%s" % (
|
||||
"127.0.0.1", self.api_port, params)
|
||||
response, content = https.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
self.assertEqual(len(data['images']), 2)
|
||||
self.assertEqual(2, len(data['images']))
|
||||
for image in data['images']:
|
||||
self.assertTrue(image['size'] <= 20)
|
||||
|
||||
|
@ -838,9 +838,9 @@ class TestSSL(functional.FunctionalTest):
|
|||
path = "https://%s:%d/v1/images?%s" % (
|
||||
"127.0.0.1", self.api_port, params)
|
||||
response, content = https.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
self.assertEqual(len(data['images']), 2)
|
||||
self.assertEqual(2, len(data['images']))
|
||||
for image in data['images']:
|
||||
self.assertTrue(image['size'] >= 20)
|
||||
|
||||
|
@ -851,9 +851,9 @@ class TestSSL(functional.FunctionalTest):
|
|||
path = "https://%s:%d/v1/images?%s" % (
|
||||
"127.0.0.1", self.api_port, params)
|
||||
response, content = https.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
self.assertEqual(len(data['images']), 4)
|
||||
self.assertEqual(4, len(data['images']))
|
||||
|
||||
# 10. Get /images with is_public=False filter
|
||||
# Verify correct images returned with property
|
||||
|
@ -862,11 +862,11 @@ class TestSSL(functional.FunctionalTest):
|
|||
path = "https://%s:%d/v1/images?%s" % (
|
||||
"127.0.0.1", self.api_port, params)
|
||||
response, content = https.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
self.assertEqual(len(data['images']), 1)
|
||||
self.assertEqual(1, len(data['images']))
|
||||
for image in data['images']:
|
||||
self.assertEqual(image['name'], "My Private Image")
|
||||
self.assertEqual("My Private Image", image['name'])
|
||||
|
||||
# 11. Get /images with is_public=True filter
|
||||
# Verify correct images returned with property
|
||||
|
@ -875,9 +875,9 @@ class TestSSL(functional.FunctionalTest):
|
|||
path = "https://%s:%d/v1/images?%s" % (
|
||||
"127.0.0.1", self.api_port, params)
|
||||
response, content = https.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
self.assertEqual(len(data['images']), 3)
|
||||
self.assertEqual(3, len(data['images']))
|
||||
for image in data['images']:
|
||||
self.assertNotEqual(image['name'], "My Private Image")
|
||||
|
||||
|
@ -887,11 +887,11 @@ class TestSSL(functional.FunctionalTest):
|
|||
path = "https://%s:%d/v1/images/detail?%s" % (
|
||||
"127.0.0.1", self.api_port, params)
|
||||
response, content = https.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
self.assertEqual(len(data['images']), 2)
|
||||
self.assertEqual(2, len(data['images']))
|
||||
for image in data['images']:
|
||||
self.assertEqual(image['properties']['pants'], "are on")
|
||||
self.assertEqual("are on", image['properties']['pants'])
|
||||
|
||||
# 13. GET /images with property filter and name filter
|
||||
# Verify correct images returned with property and name
|
||||
|
@ -900,12 +900,12 @@ class TestSSL(functional.FunctionalTest):
|
|||
path = "https://%s:%d/v1/images/detail?%s" % (
|
||||
"127.0.0.1", self.api_port, params)
|
||||
response, content = https.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
self.assertEqual(len(data['images']), 1)
|
||||
self.assertEqual(1, len(data['images']))
|
||||
for image in data['images']:
|
||||
self.assertEqual(image['properties']['pants'], "are on")
|
||||
self.assertEqual(image['name'], "My Image!")
|
||||
self.assertEqual("are on", image['properties']['pants'])
|
||||
self.assertEqual("My Image!", image['name'])
|
||||
|
||||
# 14. GET /images with past changes-since filter
|
||||
dt1 = timeutils.utcnow() - datetime.timedelta(1)
|
||||
|
@ -914,9 +914,9 @@ class TestSSL(functional.FunctionalTest):
|
|||
path = "https://%s:%d/v1/images?%s" % ("127.0.0.1",
|
||||
self.api_port, params)
|
||||
response, content = https.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
self.assertEqual(len(data['images']), 3)
|
||||
self.assertEqual(3, len(data['images']))
|
||||
|
||||
# 15. GET /images with future changes-since filter
|
||||
dt2 = timeutils.utcnow() + datetime.timedelta(1)
|
||||
|
@ -925,9 +925,9 @@ class TestSSL(functional.FunctionalTest):
|
|||
path = "https://%s:%d/v1/images?%s" % ("127.0.0.1",
|
||||
self.api_port, params)
|
||||
response, content = https.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
self.assertEqual(len(data['images']), 0)
|
||||
self.assertEqual(0, len(data['images']))
|
||||
|
||||
self.stop_servers()
|
||||
|
||||
|
@ -944,15 +944,15 @@ class TestSSL(functional.FunctionalTest):
|
|||
path = "https://%s:%d/v1/images" % ("127.0.0.1", self.api_port)
|
||||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
response, content = https.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(content, '{"images": []}')
|
||||
self.assertEqual(200, response.status)
|
||||
self.assertEqual('{"images": []}', content)
|
||||
|
||||
# 1. POST /images with three public images with various attributes
|
||||
headers = minimal_headers('Image1')
|
||||
path = "https://%s:%d/v1/images" % ("127.0.0.1", self.api_port)
|
||||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
response, content = https.request(path, 'POST', headers=headers)
|
||||
self.assertEqual(response.status, 201)
|
||||
self.assertEqual(201, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
|
||||
image_ids = [data['image']['id']]
|
||||
|
@ -961,7 +961,7 @@ class TestSSL(functional.FunctionalTest):
|
|||
path = "https://%s:%d/v1/images" % ("127.0.0.1", self.api_port)
|
||||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
response, content = https.request(path, 'POST', headers=headers)
|
||||
self.assertEqual(response.status, 201)
|
||||
self.assertEqual(201, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
|
||||
image_ids.append(data['image']['id'])
|
||||
|
@ -970,7 +970,7 @@ class TestSSL(functional.FunctionalTest):
|
|||
path = "https://%s:%d/v1/images" % ("127.0.0.1", self.api_port)
|
||||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
response, content = https.request(path, 'POST', headers=headers)
|
||||
self.assertEqual(response.status, 201)
|
||||
self.assertEqual(201, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
|
||||
image_ids.append(data['image']['id'])
|
||||
|
@ -981,11 +981,11 @@ class TestSSL(functional.FunctionalTest):
|
|||
path = "https://%s:%d/v1/images?%s" % (
|
||||
"127.0.0.1", self.api_port, params)
|
||||
response, content = https.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
self.assertEqual(len(data['images']), 2)
|
||||
self.assertEqual(data['images'][0]['id'], image_ids[2])
|
||||
self.assertEqual(data['images'][1]['id'], image_ids[1])
|
||||
self.assertEqual(2, len(data['images']))
|
||||
self.assertEqual(image_ids[2], data['images'][0]['id'])
|
||||
self.assertEqual(image_ids[1], data['images'][1]['id'])
|
||||
|
||||
# 3. GET /images with marker
|
||||
# Verify only two images were returned
|
||||
|
@ -993,11 +993,11 @@ class TestSSL(functional.FunctionalTest):
|
|||
path = "https://%s:%d/v1/images?%s" % (
|
||||
"127.0.0.1", self.api_port, params)
|
||||
response, content = https.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
self.assertEqual(len(data['images']), 2)
|
||||
self.assertEqual(data['images'][0]['id'], image_ids[1])
|
||||
self.assertEqual(data['images'][1]['id'], image_ids[0])
|
||||
self.assertEqual(2, len(data['images']))
|
||||
self.assertEqual(image_ids[1], data['images'][0]['id'])
|
||||
self.assertEqual(image_ids[0], data['images'][1]['id'])
|
||||
|
||||
# 4. GET /images with marker and limit
|
||||
# Verify only one image was returned with the correct id
|
||||
|
@ -1005,10 +1005,10 @@ class TestSSL(functional.FunctionalTest):
|
|||
path = "https://%s:%d/v1/images?%s" % (
|
||||
"127.0.0.1", self.api_port, params)
|
||||
response, content = https.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
self.assertEqual(len(data['images']), 1)
|
||||
self.assertEqual(data['images'][0]['id'], image_ids[0])
|
||||
self.assertEqual(1, len(data['images']))
|
||||
self.assertEqual(image_ids[0], data['images'][0]['id'])
|
||||
|
||||
# 5. GET /images/detail with marker and limit
|
||||
# Verify only one image was returned with the correct id
|
||||
|
@ -1016,10 +1016,10 @@ class TestSSL(functional.FunctionalTest):
|
|||
path = "https://%s:%d/v1/images?%s" % (
|
||||
"127.0.0.1", self.api_port, params)
|
||||
response, content = https.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
self.assertEqual(len(data['images']), 1)
|
||||
self.assertEqual(data['images'][0]['id'], image_ids[1])
|
||||
self.assertEqual(1, len(data['images']))
|
||||
self.assertEqual(image_ids[1], data['images'][0]['id'])
|
||||
|
||||
self.stop_servers()
|
||||
|
||||
|
@ -1036,8 +1036,8 @@ class TestSSL(functional.FunctionalTest):
|
|||
path = "https://%s:%d/v1/images" % ("127.0.0.1", self.api_port)
|
||||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
response, content = https.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(content, '{"images": []}')
|
||||
self.assertEqual(200, response.status)
|
||||
self.assertEqual('{"images": []}', content)
|
||||
|
||||
# 1. POST /images with three public images with various attributes
|
||||
headers = {'Content-Type': 'application/octet-stream',
|
||||
|
@ -1050,7 +1050,7 @@ class TestSSL(functional.FunctionalTest):
|
|||
path = "https://%s:%d/v1/images" % ("127.0.0.1", self.api_port)
|
||||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
response, content = https.request(path, 'POST', headers=headers)
|
||||
self.assertEqual(response.status, 201)
|
||||
self.assertEqual(201, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
|
||||
image_ids = [data['image']['id']]
|
||||
|
@ -1065,7 +1065,7 @@ class TestSSL(functional.FunctionalTest):
|
|||
path = "https://%s:%d/v1/images" % ("127.0.0.1", self.api_port)
|
||||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
response, content = https.request(path, 'POST', headers=headers)
|
||||
self.assertEqual(response.status, 201)
|
||||
self.assertEqual(201, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
|
||||
image_ids.append(data['image']['id'])
|
||||
|
@ -1080,7 +1080,7 @@ class TestSSL(functional.FunctionalTest):
|
|||
path = "https://%s:%d/v1/images" % ("127.0.0.1", self.api_port)
|
||||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
response, content = https.request(path, 'POST', headers=headers)
|
||||
self.assertEqual(response.status, 201)
|
||||
self.assertEqual(201, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
|
||||
image_ids.append(data['image']['id'])
|
||||
|
@ -1090,12 +1090,12 @@ class TestSSL(functional.FunctionalTest):
|
|||
path = "https://%s:%d/v1/images" % ("127.0.0.1", self.api_port)
|
||||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
response, content = https.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
self.assertEqual(len(data['images']), 3)
|
||||
self.assertEqual(data['images'][0]['id'], image_ids[2])
|
||||
self.assertEqual(data['images'][1]['id'], image_ids[1])
|
||||
self.assertEqual(data['images'][2]['id'], image_ids[0])
|
||||
self.assertEqual(3, len(data['images']))
|
||||
self.assertEqual(image_ids[2], data['images'][0]['id'])
|
||||
self.assertEqual(image_ids[1], data['images'][1]['id'])
|
||||
self.assertEqual(image_ids[0], data['images'][2]['id'])
|
||||
|
||||
# 3. GET /images sorted by name asc
|
||||
params = 'sort_key=name&sort_dir=asc'
|
||||
|
@ -1103,12 +1103,12 @@ class TestSSL(functional.FunctionalTest):
|
|||
self.api_port, params)
|
||||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
response, content = https.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
self.assertEqual(len(data['images']), 3)
|
||||
self.assertEqual(data['images'][0]['id'], image_ids[1])
|
||||
self.assertEqual(data['images'][1]['id'], image_ids[0])
|
||||
self.assertEqual(data['images'][2]['id'], image_ids[2])
|
||||
self.assertEqual(3, len(data['images']))
|
||||
self.assertEqual(image_ids[1], data['images'][0]['id'])
|
||||
self.assertEqual(image_ids[0], data['images'][1]['id'])
|
||||
self.assertEqual(image_ids[2], data['images'][2]['id'])
|
||||
|
||||
# 4. GET /images sorted by size desc
|
||||
params = 'sort_key=size&sort_dir=desc'
|
||||
|
@ -1116,23 +1116,23 @@ class TestSSL(functional.FunctionalTest):
|
|||
self.api_port, params)
|
||||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
response, content = https.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
self.assertEqual(len(data['images']), 3)
|
||||
self.assertEqual(data['images'][0]['id'], image_ids[0])
|
||||
self.assertEqual(data['images'][1]['id'], image_ids[2])
|
||||
self.assertEqual(data['images'][2]['id'], image_ids[1])
|
||||
self.assertEqual(3, len(data['images']))
|
||||
self.assertEqual(image_ids[0], data['images'][0]['id'])
|
||||
self.assertEqual(image_ids[2], data['images'][1]['id'])
|
||||
self.assertEqual(image_ids[1], data['images'][2]['id'])
|
||||
# 5. GET /images sorted by size desc with a marker
|
||||
params = 'sort_key=size&sort_dir=desc&marker=%s' % image_ids[0]
|
||||
path = "https://%s:%d/v1/images?%s" % ("127.0.0.1",
|
||||
self.api_port, params)
|
||||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
response, content = https.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
self.assertEqual(len(data['images']), 2)
|
||||
self.assertEqual(data['images'][0]['id'], image_ids[2])
|
||||
self.assertEqual(data['images'][1]['id'], image_ids[1])
|
||||
self.assertEqual(2, len(data['images']))
|
||||
self.assertEqual(image_ids[2], data['images'][0]['id'])
|
||||
self.assertEqual(image_ids[1], data['images'][1]['id'])
|
||||
|
||||
# 6. GET /images sorted by name asc with a marker
|
||||
params = 'sort_key=name&sort_dir=asc&marker=%s' % image_ids[2]
|
||||
|
@ -1140,9 +1140,9 @@ class TestSSL(functional.FunctionalTest):
|
|||
self.api_port, params)
|
||||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
response, content = https.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
self.assertEqual(len(data['images']), 0)
|
||||
self.assertEqual(0, len(data['images']))
|
||||
|
||||
self.stop_servers()
|
||||
|
||||
|
@ -1159,8 +1159,8 @@ class TestSSL(functional.FunctionalTest):
|
|||
path = "https://%s:%d/v1/images" % ("127.0.0.1", self.api_port)
|
||||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
response, content = https.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(content, '{"images": []}')
|
||||
self.assertEqual(200, response.status)
|
||||
self.assertEqual('{"images": []}', content)
|
||||
|
||||
# 1. POST /images with public image named Image1
|
||||
headers = {'Content-Type': 'application/octet-stream',
|
||||
|
@ -1173,7 +1173,7 @@ class TestSSL(functional.FunctionalTest):
|
|||
path = "https://%s:%d/v1/images" % ("127.0.0.1", self.api_port)
|
||||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
response, content = https.request(path, 'POST', headers=headers)
|
||||
self.assertEqual(response.status, 201)
|
||||
self.assertEqual(201, response.status)
|
||||
data = jsonutils.loads(content)
|
||||
|
||||
image_id = data['image']['id']
|
||||
|
@ -1190,7 +1190,7 @@ class TestSSL(functional.FunctionalTest):
|
|||
path = "https://%s:%d/v1/images" % ("127.0.0.1", self.api_port)
|
||||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
response, content = https.request(path, 'POST', headers=headers)
|
||||
self.assertEqual(response.status, 409)
|
||||
self.assertEqual(409, response.status)
|
||||
expected = "An image with identifier %s already exists" % image_id
|
||||
self.assertTrue(expected in content,
|
||||
"Could not find '%s' in '%s'" % (expected, content))
|
||||
|
@ -1215,8 +1215,8 @@ class TestSSL(functional.FunctionalTest):
|
|||
path = "https://%s:%d/v1/images" % ("127.0.0.1", self.api_port)
|
||||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
response, content = https.request(path, 'GET')
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(content, '{"images": []}')
|
||||
self.assertEqual(200, response.status)
|
||||
self.assertEqual('{"images": []}', content)
|
||||
|
||||
# 1. DELETE /images/1
|
||||
# Verify 404 returned
|
||||
|
@ -1224,6 +1224,6 @@ class TestSSL(functional.FunctionalTest):
|
|||
str(uuid.uuid4()))
|
||||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
response, content = https.request(path, 'DELETE')
|
||||
self.assertEqual(response.status, 404)
|
||||
self.assertEqual(404, response.status)
|
||||
|
||||
self.stop_servers()
|
||||
|
|
|
@ -133,7 +133,7 @@ class TestImages(functional.FunctionalTest):
|
|||
u'container_format',
|
||||
u'owner',
|
||||
])
|
||||
self.assertEqual(set(image.keys()), checked_keys)
|
||||
self.assertEqual(checked_keys, set(image.keys()))
|
||||
expected_image = {
|
||||
'status': 'queued',
|
||||
'name': 'image-1',
|
||||
|
@ -193,7 +193,7 @@ class TestImages(functional.FunctionalTest):
|
|||
u'container_format',
|
||||
u'owner',
|
||||
])
|
||||
self.assertEqual(set(image.keys()), checked_keys)
|
||||
self.assertEqual(checked_keys, set(image.keys()))
|
||||
expected_image = {
|
||||
'status': 'queued',
|
||||
'name': 'image-2',
|
||||
|
@ -218,8 +218,8 @@ class TestImages(functional.FunctionalTest):
|
|||
self.assertEqual(200, response.status_code)
|
||||
images = jsonutils.loads(response.text)['images']
|
||||
self.assertEqual(2, len(images))
|
||||
self.assertEqual(images[0]['id'], image2_id)
|
||||
self.assertEqual(images[1]['id'], image_id)
|
||||
self.assertEqual(image2_id, images[0]['id'])
|
||||
self.assertEqual(image_id, images[1]['id'])
|
||||
|
||||
# Image list should list only image-2 as image-1 doesn't contain the
|
||||
# property 'bar'
|
||||
|
@ -228,7 +228,7 @@ class TestImages(functional.FunctionalTest):
|
|||
self.assertEqual(200, response.status_code)
|
||||
images = jsonutils.loads(response.text)['images']
|
||||
self.assertEqual(1, len(images))
|
||||
self.assertEqual(images[0]['id'], image2_id)
|
||||
self.assertEqual(image2_id, images[0]['id'])
|
||||
|
||||
# Image list should list only image-1 as image-2 doesn't contain the
|
||||
# property 'foo'
|
||||
|
@ -237,7 +237,7 @@ class TestImages(functional.FunctionalTest):
|
|||
self.assertEqual(200, response.status_code)
|
||||
images = jsonutils.loads(response.text)['images']
|
||||
self.assertEqual(1, len(images))
|
||||
self.assertEqual(images[0]['id'], image_id)
|
||||
self.assertEqual(image_id, images[0]['id'])
|
||||
|
||||
# The "changes-since" filter shouldn't work on glance v2
|
||||
path = self._url('/v2/images?changes-since=20001007T10:10:10')
|
||||
|
@ -255,7 +255,7 @@ class TestImages(functional.FunctionalTest):
|
|||
self.assertEqual(200, response.status_code)
|
||||
images = jsonutils.loads(response.text)['images']
|
||||
self.assertEqual(1, len(images))
|
||||
self.assertEqual(images[0]['id'], image_id)
|
||||
self.assertEqual(image_id, images[0]['id'])
|
||||
|
||||
# Image list should list only image-2 based on the filter
|
||||
# 'bar=foo&xyz=abc'
|
||||
|
@ -264,7 +264,7 @@ class TestImages(functional.FunctionalTest):
|
|||
self.assertEqual(200, response.status_code)
|
||||
images = jsonutils.loads(response.text)['images']
|
||||
self.assertEqual(1, len(images))
|
||||
self.assertEqual(images[0]['id'], image2_id)
|
||||
self.assertEqual(image2_id, images[0]['id'])
|
||||
|
||||
# Image list should not list anything as the filter 'foo=baz&abc=xyz'
|
||||
# is not satisfied by either images
|
||||
|
@ -416,7 +416,7 @@ class TestImages(functional.FunctionalTest):
|
|||
response = requests.get(path, headers=self._headers())
|
||||
self.assertEqual(200, response.status_code)
|
||||
self.assertEqual(expected_checksum, response.headers['Content-MD5'])
|
||||
self.assertEqual(response.text, 'ZZZZZ')
|
||||
self.assertEqual('ZZZZZ', response.text)
|
||||
|
||||
# Uploading duplicate data should be rejected with a 409. The
|
||||
# original data should remain untouched.
|
||||
|
@ -482,7 +482,7 @@ class TestImages(functional.FunctionalTest):
|
|||
self.assertEqual(200, response.status_code)
|
||||
images = jsonutils.loads(response.text)['images']
|
||||
self.assertEqual(1, len(images))
|
||||
self.assertEqual(images[0]['id'], image2_id)
|
||||
self.assertEqual(image2_id, images[0]['id'])
|
||||
|
||||
# Deleting image-2 should work
|
||||
path = self._url('/v2/images/%s' % image2_id)
|
||||
|
|
|
@ -30,7 +30,7 @@ class TestSchemas(functional.FunctionalTest):
|
|||
# Ensure the image link works and custom properties are loaded
|
||||
path = 'http://%s:%d/v2/schemas/image' % ('127.0.0.1', self.api_port)
|
||||
response = requests.get(path)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(200, response.status_code)
|
||||
image_schema = jsonutils.loads(response.text)
|
||||
expected = set([
|
||||
'id',
|
||||
|
@ -60,7 +60,7 @@ class TestSchemas(functional.FunctionalTest):
|
|||
# Ensure the images link works and agrees with the image schema
|
||||
path = 'http://%s:%d/v2/schemas/images' % ('127.0.0.1', self.api_port)
|
||||
response = requests.get(path)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(200, response.status_code)
|
||||
images_schema = jsonutils.loads(response.text)
|
||||
item_schema = images_schema['properties']['images']['items']
|
||||
self.assertEqual(item_schema, image_schema)
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -101,7 +101,7 @@ class TestTasksApi(base.ApiTest):
|
|||
headers=headers,
|
||||
body=body_content)
|
||||
|
||||
self.assertEqual(response.status, 201)
|
||||
self.assertEqual(201, response.status)
|
||||
|
||||
task = json.loads(content)
|
||||
task_id = task['id']
|
||||
|
@ -121,7 +121,7 @@ class TestTasksApi(base.ApiTest):
|
|||
headers=minimal_task_headers())
|
||||
content_dict = json.loads(content)
|
||||
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
self.assertFalse(content_dict['tasks'])
|
||||
|
||||
# 1. GET /tasks/{task_id}
|
||||
|
@ -131,7 +131,7 @@ class TestTasksApi(base.ApiTest):
|
|||
response, content = self.http.request(path, 'GET',
|
||||
headers=minimal_task_headers())
|
||||
|
||||
self.assertEqual(response.status, 404)
|
||||
self.assertEqual(404, response.status)
|
||||
|
||||
# 2. POST /tasks
|
||||
# Create a new task
|
||||
|
@ -144,7 +144,7 @@ class TestTasksApi(base.ApiTest):
|
|||
path = "/v2/tasks/%s" % task_id
|
||||
response, content = self.http.request(path, 'GET',
|
||||
headers=minimal_task_headers())
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
# 4. GET /tasks
|
||||
# Get all tasks (not deleted)
|
||||
|
@ -152,7 +152,7 @@ class TestTasksApi(base.ApiTest):
|
|||
response, content = self.http.request(path, 'GET',
|
||||
headers=minimal_task_headers())
|
||||
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
self.assertIsNotNone(content)
|
||||
|
||||
data = json.loads(content)
|
||||
|
@ -179,7 +179,7 @@ class TestTasksApi(base.ApiTest):
|
|||
path = "/v2/schemas/task"
|
||||
response, content = self.http.request(path, 'GET',
|
||||
headers=minimal_task_headers())
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
schema = tasks.get_task_schema()
|
||||
expected_schema = schema.minimal()
|
||||
|
@ -192,7 +192,7 @@ class TestTasksApi(base.ApiTest):
|
|||
path = "/v2/schemas/tasks"
|
||||
response, content = self.http.request(path, 'GET',
|
||||
headers=minimal_task_headers())
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
schema = tasks.get_collection_schema()
|
||||
expected_schema = schema.minimal()
|
||||
|
@ -215,7 +215,7 @@ class TestTasksApi(base.ApiTest):
|
|||
response, content = self.http.request(
|
||||
path, 'POST', headers=minimal_task_headers(task_owner),
|
||||
body=body_content)
|
||||
self.assertEqual(response.status, 201)
|
||||
self.assertEqual(201, response.status)
|
||||
|
||||
data = json.loads(content)
|
||||
task_id = data['id']
|
||||
|
@ -236,7 +236,7 @@ class TestTasksApi(base.ApiTest):
|
|||
response, content = self.http.request(
|
||||
path, 'POST', headers=minimal_task_headers(task_owner),
|
||||
body=body_content)
|
||||
self.assertEqual(response.status, 400)
|
||||
self.assertEqual(400, response.status)
|
||||
|
||||
# 1. POST /tasks
|
||||
# Create a new task with invalid input for type 'import'
|
||||
|
@ -249,7 +249,7 @@ class TestTasksApi(base.ApiTest):
|
|||
response, content = self.http.request(
|
||||
path, 'POST', headers=minimal_task_headers(task_owner),
|
||||
body=body_content)
|
||||
self.assertEqual(response.status, 400)
|
||||
self.assertEqual(400, response.status)
|
||||
|
||||
# NOTE(nikhil): wait for all task executions to finish before exiting
|
||||
# else there is a risk of running into deadlock
|
||||
|
@ -263,7 +263,7 @@ class TestTasksApi(base.ApiTest):
|
|||
response, content = self.http.request(path, 'GET',
|
||||
headers=minimal_task_headers())
|
||||
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
content_dict = json.loads(content)
|
||||
self.assertFalse(content_dict['tasks'])
|
||||
|
@ -285,7 +285,7 @@ class TestTasksApi(base.ApiTest):
|
|||
response, content = self.http.request(path, 'GET',
|
||||
headers=minimal_task_headers())
|
||||
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
content_dict = json.loads(content)
|
||||
self.assertEqual(2, len(content_dict['tasks']))
|
||||
|
@ -298,7 +298,7 @@ class TestTasksApi(base.ApiTest):
|
|||
response, content = self.http.request(path, 'GET',
|
||||
headers=minimal_task_headers())
|
||||
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
content_dict = json.loads(content)
|
||||
self.assertEqual(1, len(content_dict['tasks']))
|
||||
|
@ -311,7 +311,7 @@ class TestTasksApi(base.ApiTest):
|
|||
response, content = self.http.request(path, 'GET',
|
||||
headers=minimal_task_headers())
|
||||
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
content_dict = json.loads(content)
|
||||
self.assertEqual(1, len(content_dict['tasks']))
|
||||
|
@ -324,7 +324,7 @@ class TestTasksApi(base.ApiTest):
|
|||
|
||||
response, content = self.http.request(path, 'GET',
|
||||
headers=minimal_task_headers())
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
content_dict = json.loads(content)
|
||||
self.assertEqual(2, len(content_dict['tasks']))
|
||||
|
@ -346,7 +346,7 @@ class TestTasksApi(base.ApiTest):
|
|||
path = "/v2/tasks"
|
||||
response, content = self.http.request(path, 'GET',
|
||||
headers=minimal_task_headers())
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
tasks = json.loads(content)
|
||||
self.assertFalse(tasks['tasks'])
|
||||
|
||||
|
@ -369,7 +369,7 @@ class TestTasksApi(base.ApiTest):
|
|||
response, content = self.http.request(path, 'GET',
|
||||
headers=minimal_task_headers())
|
||||
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
tasks = json.loads(content)['tasks']
|
||||
|
||||
|
@ -382,7 +382,7 @@ class TestTasksApi(base.ApiTest):
|
|||
response, content = self.http.request(path, 'GET',
|
||||
headers=minimal_task_headers())
|
||||
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
actual_tasks = json.loads(content)['tasks']
|
||||
|
||||
|
@ -397,7 +397,7 @@ class TestTasksApi(base.ApiTest):
|
|||
response, content = self.http.request(path, 'GET',
|
||||
headers=minimal_task_headers())
|
||||
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
actual_tasks = json.loads(content)['tasks']
|
||||
|
||||
|
@ -412,7 +412,7 @@ class TestTasksApi(base.ApiTest):
|
|||
response, content = self.http.request(path, 'GET',
|
||||
headers=minimal_task_headers())
|
||||
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
actual_tasks = json.loads(content)['tasks']
|
||||
|
||||
|
@ -429,7 +429,7 @@ class TestTasksApi(base.ApiTest):
|
|||
path = "/v2/tasks"
|
||||
response, content = self.http.request(path, 'GET',
|
||||
headers=minimal_task_headers())
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
tasks = json.loads(content)
|
||||
self.assertFalse(tasks['tasks'])
|
||||
|
||||
|
@ -453,7 +453,7 @@ class TestTasksApi(base.ApiTest):
|
|||
response, content = self.http.request(path, 'GET',
|
||||
headers=minimal_task_headers())
|
||||
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
actual_tasks = json.loads(content)['tasks']
|
||||
|
||||
|
@ -468,7 +468,7 @@ class TestTasksApi(base.ApiTest):
|
|||
response, content = self.http.request(path, 'GET',
|
||||
headers=minimal_task_headers())
|
||||
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
expected_task_owners = [TENANT1, TENANT2, TENANT3]
|
||||
expected_task_owners.sort()
|
||||
|
@ -484,7 +484,7 @@ class TestTasksApi(base.ApiTest):
|
|||
response, content = self.http.request(path, 'GET',
|
||||
headers=minimal_task_headers())
|
||||
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
actual_tasks = json.loads(content)['tasks']
|
||||
self.assertEqual(2, len(actual_tasks))
|
||||
|
@ -500,7 +500,7 @@ class TestTasksApi(base.ApiTest):
|
|||
response, content = self.http.request(path, 'GET',
|
||||
headers=minimal_task_headers())
|
||||
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
actual_tasks = json.loads(content)['tasks']
|
||||
|
||||
|
|
|
@ -70,14 +70,14 @@ class TestGlanceApiCmd(test_utils.BaseTestCase):
|
|||
def test_unsupported_default_store(self):
|
||||
self.config(group='glance_store', default_store='shouldnotexist')
|
||||
exit = self.assertRaises(SystemExit, glance.cmd.api.main)
|
||||
self.assertEqual(exit.code, 1)
|
||||
self.assertEqual(1, exit.code)
|
||||
|
||||
def test_worker_creation_failure(self):
|
||||
failure = exc.WorkerCreationFailure(reason='test')
|
||||
self.stubs.Set(glance.common.wsgi.Server, 'start',
|
||||
self._raise(failure))
|
||||
exit = self.assertRaises(SystemExit, glance.cmd.api.main)
|
||||
self.assertEqual(exit.code, 2)
|
||||
self.assertEqual(2, exit.code)
|
||||
|
||||
@mock.patch.object(glance.common.config, 'parse_cache_args')
|
||||
@mock.patch.object(glance.openstack.common.log, 'setup')
|
||||
|
|
|
@ -72,27 +72,27 @@ class TestProtectedImageRepoProxy(utils.BaseTestCase):
|
|||
image_id = '1'
|
||||
result_image = self.image_repo.get(image_id)
|
||||
result_extra_props = result_image.extra_properties
|
||||
self.assertEqual(result_extra_props['spl_create_prop'], 'c')
|
||||
self.assertEqual(result_extra_props['spl_read_prop'], 'r')
|
||||
self.assertEqual(result_extra_props['spl_update_prop'], 'u')
|
||||
self.assertEqual(result_extra_props['spl_delete_prop'], 'd')
|
||||
self.assertEqual('c', result_extra_props['spl_create_prop'])
|
||||
self.assertEqual('r', result_extra_props['spl_read_prop'])
|
||||
self.assertEqual('u', result_extra_props['spl_update_prop'])
|
||||
self.assertEqual('d', result_extra_props['spl_delete_prop'])
|
||||
self.assertNotIn('forbidden', result_extra_props.keys())
|
||||
|
||||
def test_list_image(self):
|
||||
result_images = self.image_repo.list()
|
||||
self.assertEqual(len(result_images), 3)
|
||||
self.assertEqual(3, len(result_images))
|
||||
result_extra_props = result_images[0].extra_properties
|
||||
self.assertEqual(result_extra_props['spl_create_prop'], 'c')
|
||||
self.assertEqual(result_extra_props['spl_read_prop'], 'r')
|
||||
self.assertEqual(result_extra_props['spl_update_prop'], 'u')
|
||||
self.assertEqual(result_extra_props['spl_delete_prop'], 'd')
|
||||
self.assertEqual('c', result_extra_props['spl_create_prop'])
|
||||
self.assertEqual('r', result_extra_props['spl_read_prop'])
|
||||
self.assertEqual('u', result_extra_props['spl_update_prop'])
|
||||
self.assertEqual('d', result_extra_props['spl_delete_prop'])
|
||||
self.assertNotIn('forbidden', result_extra_props.keys())
|
||||
|
||||
result_extra_props = result_images[1].extra_properties
|
||||
self.assertEqual(result_extra_props, {})
|
||||
self.assertEqual({}, result_extra_props)
|
||||
|
||||
result_extra_props = result_images[2].extra_properties
|
||||
self.assertEqual(result_extra_props['spl_read_prop'], 'r')
|
||||
self.assertEqual('r', result_extra_props['spl_read_prop'])
|
||||
self.assertNotIn('forbidden', result_extra_props.keys())
|
||||
|
||||
|
||||
|
@ -115,7 +115,7 @@ class TestProtectedImageProxy(utils.BaseTestCase):
|
|||
result_image = property_protections.ProtectedImageProxy(
|
||||
image, context, self.property_rules)
|
||||
result_extra_props = result_image.extra_properties
|
||||
self.assertEqual(result_extra_props['spl_read_prop'], 'read')
|
||||
self.assertEqual('read', result_extra_props['spl_read_prop'])
|
||||
self.assertNotIn('spl_fake_prop', result_extra_props.keys())
|
||||
|
||||
|
||||
|
@ -133,7 +133,7 @@ class TestExtraPropertiesProxy(utils.BaseTestCase):
|
|||
extra_prop_proxy = property_protections.ExtraPropertiesProxy(
|
||||
context, extra_properties, self.property_rules)
|
||||
test_result = extra_prop_proxy['foo']
|
||||
self.assertEqual(test_result, 'bar')
|
||||
self.assertEqual('bar', test_result)
|
||||
|
||||
def test_read_extra_property_as_unpermitted_role(self):
|
||||
extra_properties = {'foo': 'bar', 'ping': 'pong'}
|
||||
|
@ -148,7 +148,7 @@ class TestExtraPropertiesProxy(utils.BaseTestCase):
|
|||
extra_prop_proxy = property_protections.ExtraPropertiesProxy(
|
||||
context, extra_properties, self.property_rules)
|
||||
extra_prop_proxy['foo'] = 'par'
|
||||
self.assertEqual(extra_prop_proxy['foo'], 'par')
|
||||
self.assertEqual('par', extra_prop_proxy['foo'])
|
||||
|
||||
def test_update_extra_property_as_unpermitted_role_after_read(self):
|
||||
extra_properties = {'spl_read_prop': 'bar'}
|
||||
|
@ -182,7 +182,7 @@ class TestExtraPropertiesProxy(utils.BaseTestCase):
|
|||
extra_prop_proxy = property_protections.ExtraPropertiesProxy(
|
||||
context, extra_properties, self.property_rules)
|
||||
extra_prop_proxy['boo'] = 'doo'
|
||||
self.assertEqual(extra_prop_proxy['boo'], 'doo')
|
||||
self.assertEqual('doo', extra_prop_proxy['boo'])
|
||||
|
||||
def test_create_reserved_extra_property(self):
|
||||
extra_properties = {}
|
||||
|
@ -214,7 +214,7 @@ class TestExtraPropertiesProxy(utils.BaseTestCase):
|
|||
extra_prop_proxy = property_protections.ExtraPropertiesProxy(
|
||||
context, extra_properties, self.property_rules)
|
||||
# Ensure property has been created and can be read
|
||||
self.assertEqual(extra_prop_proxy['spl_read_prop'], 'r')
|
||||
self.assertEqual('r', extra_prop_proxy['spl_read_prop'])
|
||||
self.assertRaises(exception.ReservedProperty,
|
||||
extra_prop_proxy.__delitem__, 'spl_read_prop')
|
||||
|
||||
|
@ -252,7 +252,7 @@ class TestProtectedImageFactoryProxy(utils.BaseTestCase):
|
|||
extra_props = {}
|
||||
image = self.image_factory.new_image(extra_properties=extra_props)
|
||||
expected_extra_props = {}
|
||||
self.assertEqual(image.extra_properties, expected_extra_props)
|
||||
self.assertEqual(expected_extra_props, image.extra_properties)
|
||||
|
||||
def test_create_image_extra_prop(self):
|
||||
self.context = glance.context.RequestContext(tenant=TENANT1,
|
||||
|
@ -263,7 +263,7 @@ class TestProtectedImageFactoryProxy(utils.BaseTestCase):
|
|||
extra_props = {'spl_create_prop': 'c'}
|
||||
image = self.image_factory.new_image(extra_properties=extra_props)
|
||||
expected_extra_props = {'spl_create_prop': 'c'}
|
||||
self.assertEqual(image.extra_properties, expected_extra_props)
|
||||
self.assertEqual(expected_extra_props, image.extra_properties)
|
||||
|
||||
def test_create_image_extra_prop_reserved_property(self):
|
||||
self.context = glance.context.RequestContext(tenant=TENANT1,
|
||||
|
@ -286,7 +286,7 @@ class TestProtectedImageFactoryProxy(utils.BaseTestCase):
|
|||
extra_props = {'foo': 'bar', 'spl_create_prop': 'c'}
|
||||
image = self.image_factory.new_image(extra_properties=extra_props)
|
||||
expected_extra_props = {'foo': 'bar', 'spl_create_prop': 'c'}
|
||||
self.assertEqual(image.extra_properties, expected_extra_props)
|
||||
self.assertEqual(expected_extra_props, image.extra_properties)
|
||||
|
||||
def test_create_image_extra_prop_invalid_role(self):
|
||||
self.context = glance.context.RequestContext(tenant=TENANT1,
|
||||
|
|
|
@ -25,7 +25,7 @@ class GlanceExceptionTestCase(test_utils.BaseTestCase):
|
|||
message = "default message"
|
||||
|
||||
exc = FakeGlanceException()
|
||||
self.assertEqual(utils.exception_to_str(exc), 'default message')
|
||||
self.assertEqual('default message', utils.exception_to_str(exc))
|
||||
|
||||
def test_specified_error_msg(self):
|
||||
msg = exception.GlanceException('test')
|
||||
|
@ -36,7 +36,7 @@ class GlanceExceptionTestCase(test_utils.BaseTestCase):
|
|||
message = "default message: %(code)s"
|
||||
|
||||
exc = FakeGlanceException(code=500)
|
||||
self.assertEqual(utils.exception_to_str(exc), "default message: 500")
|
||||
self.assertEqual("default message: 500", utils.exception_to_str(exc))
|
||||
|
||||
def test_specified_error_msg_with_kwargs(self):
|
||||
msg = exception.GlanceException('test: %(code)s', code=500)
|
||||
|
|
|
@ -39,9 +39,9 @@ class TestLocationStrategy(base.IsolatedUnitTest):
|
|||
def test_load_strategy_modules(self):
|
||||
modules = location_strategy._load_strategies()
|
||||
# By default we have two built-in strategy modules.
|
||||
self.assertEqual(len(modules), 2)
|
||||
self.assertEqual(set(modules.keys()),
|
||||
set(['location_order', 'store_type']))
|
||||
self.assertEqual(2, len(modules))
|
||||
self.assertEqual(set(['location_order', 'store_type']),
|
||||
set(modules.keys()))
|
||||
self.assertEqual(location_strategy._available_strategies, modules)
|
||||
|
||||
def test_load_strategy_module_with_deduplicating(self):
|
||||
|
@ -67,10 +67,10 @@ class TestLocationStrategy(base.IsolatedUnitTest):
|
|||
_fake_stevedore_driver_manager)
|
||||
|
||||
loaded_modules = location_strategy._load_strategies()
|
||||
self.assertEqual(len(loaded_modules), 1)
|
||||
self.assertEqual(loaded_modules.keys()[0], 'module_name')
|
||||
self.assertEqual(1, len(loaded_modules))
|
||||
self.assertEqual('module_name', loaded_modules.keys()[0])
|
||||
# Skipped module #2, duplicated one.
|
||||
self.assertEqual(loaded_modules['module_name'].__name__, 'module1')
|
||||
self.assertEqual('module1', loaded_modules['module_name'].__name__)
|
||||
|
||||
def test_load_strategy_module_with_init_exception(self):
|
||||
modules = ['module_init_exception', 'module_good']
|
||||
|
@ -97,10 +97,10 @@ class TestLocationStrategy(base.IsolatedUnitTest):
|
|||
_fake_stevedore_driver_manager)
|
||||
|
||||
loaded_modules = location_strategy._load_strategies()
|
||||
self.assertEqual(len(loaded_modules), 1)
|
||||
self.assertEqual(loaded_modules.keys()[0], 'module_good')
|
||||
self.assertEqual(1, len(loaded_modules))
|
||||
self.assertEqual('module_good', loaded_modules.keys()[0])
|
||||
# Skipped module #1, initialize failed one.
|
||||
self.assertEqual(loaded_modules['module_good'].__name__, 'module_good')
|
||||
self.assertEqual('module_good', loaded_modules['module_good'].__name__)
|
||||
|
||||
def test_verify_valid_location_strategy(self):
|
||||
for strategy_name in ['location_order', 'store_type']:
|
||||
|
@ -115,8 +115,8 @@ class TestLocationStrategy(base.IsolatedUnitTest):
|
|||
strategy)
|
||||
|
||||
def test_get_ordered_locations_with_none_or_empty_locations(self):
|
||||
self.assertEqual(location_strategy.get_ordered_locations(None), [])
|
||||
self.assertEqual(location_strategy.get_ordered_locations([]), [])
|
||||
self.assertEqual([], location_strategy.get_ordered_locations(None))
|
||||
self.assertEqual([], location_strategy.get_ordered_locations([]))
|
||||
|
||||
def test_get_ordered_locations(self):
|
||||
self.config(location_strategy='location_order')
|
||||
|
|
|
@ -127,7 +127,7 @@ class TestRPCController(base.IsolatedUnitTest):
|
|||
res = req.get_response(api)
|
||||
returned = jsonutils.loads(res.body)
|
||||
self.assertIsInstance(returned, list)
|
||||
self.assertEqual(returned[0], 1)
|
||||
self.assertEqual(1, returned[0])
|
||||
|
||||
def test_request_exc(self):
|
||||
api = create_api()
|
||||
|
@ -155,27 +155,27 @@ class TestRPCController(base.IsolatedUnitTest):
|
|||
# Body is not a list, it should fail
|
||||
req.body = jsonutils.dumps({})
|
||||
res = req.get_response(api)
|
||||
self.assertEqual(res.status_int, 400)
|
||||
self.assertEqual(400, res.status_int)
|
||||
|
||||
# cmd is not dict, it should fail.
|
||||
req.body = jsonutils.dumps([None])
|
||||
res = req.get_response(api)
|
||||
self.assertEqual(res.status_int, 400)
|
||||
self.assertEqual(400, res.status_int)
|
||||
|
||||
# No command key, it should fail.
|
||||
req.body = jsonutils.dumps([{}])
|
||||
res = req.get_response(api)
|
||||
self.assertEqual(res.status_int, 400)
|
||||
self.assertEqual(400, res.status_int)
|
||||
|
||||
# kwargs not dict, it should fail.
|
||||
req.body = jsonutils.dumps([{"command": "test", "kwargs": 200}])
|
||||
res = req.get_response(api)
|
||||
self.assertEqual(res.status_int, 400)
|
||||
self.assertEqual(400, res.status_int)
|
||||
|
||||
# Command does not exist, it should fail.
|
||||
req.body = jsonutils.dumps([{"command": "test"}])
|
||||
res = req.get_response(api)
|
||||
self.assertEqual(res.status_int, 404)
|
||||
self.assertEqual(404, res.status_int)
|
||||
|
||||
def test_rpc_exception_propagation(self):
|
||||
api = create_api()
|
||||
|
@ -185,18 +185,18 @@ class TestRPCController(base.IsolatedUnitTest):
|
|||
|
||||
req.body = jsonutils.dumps([{"command": "raise_value_error"}])
|
||||
res = req.get_response(api)
|
||||
self.assertEqual(res.status_int, 200)
|
||||
self.assertEqual(200, res.status_int)
|
||||
|
||||
returned = jsonutils.loads(res.body)[0]
|
||||
self.assertEqual(returned['_error']['cls'], 'exceptions.ValueError')
|
||||
self.assertEqual('exceptions.ValueError', returned['_error']['cls'])
|
||||
|
||||
req.body = jsonutils.dumps([{"command": "raise_weird_error"}])
|
||||
res = req.get_response(api)
|
||||
self.assertEqual(res.status_int, 200)
|
||||
self.assertEqual(200, res.status_int)
|
||||
|
||||
returned = jsonutils.loads(res.body)[0]
|
||||
self.assertEqual(returned['_error']['cls'],
|
||||
'glance.common.exception.RPCError')
|
||||
self.assertEqual('glance.common.exception.RPCError',
|
||||
returned['_error']['cls'])
|
||||
|
||||
|
||||
class TestRPCClient(base.IsolatedUnitTest):
|
||||
|
@ -226,7 +226,7 @@ class TestRPCClient(base.IsolatedUnitTest):
|
|||
{"command": "get_all_images"}]
|
||||
|
||||
res = self.client.bulk_request(commands)
|
||||
self.assertEqual(len(res), 2)
|
||||
self.assertEqual(2, len(res))
|
||||
self.assertTrue(res[0])
|
||||
self.assertFalse(res[1])
|
||||
|
||||
|
@ -235,7 +235,7 @@ class TestRPCClient(base.IsolatedUnitTest):
|
|||
self.client.raise_value_error()
|
||||
self.fail("Exception not raised")
|
||||
except ValueError as exc:
|
||||
self.assertEqual(str(exc), "Yep, Just like that!")
|
||||
self.assertEqual("Yep, Just like that!", str(exc))
|
||||
|
||||
def test_rpc_exception(self):
|
||||
try:
|
||||
|
@ -246,7 +246,7 @@ class TestRPCClient(base.IsolatedUnitTest):
|
|||
|
||||
def test_non_str_or_dict_response(self):
|
||||
rst = self.client.count_images(images=[1, 2, 3, 4])
|
||||
self.assertEqual(rst, 4)
|
||||
self.assertEqual(4, rst)
|
||||
self.assertIsInstance(rst, int)
|
||||
|
||||
|
||||
|
@ -256,7 +256,7 @@ class TestRPCJSONSerializer(test_utils.BaseTestCase):
|
|||
fixture = {"key": "value"}
|
||||
expected = '{"key": "value"}'
|
||||
actual = rpc.RPCJSONSerializer().to_json(fixture)
|
||||
self.assertEqual(actual, expected)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_to_json_with_date_format_value(self):
|
||||
fixture = {"date": datetime.datetime(1900, 3, 8, 2)}
|
||||
|
@ -280,12 +280,12 @@ class TestRPCJSONSerializer(test_utils.BaseTestCase):
|
|||
fixture = {"key": "value"}
|
||||
response = webob.Response()
|
||||
rpc.RPCJSONSerializer().default(response, fixture)
|
||||
self.assertEqual(response.status_int, 200)
|
||||
self.assertEqual(200, response.status_int)
|
||||
content_types = filter(lambda h: h[0] == 'Content-Type',
|
||||
response.headerlist)
|
||||
self.assertEqual(len(content_types), 1)
|
||||
self.assertEqual(response.content_type, 'application/json')
|
||||
self.assertEqual(response.body, '{"key": "value"}')
|
||||
self.assertEqual(1, len(content_types))
|
||||
self.assertEqual('application/json', response.content_type)
|
||||
self.assertEqual('{"key": "value"}', response.body)
|
||||
|
||||
|
||||
class TestRPCJSONDeserializer(test_utils.BaseTestCase):
|
||||
|
@ -319,7 +319,7 @@ class TestRPCJSONDeserializer(test_utils.BaseTestCase):
|
|||
fixture = '{"key": "value"}'
|
||||
expected = {"key": "value"}
|
||||
actual = rpc.RPCJSONDeserializer().from_json(fixture)
|
||||
self.assertEqual(actual, expected)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_from_json_malformed(self):
|
||||
fixture = 'kjasdklfjsklajf'
|
||||
|
@ -330,7 +330,7 @@ class TestRPCJSONDeserializer(test_utils.BaseTestCase):
|
|||
request = wsgi.Request.blank('/')
|
||||
actual = rpc.RPCJSONDeserializer().default(request)
|
||||
expected = {}
|
||||
self.assertEqual(actual, expected)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_default_with_body(self):
|
||||
request = wsgi.Request.blank('/')
|
||||
|
@ -338,7 +338,7 @@ class TestRPCJSONDeserializer(test_utils.BaseTestCase):
|
|||
request.body = '{"key": "value"}'
|
||||
actual = rpc.RPCJSONDeserializer().default(request)
|
||||
expected = {"body": {"key": "value"}}
|
||||
self.assertEqual(actual, expected)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_has_body_has_transfer_encoding(self):
|
||||
request = wsgi.Request.blank('/')
|
||||
|
@ -353,4 +353,4 @@ class TestRPCJSONDeserializer(test_utils.BaseTestCase):
|
|||
'"_type": "datetime"}}')
|
||||
expected = {"date": datetime.datetime(1900, 3, 8, 2)}
|
||||
actual = rpc.RPCJSONDeserializer().from_json(fixture)
|
||||
self.assertEqual(actual, expected)
|
||||
self.assertEqual(expected, actual)
|
||||
|
|
|
@ -38,7 +38,7 @@ class TestUtils(test_utils.BaseTestCase):
|
|||
for chunk in utils.CooperativeReader(tmp_fd):
|
||||
bytes_read += len(chunk)
|
||||
|
||||
self.assertEqual(bytes_read, BYTES)
|
||||
self.assertEqual(BYTES, bytes_read)
|
||||
|
||||
bytes_read = 0
|
||||
with tempfile.TemporaryFile('w+') as tmp_fd:
|
||||
|
@ -50,7 +50,7 @@ class TestUtils(test_utils.BaseTestCase):
|
|||
bytes_read += 1
|
||||
byte = reader.read(1)
|
||||
|
||||
self.assertEqual(bytes_read, BYTES)
|
||||
self.assertEqual(BYTES, bytes_read)
|
||||
|
||||
def test_cooperative_reader_of_iterator(self):
|
||||
"""Ensure cooperative reader supports iterator backends too"""
|
||||
|
@ -61,7 +61,7 @@ class TestUtils(test_utils.BaseTestCase):
|
|||
if chunks[-1] == '':
|
||||
break
|
||||
meat = ''.join(chunks)
|
||||
self.assertEqual(meat, 'aaabbbcccdddeeefffggghhh')
|
||||
self.assertEqual('aaabbbcccdddeeefffggghhh', meat)
|
||||
|
||||
def test_cooperative_reader_of_iterator_stop_iteration_err(self):
|
||||
"""Ensure cooperative reader supports iterator backends too"""
|
||||
|
@ -72,7 +72,7 @@ class TestUtils(test_utils.BaseTestCase):
|
|||
if chunks[-1] == '':
|
||||
break
|
||||
meat = ''.join(chunks)
|
||||
self.assertEqual(meat, '')
|
||||
self.assertEqual('', meat)
|
||||
|
||||
def test_limiting_reader(self):
|
||||
"""Ensure limiting reader class accesses all bytes of file"""
|
||||
|
@ -82,7 +82,7 @@ class TestUtils(test_utils.BaseTestCase):
|
|||
for chunk in utils.LimitingReader(data, BYTES):
|
||||
bytes_read += len(chunk)
|
||||
|
||||
self.assertEqual(bytes_read, BYTES)
|
||||
self.assertEqual(BYTES, bytes_read)
|
||||
|
||||
bytes_read = 0
|
||||
data = six.StringIO("*" * BYTES)
|
||||
|
@ -92,7 +92,7 @@ class TestUtils(test_utils.BaseTestCase):
|
|||
bytes_read += 1
|
||||
byte = reader.read(1)
|
||||
|
||||
self.assertEqual(bytes_read, BYTES)
|
||||
self.assertEqual(BYTES, bytes_read)
|
||||
|
||||
def test_limiting_reader_fails(self):
|
||||
"""Ensure limiting reader class throws exceptions if limit exceeded"""
|
||||
|
|
|
@ -90,38 +90,38 @@ class RequestTest(test_utils.BaseTestCase):
|
|||
request = wsgi.Request.blank('/tests/123')
|
||||
request.headers["Content-Type"] = "application/json; charset=UTF-8"
|
||||
result = request.get_content_type(('application/json',))
|
||||
self.assertEqual(result, "application/json")
|
||||
self.assertEqual("application/json", result)
|
||||
|
||||
def test_content_type_from_accept_xml(self):
|
||||
request = wsgi.Request.blank('/tests/123')
|
||||
request.headers["Accept"] = "application/xml"
|
||||
result = request.best_match_content_type()
|
||||
self.assertEqual(result, "application/json")
|
||||
self.assertEqual("application/json", result)
|
||||
|
||||
def test_content_type_from_accept_json(self):
|
||||
request = wsgi.Request.blank('/tests/123')
|
||||
request.headers["Accept"] = "application/json"
|
||||
result = request.best_match_content_type()
|
||||
self.assertEqual(result, "application/json")
|
||||
self.assertEqual("application/json", result)
|
||||
|
||||
def test_content_type_from_accept_xml_json(self):
|
||||
request = wsgi.Request.blank('/tests/123')
|
||||
request.headers["Accept"] = "application/xml, application/json"
|
||||
result = request.best_match_content_type()
|
||||
self.assertEqual(result, "application/json")
|
||||
self.assertEqual("application/json", result)
|
||||
|
||||
def test_content_type_from_accept_json_xml_quality(self):
|
||||
request = wsgi.Request.blank('/tests/123')
|
||||
request.headers["Accept"] = ("application/json; q=0.3, "
|
||||
"application/xml; q=0.9")
|
||||
result = request.best_match_content_type()
|
||||
self.assertEqual(result, "application/json")
|
||||
self.assertEqual("application/json", result)
|
||||
|
||||
def test_content_type_accept_default(self):
|
||||
request = wsgi.Request.blank('/tests/123.unsupported')
|
||||
request.headers["Accept"] = "application/unsupported1"
|
||||
result = request.best_match_content_type()
|
||||
self.assertEqual(result, "application/json")
|
||||
self.assertEqual("application/json", result)
|
||||
|
||||
def test_language_accept_default(self):
|
||||
request = wsgi.Request.blank('/tests/123')
|
||||
|
@ -242,13 +242,13 @@ class ResourceTest(test_utils.BaseTestCase):
|
|||
expected = {'action': 'update', 'id': 12}
|
||||
actual = wsgi.Resource(None, None, None).get_action_args(env)
|
||||
|
||||
self.assertEqual(actual, expected)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_get_action_args_invalid_index(self):
|
||||
env = {'wsgiorg.routing_args': []}
|
||||
expected = {}
|
||||
actual = wsgi.Resource(None, None, None).get_action_args(env)
|
||||
self.assertEqual(actual, expected)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_get_action_args_del_controller_error(self):
|
||||
actions = {'format': None,
|
||||
|
@ -257,14 +257,14 @@ class ResourceTest(test_utils.BaseTestCase):
|
|||
env = {'wsgiorg.routing_args': [None, actions]}
|
||||
expected = {'action': 'update', 'id': 12}
|
||||
actual = wsgi.Resource(None, None, None).get_action_args(env)
|
||||
self.assertEqual(actual, expected)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_get_action_args_del_format_error(self):
|
||||
actions = {'action': 'update', 'id': 12}
|
||||
env = {'wsgiorg.routing_args': [None, actions]}
|
||||
expected = {'action': 'update', 'id': 12}
|
||||
actual = wsgi.Resource(None, None, None).get_action_args(env)
|
||||
self.assertEqual(actual, expected)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_dispatch(self):
|
||||
class Controller(object):
|
||||
|
@ -274,7 +274,7 @@ class ResourceTest(test_utils.BaseTestCase):
|
|||
resource = wsgi.Resource(None, None, None)
|
||||
actual = resource.dispatch(Controller(), 'index', 'on', pants='off')
|
||||
expected = ('on', 'off')
|
||||
self.assertEqual(actual, expected)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_dispatch_default(self):
|
||||
class Controller(object):
|
||||
|
@ -284,7 +284,7 @@ class ResourceTest(test_utils.BaseTestCase):
|
|||
resource = wsgi.Resource(None, None, None)
|
||||
actual = resource.dispatch(Controller(), 'index', 'on', pants='off')
|
||||
expected = ('on', 'off')
|
||||
self.assertEqual(actual, expected)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_dispatch_no_default(self):
|
||||
class Controller(object):
|
||||
|
@ -315,7 +315,7 @@ class ResourceTest(test_utils.BaseTestCase):
|
|||
response = resource.__call__(request)
|
||||
|
||||
self.assertIsInstance(response, webob.exc.HTTPForbidden)
|
||||
self.assertEqual(response.status_code, 403)
|
||||
self.assertEqual(403, response.status_code)
|
||||
|
||||
@mock.patch.object(wsgi, 'translate_exception')
|
||||
def test_resource_call_error_handle_localized(self,
|
||||
|
@ -360,13 +360,13 @@ class JSONResponseSerializerTest(test_utils.BaseTestCase):
|
|||
fixture = {"key": "value"}
|
||||
expected = '{"key": "value"}'
|
||||
actual = wsgi.JSONResponseSerializer().to_json(fixture)
|
||||
self.assertEqual(actual, expected)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_to_json_with_date_format_value(self):
|
||||
fixture = {"date": datetime.datetime(1, 3, 8, 2)}
|
||||
expected = '{"date": "0001-03-08T02:00:00"}'
|
||||
actual = wsgi.JSONResponseSerializer().to_json(fixture)
|
||||
self.assertEqual(actual, expected)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_to_json_with_more_deep_format(self):
|
||||
fixture = {"is_public": True, "name": [{"name1": "test"}]}
|
||||
|
@ -386,12 +386,12 @@ class JSONResponseSerializerTest(test_utils.BaseTestCase):
|
|||
fixture = {"key": "value"}
|
||||
response = webob.Response()
|
||||
wsgi.JSONResponseSerializer().default(response, fixture)
|
||||
self.assertEqual(response.status_int, 200)
|
||||
self.assertEqual(200, response.status_int)
|
||||
content_types = filter(lambda h: h[0] == 'Content-Type',
|
||||
response.headerlist)
|
||||
self.assertEqual(len(content_types), 1)
|
||||
self.assertEqual(response.content_type, 'application/json')
|
||||
self.assertEqual(response.body, '{"key": "value"}')
|
||||
self.assertEqual(1, len(content_types))
|
||||
self.assertEqual('application/json', response.content_type)
|
||||
self.assertEqual('{"key": "value"}', response.body)
|
||||
|
||||
|
||||
class JSONRequestDeserializerTest(test_utils.BaseTestCase):
|
||||
|
@ -425,7 +425,7 @@ class JSONRequestDeserializerTest(test_utils.BaseTestCase):
|
|||
fixture = '{"key": "value"}'
|
||||
expected = {"key": "value"}
|
||||
actual = wsgi.JSONRequestDeserializer().from_json(fixture)
|
||||
self.assertEqual(actual, expected)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_from_json_malformed(self):
|
||||
fixture = 'kjasdklfjsklajf'
|
||||
|
@ -436,7 +436,7 @@ class JSONRequestDeserializerTest(test_utils.BaseTestCase):
|
|||
request = wsgi.Request.blank('/')
|
||||
actual = wsgi.JSONRequestDeserializer().default(request)
|
||||
expected = {}
|
||||
self.assertEqual(actual, expected)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_default_with_body(self):
|
||||
request = wsgi.Request.blank('/')
|
||||
|
@ -444,7 +444,7 @@ class JSONRequestDeserializerTest(test_utils.BaseTestCase):
|
|||
request.body = '{"key": "value"}'
|
||||
actual = wsgi.JSONRequestDeserializer().default(request)
|
||||
expected = {"body": {"key": "value"}}
|
||||
self.assertEqual(actual, expected)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_has_body_has_transfer_encoding(self):
|
||||
request = wsgi.Request.blank('/')
|
||||
|
|
|
@ -309,7 +309,7 @@ class TestKeystoneAuthPlugin(utils.BaseTestCase):
|
|||
for creds in good_creds:
|
||||
plugin = auth.KeystoneStrategy(creds)
|
||||
self.assertIsNone(plugin.authenticate())
|
||||
self.assertEqual(plugin.management_url, "example.com")
|
||||
self.assertEqual("example.com", plugin.management_url)
|
||||
|
||||
# Assert it does not update management_url via auth response
|
||||
for creds in good_creds:
|
||||
|
@ -391,7 +391,7 @@ class TestKeystoneAuthPlugin(utils.BaseTestCase):
|
|||
|
||||
plugin = auth.KeystoneStrategy(no_region_creds)
|
||||
self.assertIsNone(plugin.authenticate())
|
||||
self.assertEqual(plugin.management_url, 'http://localhost:9292')
|
||||
self.assertEqual('http://localhost:9292', plugin.management_url)
|
||||
|
||||
# Add another image service, with a different region
|
||||
mock_token.add_service('image', ['RegionTwo'])
|
||||
|
@ -487,7 +487,7 @@ class TestKeystoneAuthPlugin(utils.BaseTestCase):
|
|||
for creds in good_creds:
|
||||
plugin = auth.KeystoneStrategy(creds)
|
||||
self.assertIsNone(plugin.authenticate())
|
||||
self.assertEqual(plugin.management_url, 'http://localhost:9292')
|
||||
self.assertEqual('http://localhost:9292', plugin.management_url)
|
||||
|
||||
ambiguous_region_creds = {
|
||||
'username': 'user1',
|
||||
|
@ -775,7 +775,7 @@ class TestImmutableImage(utils.BaseTestCase):
|
|||
|
||||
image = glance.api.authorization.ImmutableImageProxy(
|
||||
FakeImage(), self.context)
|
||||
self.assertEqual(image.get_data(), 'tiddlywinks')
|
||||
self.assertEqual('tiddlywinks', image.get_data())
|
||||
|
||||
|
||||
class TestImageFactoryProxy(utils.BaseTestCase):
|
||||
|
@ -788,7 +788,7 @@ class TestImageFactoryProxy(utils.BaseTestCase):
|
|||
|
||||
def test_default_owner_is_set(self):
|
||||
image = self.image_factory.new_image()
|
||||
self.assertEqual(image.owner, TENANT1)
|
||||
self.assertEqual(TENANT1, image.owner)
|
||||
|
||||
def test_wrong_owner_cannot_be_set(self):
|
||||
self.assertRaises(exception.Forbidden,
|
||||
|
@ -801,7 +801,7 @@ class TestImageFactoryProxy(utils.BaseTestCase):
|
|||
def test_admin_can_set_any_owner(self):
|
||||
self.context.is_admin = True
|
||||
image = self.image_factory.new_image(owner=TENANT2)
|
||||
self.assertEqual(image.owner, TENANT2)
|
||||
self.assertEqual(TENANT2, image.owner)
|
||||
|
||||
def test_admin_can_set_owner_to_none(self):
|
||||
self.context.is_admin = True
|
||||
|
@ -811,7 +811,7 @@ class TestImageFactoryProxy(utils.BaseTestCase):
|
|||
def test_admin_still_gets_default_tenant(self):
|
||||
self.context.is_admin = True
|
||||
image = self.image_factory.new_image()
|
||||
self.assertEqual(image.owner, TENANT1)
|
||||
self.assertEqual(TENANT1, image.owner)
|
||||
|
||||
|
||||
class TestImageRepoProxy(utils.BaseTestCase):
|
||||
|
@ -996,7 +996,7 @@ class TestTaskFactoryProxy(utils.BaseTestCase):
|
|||
owner = self.request1.context.owner
|
||||
task = self.task_factory.new_task(task_type=self.task_type,
|
||||
owner=owner)
|
||||
self.assertEqual(task.owner, TENANT1)
|
||||
self.assertEqual(TENANT1, task.owner)
|
||||
|
||||
def test_task_create_wrong_owner(self):
|
||||
self.assertRaises(exception.Forbidden,
|
||||
|
|
|
@ -48,12 +48,12 @@ class TestCacheMiddlewareURLMatching(testtools.TestCase):
|
|||
def test_v1_match_id_with_query_param(self):
|
||||
req = webob.Request.blank('/v1/images/asdf?ping=pong')
|
||||
out = glance.api.middleware.cache.CacheFilter._match_request(req)
|
||||
self.assertEqual(out, ('v1', 'GET', 'asdf'))
|
||||
self.assertEqual(('v1', 'GET', 'asdf'), out)
|
||||
|
||||
def test_v2_match_id(self):
|
||||
req = webob.Request.blank('/v2/images/asdf/file')
|
||||
out = glance.api.middleware.cache.CacheFilter._match_request(req)
|
||||
self.assertEqual(out, ('v2', 'GET', 'asdf'))
|
||||
self.assertEqual(('v2', 'GET', 'asdf'), out)
|
||||
|
||||
def test_v2_no_match_bad_path(self):
|
||||
req = webob.Request.blank('/v2/images/asdf')
|
||||
|
@ -575,7 +575,7 @@ class TestCacheMiddlewareProcessResponse(base.IsolatedUnitTest):
|
|||
headers = {"x-image-meta-deleted": True}
|
||||
resp = webob.Response(request=request, headers=headers)
|
||||
actual = cache_filter._process_DELETE_response(resp, image_id)
|
||||
self.assertEqual(actual, resp)
|
||||
self.assertEqual(resp, actual)
|
||||
|
||||
def test_get_status_code(self):
|
||||
headers = {"x-image-meta-deleted": True}
|
||||
|
@ -600,7 +600,7 @@ class TestCacheMiddlewareProcessResponse(base.IsolatedUnitTest):
|
|||
headers = {"x-image-meta-deleted": True}
|
||||
resp = webob.Response(request=request, headers=headers)
|
||||
actual = cache_filter.process_response(resp)
|
||||
self.assertEqual(actual, resp)
|
||||
self.assertEqual(resp, actual)
|
||||
|
||||
def test_process_response_without_download_image_policy(self):
|
||||
"""
|
||||
|
|
|
@ -48,7 +48,7 @@ class TestContext(utils.BaseTestCase):
|
|||
img = _fake_image(img_owner, img_public)
|
||||
ctx = context.RequestContext(**kwargs)
|
||||
|
||||
self.assertEqual(self.db_api.is_image_visible(ctx, img), exp_res)
|
||||
self.assertEqual(exp_res, self.db_api.is_image_visible(ctx, img))
|
||||
|
||||
def test_empty_public(self):
|
||||
"""
|
||||
|
|
|
@ -40,10 +40,10 @@ class TestContextMiddleware(base.IsolatedUnitTest):
|
|||
def test_header_parsing(self):
|
||||
req = self._build_request()
|
||||
self._build_middleware().process_request(req)
|
||||
self.assertEqual(req.context.auth_tok, 'token1')
|
||||
self.assertEqual(req.context.user, 'user1')
|
||||
self.assertEqual(req.context.tenant, 'tenant1')
|
||||
self.assertEqual(req.context.roles, ['role1', 'role2'])
|
||||
self.assertEqual('token1', req.context.auth_tok)
|
||||
self.assertEqual('user1', req.context.user)
|
||||
self.assertEqual('tenant1', req.context.tenant)
|
||||
self.assertEqual(['role1', 'role2'], req.context.roles)
|
||||
|
||||
def test_is_admin_flag(self):
|
||||
# is_admin check should look for 'admin' role by default
|
||||
|
@ -95,7 +95,7 @@ class TestContextMiddleware(base.IsolatedUnitTest):
|
|||
self.assertIsNone(req.context.auth_tok)
|
||||
self.assertIsNone(req.context.user)
|
||||
self.assertIsNone(req.context.tenant)
|
||||
self.assertEqual(req.context.roles, [])
|
||||
self.assertEqual([], req.context.roles)
|
||||
self.assertFalse(req.context.is_admin)
|
||||
self.assertTrue(req.context.read_only)
|
||||
|
||||
|
@ -127,7 +127,7 @@ class TestUnauthenticatedContextMiddleware(base.IsolatedUnitTest):
|
|||
self.assertIsNone(req.context.auth_tok)
|
||||
self.assertIsNone(req.context.user)
|
||||
self.assertIsNone(req.context.tenant)
|
||||
self.assertEqual(req.context.roles, [])
|
||||
self.assertEqual([], req.context.roles)
|
||||
self.assertTrue(req.context.is_admin)
|
||||
|
||||
def test_response(self):
|
||||
|
|
|
@ -166,27 +166,27 @@ class TestImageRepo(test_utils.BaseTestCase):
|
|||
|
||||
def test_get(self):
|
||||
image = self.image_repo.get(UUID1)
|
||||
self.assertEqual(image.image_id, UUID1)
|
||||
self.assertEqual(image.name, '1')
|
||||
self.assertEqual(image.tags, set(['ping', 'pong']))
|
||||
self.assertEqual(image.visibility, 'public')
|
||||
self.assertEqual(image.status, 'active')
|
||||
self.assertEqual(image.size, 256)
|
||||
self.assertEqual(image.owner, TENANT1)
|
||||
self.assertEqual(UUID1, image.image_id)
|
||||
self.assertEqual('1', image.name)
|
||||
self.assertEqual(set(['ping', 'pong']), image.tags)
|
||||
self.assertEqual('public', image.visibility)
|
||||
self.assertEqual('active', image.status)
|
||||
self.assertEqual(256, image.size)
|
||||
self.assertEqual(TENANT1, image.owner)
|
||||
|
||||
def test_location_value(self):
|
||||
image = self.image_repo.get(UUID3)
|
||||
self.assertEqual(image.locations[0]['url'], UUID3_LOCATION)
|
||||
self.assertEqual(UUID3_LOCATION, image.locations[0]['url'])
|
||||
|
||||
def test_location_data_value(self):
|
||||
image = self.image_repo.get(UUID1)
|
||||
self.assertEqual(image.locations[0]['url'], UUID1_LOCATION)
|
||||
self.assertEqual(image.locations[0]['metadata'],
|
||||
UUID1_LOCATION_METADATA)
|
||||
self.assertEqual(UUID1_LOCATION, image.locations[0]['url'])
|
||||
self.assertEqual(UUID1_LOCATION_METADATA,
|
||||
image.locations[0]['metadata'])
|
||||
|
||||
def test_location_data_exists(self):
|
||||
image = self.image_repo.get(UUID2)
|
||||
self.assertEqual(image.locations, [])
|
||||
self.assertEqual([], image.locations)
|
||||
|
||||
def test_get_not_found(self):
|
||||
fake_uuid = str(uuid.uuid4())
|
||||
|
@ -226,23 +226,23 @@ class TestImageRepo(test_utils.BaseTestCase):
|
|||
full_ids = [i.image_id for i in full_images]
|
||||
marked_images = self.image_repo.list(marker=full_ids[0])
|
||||
actual_ids = [i.image_id for i in marked_images]
|
||||
self.assertEqual(actual_ids, full_ids[1:])
|
||||
self.assertEqual(full_ids[1:], actual_ids)
|
||||
|
||||
def test_list_with_last_marker(self):
|
||||
images = self.image_repo.list()
|
||||
marked_images = self.image_repo.list(marker=images[-1].image_id)
|
||||
self.assertEqual(len(marked_images), 0)
|
||||
self.assertEqual(0, len(marked_images))
|
||||
|
||||
def test_limited_list(self):
|
||||
limited_images = self.image_repo.list(limit=2)
|
||||
self.assertEqual(len(limited_images), 2)
|
||||
self.assertEqual(2, len(limited_images))
|
||||
|
||||
def test_list_with_marker_and_limit(self):
|
||||
full_images = self.image_repo.list()
|
||||
full_ids = [i.image_id for i in full_images]
|
||||
marked_images = self.image_repo.list(marker=full_ids[0], limit=1)
|
||||
actual_ids = [i.image_id for i in marked_images]
|
||||
self.assertEqual(actual_ids, full_ids[1:2])
|
||||
self.assertEqual(full_ids[1:2], actual_ids)
|
||||
|
||||
def test_list_private_images(self):
|
||||
filters = {'visibility': 'private'}
|
||||
|
@ -323,9 +323,9 @@ class TestImageRepo(test_utils.BaseTestCase):
|
|||
current_update_time = image.updated_at
|
||||
self.assertTrue(current_update_time > original_update_time)
|
||||
image = self.image_repo.get(UUID1)
|
||||
self.assertEqual(image.name, 'foo')
|
||||
self.assertEqual(image.tags, set(['king', 'kong']))
|
||||
self.assertEqual(image.updated_at, current_update_time)
|
||||
self.assertEqual('foo', image.name)
|
||||
self.assertEqual(set(['king', 'kong']), image.tags)
|
||||
self.assertEqual(current_update_time, image.updated_at)
|
||||
|
||||
def test_save_image_not_found(self):
|
||||
fake_uuid = str(uuid.uuid4())
|
||||
|
@ -483,7 +483,7 @@ class TestImageMemberRepo(test_utils.BaseTestCase):
|
|||
self.image_member_repo.save(image_member)
|
||||
image_member_updated = self.image_member_repo.get(TENANT2)
|
||||
self.assertEqual(image_member.id, image_member_updated.id)
|
||||
self.assertEqual(image_member_updated.status, 'accepted')
|
||||
self.assertEqual('accepted', image_member_updated.status)
|
||||
|
||||
def test_add_image_member(self):
|
||||
image = self.image_repo.get(UUID1)
|
||||
|
@ -497,8 +497,7 @@ class TestImageMemberRepo(test_utils.BaseTestCase):
|
|||
image_member.image_id)
|
||||
self.assertEqual(retreived_image_member.member_id,
|
||||
image_member.member_id)
|
||||
self.assertEqual(retreived_image_member.status,
|
||||
'pending')
|
||||
self.assertEqual('pending', retreived_image_member.status)
|
||||
|
||||
def test_add_duplicate_image_member(self):
|
||||
image = self.image_repo.get(UUID1)
|
||||
|
@ -512,8 +511,7 @@ class TestImageMemberRepo(test_utils.BaseTestCase):
|
|||
image_member.image_id)
|
||||
self.assertEqual(retreived_image_member.member_id,
|
||||
image_member.member_id)
|
||||
self.assertEqual(retreived_image_member.status,
|
||||
'pending')
|
||||
self.assertEqual('pending', retreived_image_member.status)
|
||||
|
||||
self.assertRaises(exception.Duplicate, self.image_member_repo.add,
|
||||
image_member)
|
||||
|
@ -530,7 +528,7 @@ class TestImageMemberRepo(test_utils.BaseTestCase):
|
|||
self.assertEqual(member.id, image_member.id)
|
||||
self.assertEqual(member.image_id, image_member.image_id)
|
||||
self.assertEqual(member.member_id, image_member.member_id)
|
||||
self.assertEqual(member.status, 'pending')
|
||||
self.assertEqual('pending', member.status)
|
||||
|
||||
def test_get_nonexistent_image_member(self):
|
||||
fake_image_member_id = 'fake'
|
||||
|
@ -603,11 +601,11 @@ class TestTaskRepo(test_utils.BaseTestCase):
|
|||
def test_get(self):
|
||||
task = self.task_repo.get(UUID1)
|
||||
self.assertEqual(task.task_id, UUID1)
|
||||
self.assertEqual(task.type, 'import')
|
||||
self.assertEqual(task.status, 'pending')
|
||||
self.assertEqual('import', task.type)
|
||||
self.assertEqual('pending', task.status)
|
||||
self.assertEqual(task.task_input, self.fake_task_input)
|
||||
self.assertEqual(task.result, '')
|
||||
self.assertEqual(task.message, '')
|
||||
self.assertEqual('', task.result)
|
||||
self.assertEqual('', task.message)
|
||||
self.assertEqual(task.owner, TENANT1)
|
||||
|
||||
def test_get_not_found(self):
|
||||
|
@ -642,23 +640,23 @@ class TestTaskRepo(test_utils.BaseTestCase):
|
|||
full_ids = [i.task_id for i in full_tasks]
|
||||
marked_tasks = self.task_repo.list(marker=full_ids[0])
|
||||
actual_ids = [i.task_id for i in marked_tasks]
|
||||
self.assertEqual(actual_ids, full_ids[1:])
|
||||
self.assertEqual(full_ids[1:], actual_ids)
|
||||
|
||||
def test_list_with_last_marker(self):
|
||||
tasks = self.task_repo.list()
|
||||
marked_tasks = self.task_repo.list(marker=tasks[-1].task_id)
|
||||
self.assertEqual(len(marked_tasks), 0)
|
||||
self.assertEqual(0, len(marked_tasks))
|
||||
|
||||
def test_limited_list(self):
|
||||
limited_tasks = self.task_repo.list(limit=2)
|
||||
self.assertEqual(len(limited_tasks), 2)
|
||||
self.assertEqual(2, len(limited_tasks))
|
||||
|
||||
def test_list_with_marker_and_limit(self):
|
||||
full_tasks = self.task_repo.list()
|
||||
full_ids = [i.task_id for i in full_tasks]
|
||||
marked_tasks = self.task_repo.list(marker=full_ids[0], limit=1)
|
||||
actual_ids = [i.task_id for i in marked_tasks]
|
||||
self.assertEqual(actual_ids, full_ids[1:2])
|
||||
self.assertEqual(full_ids[1:2], actual_ids)
|
||||
|
||||
def test_sorted_list(self):
|
||||
tasks = self.task_repo.list(sort_key='status', sort_dir='desc')
|
||||
|
|
|
@ -46,38 +46,38 @@ class TestImageFactory(test_utils.BaseTestCase):
|
|||
self.assertIsNotNone(image.image_id)
|
||||
self.assertIsNotNone(image.created_at)
|
||||
self.assertEqual(image.created_at, image.updated_at)
|
||||
self.assertEqual(image.status, 'queued')
|
||||
self.assertEqual(image.visibility, 'private')
|
||||
self.assertEqual('queued', image.status)
|
||||
self.assertEqual('private', image.visibility)
|
||||
self.assertIsNone(image.owner)
|
||||
self.assertIsNone(image.name)
|
||||
self.assertIsNone(image.size)
|
||||
self.assertEqual(image.min_disk, 0)
|
||||
self.assertEqual(image.min_ram, 0)
|
||||
self.assertEqual(0, image.min_disk)
|
||||
self.assertEqual(0, image.min_ram)
|
||||
self.assertFalse(image.protected)
|
||||
self.assertIsNone(image.disk_format)
|
||||
self.assertIsNone(image.container_format)
|
||||
self.assertEqual(image.extra_properties, {})
|
||||
self.assertEqual(image.tags, set([]))
|
||||
self.assertEqual({}, image.extra_properties)
|
||||
self.assertEqual(set([]), image.tags)
|
||||
|
||||
def test_new_image(self):
|
||||
image = self.image_factory.new_image(
|
||||
image_id=UUID1, name='image-1', min_disk=256,
|
||||
owner=TENANT1)
|
||||
self.assertEqual(image.image_id, UUID1)
|
||||
self.assertEqual(UUID1, image.image_id)
|
||||
self.assertIsNotNone(image.created_at)
|
||||
self.assertEqual(image.created_at, image.updated_at)
|
||||
self.assertEqual(image.status, 'queued')
|
||||
self.assertEqual(image.visibility, 'private')
|
||||
self.assertEqual(image.owner, TENANT1)
|
||||
self.assertEqual(image.name, 'image-1')
|
||||
self.assertEqual('queued', image.status)
|
||||
self.assertEqual('private', image.visibility)
|
||||
self.assertEqual(TENANT1, image.owner)
|
||||
self.assertEqual('image-1', image.name)
|
||||
self.assertIsNone(image.size)
|
||||
self.assertEqual(image.min_disk, 256)
|
||||
self.assertEqual(image.min_ram, 0)
|
||||
self.assertEqual(256, image.min_disk)
|
||||
self.assertEqual(0, image.min_ram)
|
||||
self.assertFalse(image.protected)
|
||||
self.assertIsNone(image.disk_format)
|
||||
self.assertIsNone(image.container_format)
|
||||
self.assertEqual(image.extra_properties, {})
|
||||
self.assertEqual(image.tags, set([]))
|
||||
self.assertEqual({}, image.extra_properties)
|
||||
self.assertEqual(set([]), image.tags)
|
||||
|
||||
def test_new_image_with_extra_properties_and_tags(self):
|
||||
extra_properties = {'foo': 'bar'}
|
||||
|
@ -86,21 +86,21 @@ class TestImageFactory(test_utils.BaseTestCase):
|
|||
image_id=UUID1, name='image-1',
|
||||
extra_properties=extra_properties, tags=tags)
|
||||
|
||||
self.assertEqual(image.image_id, UUID1)
|
||||
self.assertEqual(UUID1, image.image_id, UUID1)
|
||||
self.assertIsNotNone(image.created_at)
|
||||
self.assertEqual(image.created_at, image.updated_at)
|
||||
self.assertEqual(image.status, 'queued')
|
||||
self.assertEqual(image.visibility, 'private')
|
||||
self.assertEqual('queued', image.status)
|
||||
self.assertEqual('private', image.visibility)
|
||||
self.assertIsNone(image.owner)
|
||||
self.assertEqual(image.name, 'image-1')
|
||||
self.assertEqual('image-1', image.name)
|
||||
self.assertIsNone(image.size)
|
||||
self.assertEqual(image.min_disk, 0)
|
||||
self.assertEqual(image.min_ram, 0)
|
||||
self.assertEqual(0, image.min_disk)
|
||||
self.assertEqual(0, image.min_ram)
|
||||
self.assertFalse(image.protected)
|
||||
self.assertIsNone(image.disk_format)
|
||||
self.assertIsNone(image.container_format)
|
||||
self.assertEqual(image.extra_properties, {'foo': 'bar'})
|
||||
self.assertEqual(image.tags, set(['one', 'two']))
|
||||
self.assertEqual({'foo': 'bar'}, image.extra_properties)
|
||||
self.assertEqual(set(['one', 'two']), image.tags)
|
||||
|
||||
def test_new_image_read_only_property(self):
|
||||
self.assertRaises(exception.ReadonlyProperty,
|
||||
|
@ -129,17 +129,17 @@ class TestImage(test_utils.BaseTestCase):
|
|||
|
||||
def test_extra_properties(self):
|
||||
self.image.extra_properties = {'foo': 'bar'}
|
||||
self.assertEqual(self.image.extra_properties, {'foo': 'bar'})
|
||||
self.assertEqual({'foo': 'bar'}, self.image.extra_properties)
|
||||
|
||||
def test_extra_properties_assign(self):
|
||||
self.image.extra_properties['foo'] = 'bar'
|
||||
self.assertEqual(self.image.extra_properties, {'foo': 'bar'})
|
||||
self.assertEqual({'foo': 'bar'}, self.image.extra_properties)
|
||||
|
||||
def test_delete_extra_properties(self):
|
||||
self.image.extra_properties = {'foo': 'bar'}
|
||||
self.assertEqual(self.image.extra_properties, {'foo': 'bar'})
|
||||
self.assertEqual({'foo': 'bar'}, self.image.extra_properties)
|
||||
del self.image.extra_properties['foo']
|
||||
self.assertEqual(self.image.extra_properties, {})
|
||||
self.assertEqual({}, self.image.extra_properties)
|
||||
|
||||
def test_visibility_enumerated(self):
|
||||
self.image.visibility = 'public'
|
||||
|
@ -149,7 +149,7 @@ class TestImage(test_utils.BaseTestCase):
|
|||
|
||||
def test_tags_always_a_set(self):
|
||||
self.image.tags = ['a', 'b', 'c']
|
||||
self.assertEqual(self.image.tags, set(['a', 'b', 'c']))
|
||||
self.assertEqual(set(['a', 'b', 'c']), self.image.tags)
|
||||
|
||||
def test_delete_protected_image(self):
|
||||
self.image.protected = True
|
||||
|
@ -157,7 +157,7 @@ class TestImage(test_utils.BaseTestCase):
|
|||
|
||||
def test_status_saving(self):
|
||||
self.image.status = 'saving'
|
||||
self.assertEqual(self.image.status, 'saving')
|
||||
self.assertEqual('saving', self.image.status)
|
||||
|
||||
def test_status_saving_without_disk_format(self):
|
||||
self.image.disk_format = None
|
||||
|
@ -184,9 +184,9 @@ class TestImage(test_utils.BaseTestCase):
|
|||
self.image.status = 'active'
|
||||
self.image.locations = [{'url': 'http://foo.bar/not.exists',
|
||||
'metadata': {}}]
|
||||
self.assertEqual(self.image.status, 'active')
|
||||
self.assertEqual('active', self.image.status)
|
||||
self.image.delete()
|
||||
self.assertEqual(self.image.status, 'pending_delete')
|
||||
self.assertEqual('pending_delete', self.image.status)
|
||||
|
||||
|
||||
class TestImageMember(test_utils.BaseTestCase):
|
||||
|
@ -225,7 +225,7 @@ class TestImageMemberFactory(test_utils.BaseTestCase):
|
|||
self.assertEqual(image_member.image_id, image.image_id)
|
||||
self.assertIsNotNone(image_member.created_at)
|
||||
self.assertEqual(image_member.created_at, image_member.updated_at)
|
||||
self.assertEqual(image_member.status, 'pending')
|
||||
self.assertEqual('pending', image_member.status)
|
||||
self.assertIsNotNone(image_member.member_id)
|
||||
|
||||
|
||||
|
@ -234,8 +234,8 @@ class TestExtraProperties(test_utils.BaseTestCase):
|
|||
def test_getitem(self):
|
||||
a_dict = {'foo': 'bar', 'snitch': 'golden'}
|
||||
extra_properties = domain.ExtraProperties(a_dict)
|
||||
self.assertEqual(extra_properties['foo'], 'bar')
|
||||
self.assertEqual(extra_properties['snitch'], 'golden')
|
||||
self.assertEqual('bar', extra_properties['foo'])
|
||||
self.assertEqual('golden', extra_properties['snitch'])
|
||||
|
||||
def test_getitem_with_no_items(self):
|
||||
extra_properties = domain.ExtraProperties()
|
||||
|
@ -245,30 +245,30 @@ class TestExtraProperties(test_utils.BaseTestCase):
|
|||
a_dict = {'foo': 'bar', 'snitch': 'golden'}
|
||||
extra_properties = domain.ExtraProperties(a_dict)
|
||||
extra_properties['foo'] = 'baz'
|
||||
self.assertEqual(extra_properties['foo'], 'baz')
|
||||
self.assertEqual('baz', extra_properties['foo'])
|
||||
|
||||
def test_delitem(self):
|
||||
a_dict = {'foo': 'bar', 'snitch': 'golden'}
|
||||
extra_properties = domain.ExtraProperties(a_dict)
|
||||
del extra_properties['foo']
|
||||
self.assertRaises(KeyError, extra_properties.__getitem__, 'foo')
|
||||
self.assertEqual(extra_properties['snitch'], 'golden')
|
||||
self.assertEqual('golden', extra_properties['snitch'])
|
||||
|
||||
def test_len_with_zero_items(self):
|
||||
extra_properties = domain.ExtraProperties()
|
||||
self.assertEqual(len(extra_properties), 0)
|
||||
self.assertEqual(0, len(extra_properties))
|
||||
|
||||
def test_len_with_non_zero_items(self):
|
||||
extra_properties = domain.ExtraProperties()
|
||||
extra_properties['foo'] = 'bar'
|
||||
extra_properties['snitch'] = 'golden'
|
||||
self.assertEqual(len(extra_properties), 2)
|
||||
self.assertEqual(2, len(extra_properties))
|
||||
|
||||
def test_eq_with_a_dict(self):
|
||||
a_dict = {'foo': 'bar', 'snitch': 'golden'}
|
||||
extra_properties = domain.ExtraProperties(a_dict)
|
||||
ref_extra_properties = {'foo': 'bar', 'snitch': 'golden'}
|
||||
self.assertEqual(extra_properties, ref_extra_properties)
|
||||
self.assertEqual(ref_extra_properties, extra_properties)
|
||||
|
||||
def test_eq_with_an_object_of_ExtraProperties(self):
|
||||
a_dict = {'foo': 'bar', 'snitch': 'golden'}
|
||||
|
@ -276,7 +276,7 @@ class TestExtraProperties(test_utils.BaseTestCase):
|
|||
ref_extra_properties = domain.ExtraProperties()
|
||||
ref_extra_properties['snitch'] = 'golden'
|
||||
ref_extra_properties['foo'] = 'bar'
|
||||
self.assertEqual(extra_properties, ref_extra_properties)
|
||||
self.assertEqual(ref_extra_properties, extra_properties)
|
||||
|
||||
def test_eq_with_uneqal_dict(self):
|
||||
a_dict = {'foo': 'bar', 'snitch': 'golden'}
|
||||
|
@ -319,7 +319,7 @@ class TestTaskFactory(test_utils.BaseTestCase):
|
|||
self.assertIsNone(task.expires_at)
|
||||
self.assertEqual(owner, task.owner)
|
||||
self.assertEqual(task_input, task.task_input)
|
||||
self.assertEqual(task.message, u'')
|
||||
self.assertEqual(u'', task.message)
|
||||
self.assertIsNone(task.result)
|
||||
|
||||
def test_new_task_invalid_type(self):
|
||||
|
@ -365,17 +365,17 @@ class TestTask(test_utils.BaseTestCase):
|
|||
|
||||
def test_validate_status_transition_from_pending(self):
|
||||
self.task.begin_processing()
|
||||
self.assertEqual(self.task.status, 'processing')
|
||||
self.assertEqual('processing', self.task.status)
|
||||
|
||||
def test_validate_status_transition_from_processing_to_success(self):
|
||||
self.task.begin_processing()
|
||||
self.task.succeed('')
|
||||
self.assertEqual(self.task.status, 'success')
|
||||
self.assertEqual('success', self.task.status)
|
||||
|
||||
def test_validate_status_transition_from_processing_to_failure(self):
|
||||
self.task.begin_processing()
|
||||
self.task.fail('')
|
||||
self.assertEqual(self.task.status, 'failure')
|
||||
self.assertEqual('failure', self.task.status)
|
||||
|
||||
def test_invalid_status_transitions_from_pending(self):
|
||||
# test do not allow transition from pending to success
|
||||
|
@ -417,21 +417,21 @@ class TestTask(test_utils.BaseTestCase):
|
|||
|
||||
def test_begin_processing(self):
|
||||
self.task.begin_processing()
|
||||
self.assertEqual(self.task.status, 'processing')
|
||||
self.assertEqual('processing', self.task.status)
|
||||
|
||||
@mock.patch.object(timeutils, 'utcnow')
|
||||
def test_succeed(self, mock_utcnow):
|
||||
mock_utcnow.return_value = datetime.datetime.utcnow()
|
||||
self.task.begin_processing()
|
||||
self.task.succeed('{"location": "file://home"}')
|
||||
self.assertEqual(self.task.status, 'success')
|
||||
self.assertEqual(self.task.result, '{"location": "file://home"}')
|
||||
self.assertEqual(self.task.message, u'')
|
||||
self.assertEqual('success', self.task.status)
|
||||
self.assertEqual('{"location": "file://home"}', self.task.result)
|
||||
self.assertEqual(u'', self.task.message)
|
||||
expected = (timeutils.utcnow() +
|
||||
datetime.timedelta(hours=CONF.task.task_time_to_live))
|
||||
self.assertEqual(
|
||||
self.task.expires_at,
|
||||
expected
|
||||
expected,
|
||||
self.task.expires_at
|
||||
)
|
||||
|
||||
@mock.patch.object(timeutils, 'utcnow')
|
||||
|
@ -439,14 +439,14 @@ class TestTask(test_utils.BaseTestCase):
|
|||
mock_utcnow.return_value = datetime.datetime.utcnow()
|
||||
self.task.begin_processing()
|
||||
self.task.fail('{"message": "connection failed"}')
|
||||
self.assertEqual(self.task.status, 'failure')
|
||||
self.assertEqual(self.task.message, '{"message": "connection failed"}')
|
||||
self.assertEqual('failure', self.task.status)
|
||||
self.assertEqual('{"message": "connection failed"}', self.task.message)
|
||||
self.assertIsNone(self.task.result)
|
||||
expected = (timeutils.utcnow() +
|
||||
datetime.timedelta(hours=CONF.task.task_time_to_live))
|
||||
self.assertEqual(
|
||||
self.task.expires_at,
|
||||
expected
|
||||
expected,
|
||||
self.task.expires_at
|
||||
)
|
||||
|
||||
@mock.patch.object(glance.async.TaskExecutor, 'begin_processing')
|
||||
|
|
|
@ -94,8 +94,8 @@ class TestProxyRepoWrapping(test_utils.BaseTestCase):
|
|||
proxy_result = method(*args, **kwargs)
|
||||
self.assertIsInstance(proxy_result, FakeProxy)
|
||||
self.assertEqual(proxy_result.base, base_result)
|
||||
self.assertEqual(len(proxy_result.args), 0)
|
||||
self.assertEqual(proxy_result.kwargs, {'a': 1})
|
||||
self.assertEqual(0, len(proxy_result.args))
|
||||
self.assertEqual({'a': 1}, proxy_result.kwargs)
|
||||
self.assertEqual(self.fake_repo.args, args)
|
||||
self.assertEqual(self.fake_repo.kwargs, kwargs)
|
||||
|
||||
|
@ -103,23 +103,23 @@ class TestProxyRepoWrapping(test_utils.BaseTestCase):
|
|||
self.fake_repo.result = 'snarf'
|
||||
result = self.proxy_repo.get('some-id')
|
||||
self.assertIsInstance(result, FakeProxy)
|
||||
self.assertEqual(self.fake_repo.args, ('some-id',))
|
||||
self.assertEqual(self.fake_repo.kwargs, {})
|
||||
self.assertEqual(result.base, 'snarf')
|
||||
self.assertEqual(result.args, tuple())
|
||||
self.assertEqual(result.kwargs, {'a': 1})
|
||||
self.assertEqual(('some-id',), self.fake_repo.args)
|
||||
self.assertEqual({}, self.fake_repo.kwargs)
|
||||
self.assertEqual('snarf', result.base)
|
||||
self.assertEqual(tuple(), result.args)
|
||||
self.assertEqual({'a': 1}, result.kwargs)
|
||||
|
||||
def test_list(self):
|
||||
self.fake_repo.result = ['scratch', 'sniff']
|
||||
results = self.proxy_repo.list(2, prefix='s')
|
||||
self.assertEqual(self.fake_repo.args, (2,))
|
||||
self.assertEqual(self.fake_repo.kwargs, {'prefix': 's'})
|
||||
self.assertEqual(len(results), 2)
|
||||
self.assertEqual((2,), self.fake_repo.args)
|
||||
self.assertEqual({'prefix': 's'}, self.fake_repo.kwargs)
|
||||
self.assertEqual(2, len(results))
|
||||
for i in xrange(2):
|
||||
self.assertIsInstance(results[i], FakeProxy)
|
||||
self.assertEqual(results[i].base, self.fake_repo.result[i])
|
||||
self.assertEqual(results[i].args, tuple())
|
||||
self.assertEqual(results[i].kwargs, {'a': 1})
|
||||
self.assertEqual(self.fake_repo.result[i], results[i].base)
|
||||
self.assertEqual(tuple(), results[i].args)
|
||||
self.assertEqual({'a': 1}, results[i].kwargs)
|
||||
|
||||
def _test_method_with_proxied_argument(self, name, result):
|
||||
self.fake_repo.result = result
|
||||
|
@ -127,16 +127,16 @@ class TestProxyRepoWrapping(test_utils.BaseTestCase):
|
|||
method = getattr(self.proxy_repo, name)
|
||||
proxy_result = method(item)
|
||||
|
||||
self.assertEqual(self.fake_repo.args, ('snoop',))
|
||||
self.assertEqual(self.fake_repo.kwargs, {})
|
||||
self.assertEqual(('snoop',), self.fake_repo.args)
|
||||
self.assertEqual({}, self.fake_repo.kwargs)
|
||||
|
||||
if result is None:
|
||||
self.assertIsNone(proxy_result)
|
||||
else:
|
||||
self.assertIsInstance(proxy_result, FakeProxy)
|
||||
self.assertEqual(proxy_result.base, result)
|
||||
self.assertEqual(proxy_result.args, tuple())
|
||||
self.assertEqual(proxy_result.kwargs, {'a': 1})
|
||||
self.assertEqual(result, proxy_result.base)
|
||||
self.assertEqual(tuple(), proxy_result.args)
|
||||
self.assertEqual({'a': 1}, proxy_result.kwargs)
|
||||
|
||||
def test_add(self):
|
||||
self._test_method_with_proxied_argument('add', 'dog')
|
||||
|
@ -176,8 +176,8 @@ class TestImageFactory(test_utils.BaseTestCase):
|
|||
proxy_factory = proxy.ImageFactory(self.factory)
|
||||
self.factory.result = 'eddard'
|
||||
image = proxy_factory.new_image(a=1, b='two')
|
||||
self.assertEqual(image, 'eddard')
|
||||
self.assertEqual(self.factory.kwargs, {'a': 1, 'b': 'two'})
|
||||
self.assertEqual('eddard', image)
|
||||
self.assertEqual({'a': 1, 'b': 'two'}, self.factory.kwargs)
|
||||
|
||||
def test_proxy_wrapping(self):
|
||||
proxy_factory = proxy.ImageFactory(self.factory,
|
||||
|
@ -186,8 +186,8 @@ class TestImageFactory(test_utils.BaseTestCase):
|
|||
self.factory.result = 'stark'
|
||||
image = proxy_factory.new_image(a=1, b='two')
|
||||
self.assertIsInstance(image, FakeProxy)
|
||||
self.assertEqual(image.base, 'stark')
|
||||
self.assertEqual(self.factory.kwargs, {'a': 1, 'b': 'two'})
|
||||
self.assertEqual('stark', image.base)
|
||||
self.assertEqual({'a': 1, 'b': 'two'}, self.factory.kwargs)
|
||||
|
||||
|
||||
class FakeImageMembershipFactory(object):
|
||||
|
@ -211,9 +211,9 @@ class TestImageMembershipFactory(test_utils.BaseTestCase):
|
|||
proxy_factory = proxy.ImageMembershipFactory(self.factory)
|
||||
self.factory.result = 'tyrion'
|
||||
membership = proxy_factory.new_image_member('jaime', 'cersei')
|
||||
self.assertEqual(membership, 'tyrion')
|
||||
self.assertEqual(self.factory.image, 'jaime')
|
||||
self.assertEqual(self.factory.member_id, 'cersei')
|
||||
self.assertEqual('tyrion', membership)
|
||||
self.assertEqual('jaime', self.factory.image)
|
||||
self.assertEqual('cersei', self.factory.member_id)
|
||||
|
||||
def test_proxy_wrapped_membership(self):
|
||||
proxy_factory = proxy.ImageMembershipFactory(
|
||||
|
@ -222,10 +222,10 @@ class TestImageMembershipFactory(test_utils.BaseTestCase):
|
|||
self.factory.result = 'tyrion'
|
||||
membership = proxy_factory.new_image_member('jaime', 'cersei')
|
||||
self.assertIsInstance(membership, FakeProxy)
|
||||
self.assertEqual(membership.base, 'tyrion')
|
||||
self.assertEqual(membership.kwargs, {'a': 1})
|
||||
self.assertEqual(self.factory.image, 'jaime')
|
||||
self.assertEqual(self.factory.member_id, 'cersei')
|
||||
self.assertEqual('tyrion', membership.base)
|
||||
self.assertEqual({'a': 1}, membership.kwargs)
|
||||
self.assertEqual('jaime', self.factory.image)
|
||||
self.assertEqual('cersei', self.factory.member_id)
|
||||
|
||||
def test_proxy_wrapped_image(self):
|
||||
proxy_factory = proxy.ImageMembershipFactory(
|
||||
|
@ -233,9 +233,9 @@ class TestImageMembershipFactory(test_utils.BaseTestCase):
|
|||
self.factory.result = 'tyrion'
|
||||
image = FakeProxy('jaime')
|
||||
membership = proxy_factory.new_image_member(image, 'cersei')
|
||||
self.assertEqual(membership, 'tyrion')
|
||||
self.assertEqual(self.factory.image, 'jaime')
|
||||
self.assertEqual(self.factory.member_id, 'cersei')
|
||||
self.assertEqual('tyrion', membership)
|
||||
self.assertEqual('jaime', self.factory.image)
|
||||
self.assertEqual('cersei', self.factory.member_id)
|
||||
|
||||
def test_proxy_both_wrapped(self):
|
||||
class FakeProxy2(FakeProxy):
|
||||
|
@ -251,10 +251,10 @@ class TestImageMembershipFactory(test_utils.BaseTestCase):
|
|||
image = FakeProxy2('jaime')
|
||||
membership = proxy_factory.new_image_member(image, 'cersei')
|
||||
self.assertIsInstance(membership, FakeProxy)
|
||||
self.assertEqual(membership.base, 'tyrion')
|
||||
self.assertEqual(membership.kwargs, {'b': 2})
|
||||
self.assertEqual(self.factory.image, 'jaime')
|
||||
self.assertEqual(self.factory.member_id, 'cersei')
|
||||
self.assertEqual('tyrion', membership.base)
|
||||
self.assertEqual({'b': 2}, membership.kwargs)
|
||||
self.assertEqual('jaime', self.factory.image)
|
||||
self.assertEqual('cersei', self.factory.member_id)
|
||||
|
||||
|
||||
class FakeImage(object):
|
||||
|
@ -273,7 +273,7 @@ class TestImage(test_utils.BaseTestCase):
|
|||
def test_normal_member_repo(self):
|
||||
proxy_image = proxy.Image(self.image)
|
||||
self.image.result = 'mormont'
|
||||
self.assertEqual(proxy_image.get_member_repo(), 'mormont')
|
||||
self.assertEqual('mormont', proxy_image.get_member_repo())
|
||||
|
||||
def test_proxied_member_repo(self):
|
||||
proxy_image = proxy.Image(self.image,
|
||||
|
@ -282,7 +282,7 @@ class TestImage(test_utils.BaseTestCase):
|
|||
self.image.result = 'corn'
|
||||
member_repo = proxy_image.get_member_repo()
|
||||
self.assertIsInstance(member_repo, FakeProxy)
|
||||
self.assertEqual(member_repo.base, 'corn')
|
||||
self.assertEqual('corn', member_repo.base)
|
||||
|
||||
|
||||
class TestTaskFactory(test_utils.BaseTestCase):
|
||||
|
@ -323,4 +323,4 @@ class TestTaskFactory(test_utils.BaseTestCase):
|
|||
owner=self.fake_owner
|
||||
)
|
||||
self.assertIsInstance(task, FakeProxy)
|
||||
self.assertEqual(task.base, 'fake_task')
|
||||
self.assertEqual('fake_task', task.base)
|
||||
|
|
|
@ -152,8 +152,8 @@ class ImageServiceTestCase(test_utils.BaseTestCase):
|
|||
200, jsonutils.dumps({'images': []}), {})
|
||||
|
||||
imgs = list(c.get_images())
|
||||
self.assertEqual(len(imgs), 2)
|
||||
self.assertEqual(c.conn.count, 2)
|
||||
self.assertEqual(2, len(imgs))
|
||||
self.assertEqual(2, c.conn.count)
|
||||
|
||||
def test_rest_get_image(self):
|
||||
c = glance_replicator.ImageService(FakeHTTPConnection(), 'noauth')
|
||||
|
@ -165,7 +165,7 @@ class ImageServiceTestCase(test_utils.BaseTestCase):
|
|||
200, image_contents, IMG_RESPONSE_ACTIVE)
|
||||
|
||||
body = c.get_image(IMG_RESPONSE_ACTIVE['id'])
|
||||
self.assertEqual(body.read(), image_contents)
|
||||
self.assertEqual(image_contents, body.read())
|
||||
|
||||
def test_rest_header_list_to_dict(self):
|
||||
i = [('x-image-meta-banana', 42),
|
||||
|
@ -223,8 +223,8 @@ class ImageServiceTestCase(test_utils.BaseTestCase):
|
|||
200, '', IMG_RESPONSE_ACTIVE)
|
||||
|
||||
headers, body = c.add_image(IMG_RESPONSE_ACTIVE, image_body)
|
||||
self.assertEqual(headers, IMG_RESPONSE_ACTIVE)
|
||||
self.assertEqual(c.conn.count, 1)
|
||||
self.assertEqual(IMG_RESPONSE_ACTIVE, headers)
|
||||
self.assertEqual(1, c.conn.count)
|
||||
|
||||
def test_rest_add_image_meta(self):
|
||||
c = glance_replicator.ImageService(FakeHTTPConnection(), 'noauth')
|
||||
|
@ -351,7 +351,7 @@ class ReplicationCommandsTestCase(test_utils.BaseTestCase):
|
|||
glance_replicator.get_image_service = orig_img_service
|
||||
|
||||
output = output.rstrip()
|
||||
self.assertEqual(output, 'Total size is 400 bytes across 2 images')
|
||||
self.assertEqual('Total size is 400 bytes across 2 images', output)
|
||||
|
||||
def test_replication_size_with_no_args(self):
|
||||
args = []
|
||||
|
@ -496,7 +496,7 @@ class ReplicationCommandsTestCase(test_utils.BaseTestCase):
|
|||
finally:
|
||||
glance_replicator.get_image_service = orig_img_service
|
||||
|
||||
self.assertEqual(len(updated), 2)
|
||||
self.assertEqual(2, len(updated))
|
||||
|
||||
def test_replication_livecopy_with_no_args(self):
|
||||
args = []
|
||||
|
|
|
@ -37,21 +37,21 @@ class CacheClientTestCase(utils.BaseTestCase):
|
|||
expected_data = '{"cached_images": "some_images"}'
|
||||
self.client.do_request.return_value = utils.FakeHTTPResponse(
|
||||
data=expected_data)
|
||||
self.assertEqual(self.client.get_cached_images(), "some_images")
|
||||
self.assertEqual("some_images", self.client.get_cached_images())
|
||||
self.client.do_request.assert_called_with("GET", "/cached_images")
|
||||
|
||||
def test_get_queued_images(self):
|
||||
expected_data = '{"queued_images": "some_images"}'
|
||||
self.client.do_request.return_value = utils.FakeHTTPResponse(
|
||||
data=expected_data)
|
||||
self.assertEqual(self.client.get_queued_images(), "some_images")
|
||||
self.assertEqual("some_images", self.client.get_queued_images())
|
||||
self.client.do_request.assert_called_with("GET", "/queued_images")
|
||||
|
||||
def test_delete_all_cached_images(self):
|
||||
expected_data = '{"num_deleted": 4}'
|
||||
self.client.do_request.return_value = utils.FakeHTTPResponse(
|
||||
data=expected_data)
|
||||
self.assertEqual(self.client.delete_all_cached_images(), 4)
|
||||
self.assertEqual(4, self.client.delete_all_cached_images())
|
||||
self.client.do_request.assert_called_with("DELETE", "/cached_images")
|
||||
|
||||
def test_queue_image_for_caching(self):
|
||||
|
@ -70,7 +70,7 @@ class CacheClientTestCase(utils.BaseTestCase):
|
|||
expected_data = '{"num_deleted": 4}'
|
||||
self.client.do_request.return_value = utils.FakeHTTPResponse(
|
||||
data=expected_data)
|
||||
self.assertEqual(self.client.delete_all_queued_images(), 4)
|
||||
self.assertEqual(4, self.client.delete_all_queued_images())
|
||||
self.client.do_request.assert_called_with("DELETE", "/queued_images")
|
||||
|
||||
|
||||
|
@ -88,7 +88,7 @@ class GetClientTestCase(utils.BaseTestCase):
|
|||
'strategy': 'noauth',
|
||||
'region': None
|
||||
}
|
||||
self.assertEqual(client.get_client(self.host).creds, expected_creds)
|
||||
self.assertEqual(expected_creds, client.get_client(self.host).creds)
|
||||
|
||||
def test_get_client_all_creds(self):
|
||||
expected_creds = {
|
||||
|
@ -108,7 +108,7 @@ class GetClientTestCase(utils.BaseTestCase):
|
|||
auth_strategy='strategy',
|
||||
region='reg'
|
||||
).creds
|
||||
self.assertEqual(creds, expected_creds)
|
||||
self.assertEqual(expected_creds, creds)
|
||||
|
||||
def test_get_client_client_configuration_error(self):
|
||||
self.assertRaises(exception.ClientConfigurationError,
|
||||
|
|
|
@ -166,7 +166,7 @@ class MigrationsMixin(test_migrations.WalkVersionsMixin):
|
|||
"""Assure that checksum data is present on table"""
|
||||
images = db_utils.get_table(engine, 'images')
|
||||
self.assertIn('checksum', images.c)
|
||||
self.assertEqual(images.c['checksum'].type.length, 32)
|
||||
self.assertEqual(32, images.c['checksum'].type.length)
|
||||
|
||||
def _pre_upgrade_005(self, engine):
|
||||
now = timeutils.utcnow()
|
||||
|
@ -267,7 +267,7 @@ class MigrationsMixin(test_migrations.WalkVersionsMixin):
|
|||
self.assertEqual(row['updated_at'], updated_at)
|
||||
|
||||
# No initial values should be remaining
|
||||
self.assertEqual(len(values), 0)
|
||||
self.assertEqual(0, len(values))
|
||||
|
||||
def _pre_upgrade_012(self, engine):
|
||||
"""Test rows in images have id changes from int to varchar(32) and
|
||||
|
@ -323,7 +323,7 @@ class MigrationsMixin(test_migrations.WalkVersionsMixin):
|
|||
rows = images.select().where(
|
||||
images.c.name == image_name).execute().fetchall()
|
||||
|
||||
self.assertEqual(len(rows), 1)
|
||||
self.assertEqual(1, len(rows))
|
||||
|
||||
row = rows[0]
|
||||
self.assertTrue(utils.is_uuid_like(row['id']))
|
||||
|
@ -333,7 +333,7 @@ class MigrationsMixin(test_migrations.WalkVersionsMixin):
|
|||
# Find all image_members to ensure image_id has been updated
|
||||
results = image_members.select().where(
|
||||
image_members.c.image_id == uuids['normal']).execute().fetchall()
|
||||
self.assertEqual(len(results), 1)
|
||||
self.assertEqual(1, len(results))
|
||||
|
||||
# Find all image_properties to ensure image_id has been updated
|
||||
# as well as ensure kernel_id and ramdisk_id values have been
|
||||
|
@ -341,7 +341,7 @@ class MigrationsMixin(test_migrations.WalkVersionsMixin):
|
|||
results = image_properties.select().where(
|
||||
image_properties.c.image_id == uuids['normal']
|
||||
).execute().fetchall()
|
||||
self.assertEqual(len(results), 2)
|
||||
self.assertEqual(2, len(results))
|
||||
for row in results:
|
||||
self.assertIn(row['name'], ('kernel_id', 'ramdisk_id'))
|
||||
|
||||
|
@ -362,7 +362,7 @@ class MigrationsMixin(test_migrations.WalkVersionsMixin):
|
|||
image_name = '%s migration 012 test' % name
|
||||
rows = images.select().where(
|
||||
images.c.name == image_name).execute().fetchall()
|
||||
self.assertEqual(len(rows), 1)
|
||||
self.assertEqual(1, len(rows))
|
||||
|
||||
row = rows[0]
|
||||
self.assertFalse(utils.is_uuid_like(row['id']))
|
||||
|
@ -372,14 +372,14 @@ class MigrationsMixin(test_migrations.WalkVersionsMixin):
|
|||
# Find all image_members to ensure image_id has been updated
|
||||
results = image_members.select().where(
|
||||
image_members.c.image_id == ids['normal']).execute().fetchall()
|
||||
self.assertEqual(len(results), 1)
|
||||
self.assertEqual(1, len(results))
|
||||
|
||||
# Find all image_properties to ensure image_id has been updated
|
||||
# as well as ensure kernel_id and ramdisk_id values have been
|
||||
# updated too
|
||||
results = image_properties.select().where(
|
||||
image_properties.c.image_id == ids['normal']).execute().fetchall()
|
||||
self.assertEqual(len(results), 2)
|
||||
self.assertEqual(2, len(results))
|
||||
for row in results:
|
||||
self.assertIn(row['name'], ('kernel_id', 'ramdisk_id'))
|
||||
|
||||
|
@ -627,8 +627,8 @@ class MigrationsMixin(test_migrations.WalkVersionsMixin):
|
|||
image_locations = db_utils.get_table(engine, 'image_locations')
|
||||
records = image_locations.select().execute().fetchall()
|
||||
locations = dict([(il.image_id, il.value) for il in records])
|
||||
self.assertEqual(locations.get('fake-19-1'),
|
||||
'http://glance.example.com')
|
||||
self.assertEqual('http://glance.example.com',
|
||||
locations.get('fake-19-1'))
|
||||
|
||||
def _check_020(self, engine, data):
|
||||
images = db_utils.get_table(engine, 'images')
|
||||
|
@ -666,11 +666,11 @@ class MigrationsMixin(test_migrations.WalkVersionsMixin):
|
|||
image_locations.c.image_id == data).execute()
|
||||
|
||||
r = list(results)
|
||||
self.assertEqual(len(r), 1)
|
||||
self.assertEqual(r[0]['value'], 'file:///some/place/onthe/fs')
|
||||
self.assertEqual(1, len(r))
|
||||
self.assertEqual('file:///some/place/onthe/fs', r[0]['value'])
|
||||
self.assertIn('meta_data', r[0])
|
||||
x = pickle.loads(r[0]['meta_data'])
|
||||
self.assertEqual(x, {})
|
||||
self.assertEqual({}, x)
|
||||
|
||||
def _check_027(self, engine, data):
|
||||
table = "images"
|
||||
|
@ -896,7 +896,7 @@ class MigrationsMixin(test_migrations.WalkVersionsMixin):
|
|||
|
||||
task_info_refs = task_info_table.select().execute().fetchall()
|
||||
|
||||
self.assertEqual(len(task_info_refs), 2)
|
||||
self.assertEqual(2, len(task_info_refs))
|
||||
|
||||
for x in range(len(task_info_refs)):
|
||||
self.assertEqual(task_info_refs[x].task_id, data[x]['id'])
|
||||
|
@ -915,13 +915,13 @@ class MigrationsMixin(test_migrations.WalkVersionsMixin):
|
|||
|
||||
tasks_table = db_utils.get_table(engine, 'tasks')
|
||||
records = tasks_table.select().execute().fetchall()
|
||||
self.assertEqual(len(records), 2)
|
||||
self.assertEqual(2, len(records))
|
||||
|
||||
tasks = dict([(t.id, t) for t in records])
|
||||
|
||||
task_1 = tasks.get('task-1')
|
||||
self.assertEqual(task_1.input, 'some input')
|
||||
self.assertEqual(task_1.result, 'successful')
|
||||
self.assertEqual('some input', task_1.input)
|
||||
self.assertEqual('successful', task_1.result)
|
||||
self.assertIsNone(task_1.message)
|
||||
|
||||
task_2 = tasks.get('task-2')
|
||||
|
@ -965,7 +965,7 @@ class MigrationsMixin(test_migrations.WalkVersionsMixin):
|
|||
image_locations = db_utils.get_table(engine, 'image_locations')
|
||||
|
||||
self.assertIn('status', image_locations.c)
|
||||
self.assertEqual(image_locations.c['status'].type.length, 30)
|
||||
self.assertEqual(30, image_locations.c['status'].type.length)
|
||||
|
||||
status_list = ['active', 'active', 'active',
|
||||
'deleted', 'pending_delete', 'deleted']
|
||||
|
@ -974,7 +974,7 @@ class MigrationsMixin(test_migrations.WalkVersionsMixin):
|
|||
results = image_locations.select().where(
|
||||
image_locations.c.image_id == image_id).execute()
|
||||
r = list(results)
|
||||
self.assertEqual(len(r), 1)
|
||||
self.assertEqual(1, len(r))
|
||||
self.assertIn('status', r[0])
|
||||
self.assertEqual(r[0]['status'], status_list[idx])
|
||||
|
||||
|
|
|
@ -63,8 +63,8 @@ class UtilsTestCase(test_utils.BaseTestCase):
|
|||
self.assertNotIn('x-image-meta-snafu', headers)
|
||||
self.assertNotIn('x-image-meta-property-arch', headers)
|
||||
|
||||
self.assertEqual(headers.get('x-image-meta-foo'), 'bar')
|
||||
self.assertEqual(headers.get('x-image-meta-bells'), 'whistles')
|
||||
self.assertEqual(headers.get('x-image-meta-empty'), '')
|
||||
self.assertEqual(headers.get('x-image-meta-property-distro'), '')
|
||||
self.assertEqual(headers.get('x-image-meta-property-user'), 'nobody')
|
||||
self.assertEqual('bar', headers.get('x-image-meta-foo'))
|
||||
self.assertEqual('whistles', headers.get('x-image-meta-bells'))
|
||||
self.assertEqual('', headers.get('x-image-meta-empty'))
|
||||
self.assertEqual('', headers.get('x-image-meta-property-distro'))
|
||||
self.assertEqual('nobody', headers.get('x-image-meta-property-user'))
|
||||
|
|
|
@ -139,33 +139,33 @@ class TestImageNotifications(utils.BaseTestCase):
|
|||
def test_image_save_notification(self):
|
||||
self.image_repo_proxy.save(self.image_proxy)
|
||||
output_logs = self.notifier.get_logs()
|
||||
self.assertEqual(len(output_logs), 1)
|
||||
self.assertEqual(1, len(output_logs))
|
||||
output_log = output_logs[0]
|
||||
self.assertEqual(output_log['notification_type'], 'INFO')
|
||||
self.assertEqual(output_log['event_type'], 'image.update')
|
||||
self.assertEqual(output_log['payload']['id'], self.image.image_id)
|
||||
self.assertEqual('INFO', output_log['notification_type'])
|
||||
self.assertEqual('image.update', output_log['event_type'])
|
||||
self.assertEqual(self.image.image_id, output_log['payload']['id'])
|
||||
if 'location' in output_log['payload']:
|
||||
self.fail('Notification contained location field.')
|
||||
|
||||
def test_image_add_notification(self):
|
||||
self.image_repo_proxy.add(self.image_proxy)
|
||||
output_logs = self.notifier.get_logs()
|
||||
self.assertEqual(len(output_logs), 1)
|
||||
self.assertEqual(1, len(output_logs))
|
||||
output_log = output_logs[0]
|
||||
self.assertEqual(output_log['notification_type'], 'INFO')
|
||||
self.assertEqual(output_log['event_type'], 'image.create')
|
||||
self.assertEqual(output_log['payload']['id'], self.image.image_id)
|
||||
self.assertEqual('INFO', output_log['notification_type'])
|
||||
self.assertEqual('image.create', output_log['event_type'])
|
||||
self.assertEqual(self.image.image_id, output_log['payload']['id'])
|
||||
if 'location' in output_log['payload']:
|
||||
self.fail('Notification contained location field.')
|
||||
|
||||
def test_image_delete_notification(self):
|
||||
self.image_repo_proxy.remove(self.image_proxy)
|
||||
output_logs = self.notifier.get_logs()
|
||||
self.assertEqual(len(output_logs), 1)
|
||||
self.assertEqual(1, len(output_logs))
|
||||
output_log = output_logs[0]
|
||||
self.assertEqual(output_log['notification_type'], 'INFO')
|
||||
self.assertEqual(output_log['event_type'], 'image.delete')
|
||||
self.assertEqual(output_log['payload']['id'], self.image.image_id)
|
||||
self.assertEqual('INFO', output_log['notification_type'])
|
||||
self.assertEqual('image.delete', output_log['event_type'])
|
||||
self.assertEqual(self.image.image_id, output_log['payload']['id'])
|
||||
self.assertTrue(output_log['payload']['deleted'])
|
||||
if 'location' in output_log['payload']:
|
||||
self.fail('Notification contained location field.')
|
||||
|
@ -173,12 +173,12 @@ class TestImageNotifications(utils.BaseTestCase):
|
|||
def test_image_get(self):
|
||||
image = self.image_repo_proxy.get(UUID1)
|
||||
self.assertIsInstance(image, glance.notifier.ImageProxy)
|
||||
self.assertEqual(image.image, 'image_from_get')
|
||||
self.assertEqual('image_from_get', image.image)
|
||||
|
||||
def test_image_list(self):
|
||||
images = self.image_repo_proxy.list()
|
||||
self.assertIsInstance(images[0], glance.notifier.ImageProxy)
|
||||
self.assertEqual(images[0].image, 'images_from_list')
|
||||
self.assertEqual('images_from_list', images[0].image)
|
||||
|
||||
def test_image_get_data_should_call_next_image_get_data(self):
|
||||
with mock.patch.object(self.image, 'get_data') as get_data_mock:
|
||||
|
@ -189,40 +189,40 @@ class TestImageNotifications(utils.BaseTestCase):
|
|||
def test_image_get_data_notification(self):
|
||||
self.image_proxy.size = 10
|
||||
data = ''.join(self.image_proxy.get_data())
|
||||
self.assertEqual(data, '0123456789')
|
||||
self.assertEqual('0123456789', data)
|
||||
output_logs = self.notifier.get_logs()
|
||||
self.assertEqual(len(output_logs), 1)
|
||||
self.assertEqual(1, len(output_logs))
|
||||
output_log = output_logs[0]
|
||||
self.assertEqual(output_log['notification_type'], 'INFO')
|
||||
self.assertEqual(output_log['event_type'], 'image.send')
|
||||
self.assertEqual(output_log['payload']['image_id'],
|
||||
self.image.image_id)
|
||||
self.assertEqual(output_log['payload']['receiver_tenant_id'], TENANT2)
|
||||
self.assertEqual(output_log['payload']['receiver_user_id'], USER1)
|
||||
self.assertEqual(output_log['payload']['bytes_sent'], 10)
|
||||
self.assertEqual(output_log['payload']['owner_id'], TENANT1)
|
||||
self.assertEqual('INFO', output_log['notification_type'])
|
||||
self.assertEqual('image.send', output_log['event_type'])
|
||||
self.assertEqual(self.image.image_id,
|
||||
output_log['payload']['image_id'])
|
||||
self.assertEqual(TENANT2, output_log['payload']['receiver_tenant_id'])
|
||||
self.assertEqual(USER1, output_log['payload']['receiver_user_id'])
|
||||
self.assertEqual(10, output_log['payload']['bytes_sent'])
|
||||
self.assertEqual(TENANT1, output_log['payload']['owner_id'])
|
||||
|
||||
def test_image_get_data_size_mismatch(self):
|
||||
self.image_proxy.size = 11
|
||||
list(self.image_proxy.get_data())
|
||||
output_logs = self.notifier.get_logs()
|
||||
self.assertEqual(len(output_logs), 1)
|
||||
self.assertEqual(1, len(output_logs))
|
||||
output_log = output_logs[0]
|
||||
self.assertEqual(output_log['notification_type'], 'ERROR')
|
||||
self.assertEqual(output_log['event_type'], 'image.send')
|
||||
self.assertEqual(output_log['payload']['image_id'],
|
||||
self.image.image_id)
|
||||
self.assertEqual('ERROR', output_log['notification_type'])
|
||||
self.assertEqual('image.send', output_log['event_type'])
|
||||
self.assertEqual(self.image.image_id,
|
||||
output_log['payload']['image_id'])
|
||||
|
||||
def test_image_set_data_prepare_notification(self):
|
||||
insurance = {'called': False}
|
||||
|
||||
def data_iterator():
|
||||
output_logs = self.notifier.get_logs()
|
||||
self.assertEqual(len(output_logs), 1)
|
||||
self.assertEqual(1, len(output_logs))
|
||||
output_log = output_logs[0]
|
||||
self.assertEqual(output_log['notification_type'], 'INFO')
|
||||
self.assertEqual(output_log['event_type'], 'image.prepare')
|
||||
self.assertEqual(output_log['payload']['id'], self.image.image_id)
|
||||
self.assertEqual('INFO', output_log['notification_type'])
|
||||
self.assertEqual('image.prepare', output_log['event_type'])
|
||||
self.assertEqual(self.image.image_id, output_log['payload']['id'])
|
||||
yield 'abcd'
|
||||
yield 'efgh'
|
||||
insurance['called'] = True
|
||||
|
@ -239,17 +239,17 @@ class TestImageNotifications(utils.BaseTestCase):
|
|||
self.image_proxy.set_data(data_iterator(), 10)
|
||||
|
||||
output_logs = self.notifier.get_logs()
|
||||
self.assertEqual(len(output_logs), 2)
|
||||
self.assertEqual(2, len(output_logs))
|
||||
|
||||
output_log = output_logs[0]
|
||||
self.assertEqual(output_log['notification_type'], 'INFO')
|
||||
self.assertEqual(output_log['event_type'], 'image.upload')
|
||||
self.assertEqual(output_log['payload']['id'], self.image.image_id)
|
||||
self.assertEqual('INFO', output_log['notification_type'])
|
||||
self.assertEqual('image.upload', output_log['event_type'])
|
||||
self.assertEqual(self.image.image_id, output_log['payload']['id'])
|
||||
|
||||
output_log = output_logs[1]
|
||||
self.assertEqual(output_log['notification_type'], 'INFO')
|
||||
self.assertEqual(output_log['event_type'], 'image.activate')
|
||||
self.assertEqual(output_log['payload']['id'], self.image.image_id)
|
||||
self.assertEqual('INFO', output_log['notification_type'])
|
||||
self.assertEqual('image.activate', output_log['event_type'])
|
||||
self.assertEqual(self.image.image_id, output_log['payload']['id'])
|
||||
|
||||
def test_image_set_data_storage_full(self):
|
||||
def data_iterator():
|
||||
|
@ -260,11 +260,11 @@ class TestImageNotifications(utils.BaseTestCase):
|
|||
self.assertRaises(webob.exc.HTTPRequestEntityTooLarge,
|
||||
self.image_proxy.set_data, data_iterator(), 10)
|
||||
output_logs = self.notifier.get_logs()
|
||||
self.assertEqual(len(output_logs), 1)
|
||||
self.assertEqual(1, len(output_logs))
|
||||
|
||||
output_log = output_logs[0]
|
||||
self.assertEqual(output_log['notification_type'], 'ERROR')
|
||||
self.assertEqual(output_log['event_type'], 'image.upload')
|
||||
self.assertEqual('ERROR', output_log['notification_type'])
|
||||
self.assertEqual('image.upload', output_log['event_type'])
|
||||
self.assertIn('Modern Major General', output_log['payload'])
|
||||
|
||||
def test_image_set_data_value_error(self):
|
||||
|
@ -277,11 +277,11 @@ class TestImageNotifications(utils.BaseTestCase):
|
|||
self.image_proxy.set_data, data_iterator(), 10)
|
||||
|
||||
output_logs = self.notifier.get_logs()
|
||||
self.assertEqual(len(output_logs), 1)
|
||||
self.assertEqual(1, len(output_logs))
|
||||
|
||||
output_log = output_logs[0]
|
||||
self.assertEqual(output_log['notification_type'], 'ERROR')
|
||||
self.assertEqual(output_log['event_type'], 'image.upload')
|
||||
self.assertEqual('ERROR', output_log['notification_type'])
|
||||
self.assertEqual('image.upload', output_log['event_type'])
|
||||
self.assertIn('value wrong', output_log['payload'])
|
||||
|
||||
def test_image_set_data_duplicate(self):
|
||||
|
@ -294,11 +294,11 @@ class TestImageNotifications(utils.BaseTestCase):
|
|||
self.image_proxy.set_data, data_iterator(), 10)
|
||||
|
||||
output_logs = self.notifier.get_logs()
|
||||
self.assertEqual(len(output_logs), 1)
|
||||
self.assertEqual(1, len(output_logs))
|
||||
|
||||
output_log = output_logs[0]
|
||||
self.assertEqual(output_log['notification_type'], 'ERROR')
|
||||
self.assertEqual(output_log['event_type'], 'image.upload')
|
||||
self.assertEqual('ERROR', output_log['notification_type'])
|
||||
self.assertEqual('image.upload', output_log['event_type'])
|
||||
self.assertIn('Cant have duplicates', output_log['payload'])
|
||||
|
||||
def test_image_set_data_storage_write_denied(self):
|
||||
|
@ -311,11 +311,11 @@ class TestImageNotifications(utils.BaseTestCase):
|
|||
self.image_proxy.set_data, data_iterator(), 10)
|
||||
|
||||
output_logs = self.notifier.get_logs()
|
||||
self.assertEqual(len(output_logs), 1)
|
||||
self.assertEqual(1, len(output_logs))
|
||||
|
||||
output_log = output_logs[0]
|
||||
self.assertEqual(output_log['notification_type'], 'ERROR')
|
||||
self.assertEqual(output_log['event_type'], 'image.upload')
|
||||
self.assertEqual('ERROR', output_log['notification_type'])
|
||||
self.assertEqual('image.upload', output_log['event_type'])
|
||||
self.assertIn('The Very Model', output_log['payload'])
|
||||
|
||||
def test_image_set_data_forbidden(self):
|
||||
|
@ -328,11 +328,11 @@ class TestImageNotifications(utils.BaseTestCase):
|
|||
self.image_proxy.set_data, data_iterator(), 10)
|
||||
|
||||
output_logs = self.notifier.get_logs()
|
||||
self.assertEqual(len(output_logs), 1)
|
||||
self.assertEqual(1, len(output_logs))
|
||||
|
||||
output_log = output_logs[0]
|
||||
self.assertEqual(output_log['notification_type'], 'ERROR')
|
||||
self.assertEqual(output_log['event_type'], 'image.upload')
|
||||
self.assertEqual('ERROR', output_log['notification_type'])
|
||||
self.assertEqual('image.upload', output_log['event_type'])
|
||||
self.assertIn('Not allowed', output_log['payload'])
|
||||
|
||||
def test_image_set_data_not_found(self):
|
||||
|
@ -345,11 +345,11 @@ class TestImageNotifications(utils.BaseTestCase):
|
|||
self.image_proxy.set_data, data_iterator(), 10)
|
||||
|
||||
output_logs = self.notifier.get_logs()
|
||||
self.assertEqual(len(output_logs), 1)
|
||||
self.assertEqual(1, len(output_logs))
|
||||
|
||||
output_log = output_logs[0]
|
||||
self.assertEqual(output_log['notification_type'], 'ERROR')
|
||||
self.assertEqual(output_log['event_type'], 'image.upload')
|
||||
self.assertEqual('ERROR', output_log['notification_type'])
|
||||
self.assertEqual('image.upload', output_log['event_type'])
|
||||
self.assertIn('Not found', output_log['payload'])
|
||||
|
||||
def test_image_set_data_HTTP_error(self):
|
||||
|
@ -362,11 +362,11 @@ class TestImageNotifications(utils.BaseTestCase):
|
|||
self.image_proxy.set_data, data_iterator(), 10)
|
||||
|
||||
output_logs = self.notifier.get_logs()
|
||||
self.assertEqual(len(output_logs), 1)
|
||||
self.assertEqual(1, len(output_logs))
|
||||
|
||||
output_log = output_logs[0]
|
||||
self.assertEqual(output_log['notification_type'], 'ERROR')
|
||||
self.assertEqual(output_log['event_type'], 'image.upload')
|
||||
self.assertEqual('ERROR', output_log['notification_type'])
|
||||
self.assertEqual('image.upload', output_log['event_type'])
|
||||
self.assertIn('Http issue', output_log['payload'])
|
||||
|
||||
def test_image_set_data_error(self):
|
||||
|
@ -379,11 +379,11 @@ class TestImageNotifications(utils.BaseTestCase):
|
|||
self.image_proxy.set_data, data_iterator(), 10)
|
||||
|
||||
output_logs = self.notifier.get_logs()
|
||||
self.assertEqual(len(output_logs), 1)
|
||||
self.assertEqual(1, len(output_logs))
|
||||
|
||||
output_log = output_logs[0]
|
||||
self.assertEqual(output_log['notification_type'], 'ERROR')
|
||||
self.assertEqual(output_log['event_type'], 'image.upload')
|
||||
self.assertEqual('ERROR', output_log['notification_type'])
|
||||
self.assertEqual('image.upload', output_log['event_type'])
|
||||
self.assertIn('Failed', output_log['payload'])
|
||||
|
||||
|
||||
|
@ -447,18 +447,18 @@ class TestTaskNotifications(utils.BaseTestCase):
|
|||
def test_task_create_notification(self):
|
||||
self.task_repo_proxy.add(self.task_stub_proxy)
|
||||
output_logs = self.notifier.get_logs()
|
||||
self.assertEqual(len(output_logs), 1)
|
||||
self.assertEqual(1, len(output_logs))
|
||||
output_log = output_logs[0]
|
||||
self.assertEqual(output_log['notification_type'], 'INFO')
|
||||
self.assertEqual(output_log['event_type'], 'task.create')
|
||||
self.assertEqual(output_log['payload']['id'], self.task.task_id)
|
||||
self.assertEqual('INFO', output_log['notification_type'])
|
||||
self.assertEqual('task.create', output_log['event_type'])
|
||||
self.assertEqual(self.task.task_id, output_log['payload']['id'])
|
||||
self.assertEqual(
|
||||
output_log['payload']['updated_at'],
|
||||
timeutils.isotime(self.task.updated_at)
|
||||
timeutils.isotime(self.task.updated_at),
|
||||
output_log['payload']['updated_at']
|
||||
)
|
||||
self.assertEqual(
|
||||
output_log['payload']['created_at'],
|
||||
timeutils.isotime(self.task.created_at)
|
||||
timeutils.isotime(self.task.created_at),
|
||||
output_log['payload']['created_at']
|
||||
)
|
||||
if 'location' in output_log['payload']:
|
||||
self.fail('Notification contained location field.')
|
||||
|
@ -467,22 +467,22 @@ class TestTaskNotifications(utils.BaseTestCase):
|
|||
now = timeutils.isotime()
|
||||
self.task_repo_proxy.remove(self.task_stub_proxy)
|
||||
output_logs = self.notifier.get_logs()
|
||||
self.assertEqual(len(output_logs), 1)
|
||||
self.assertEqual(1, len(output_logs))
|
||||
output_log = output_logs[0]
|
||||
self.assertEqual(output_log['notification_type'], 'INFO')
|
||||
self.assertEqual(output_log['event_type'], 'task.delete')
|
||||
self.assertEqual(output_log['payload']['id'], self.task.task_id)
|
||||
self.assertEqual('INFO', output_log['notification_type'])
|
||||
self.assertEqual('task.delete', output_log['event_type'])
|
||||
self.assertEqual(self.task.task_id, output_log['payload']['id'])
|
||||
self.assertEqual(
|
||||
output_log['payload']['updated_at'],
|
||||
timeutils.isotime(self.task.updated_at)
|
||||
timeutils.isotime(self.task.updated_at),
|
||||
output_log['payload']['updated_at']
|
||||
)
|
||||
self.assertEqual(
|
||||
output_log['payload']['created_at'],
|
||||
timeutils.isotime(self.task.created_at)
|
||||
timeutils.isotime(self.task.created_at),
|
||||
output_log['payload']['created_at']
|
||||
)
|
||||
self.assertEqual(
|
||||
output_log['payload']['deleted_at'],
|
||||
now
|
||||
now,
|
||||
output_log['payload']['deleted_at']
|
||||
)
|
||||
if 'location' in output_log['payload']:
|
||||
self.fail('Notification contained location field.')
|
||||
|
@ -493,36 +493,36 @@ class TestTaskNotifications(utils.BaseTestCase):
|
|||
executor._run.return_value = mock.Mock()
|
||||
self.task_proxy.run(executor=mock_executor)
|
||||
output_logs = self.notifier.get_logs()
|
||||
self.assertEqual(len(output_logs), 1)
|
||||
self.assertEqual(1, len(output_logs))
|
||||
output_log = output_logs[0]
|
||||
self.assertEqual(output_log['notification_type'], 'INFO')
|
||||
self.assertEqual(output_log['event_type'], 'task.run')
|
||||
self.assertEqual(output_log['payload']['id'], self.task.task_id)
|
||||
self.assertEqual('INFO', output_log['notification_type'])
|
||||
self.assertEqual('task.run', output_log['event_type'])
|
||||
self.assertEqual(self.task.task_id, output_log['payload']['id'])
|
||||
|
||||
def test_task_processing_notification(self):
|
||||
self.task_proxy.begin_processing()
|
||||
output_logs = self.notifier.get_logs()
|
||||
self.assertEqual(len(output_logs), 1)
|
||||
self.assertEqual(1, len(output_logs))
|
||||
output_log = output_logs[0]
|
||||
self.assertEqual(output_log['notification_type'], 'INFO')
|
||||
self.assertEqual(output_log['event_type'], 'task.processing')
|
||||
self.assertEqual(output_log['payload']['id'], self.task.task_id)
|
||||
self.assertEqual('INFO', output_log['notification_type'])
|
||||
self.assertEqual('task.processing', output_log['event_type'])
|
||||
self.assertEqual(self.task.task_id, output_log['payload']['id'])
|
||||
|
||||
def test_task_success_notification(self):
|
||||
self.task_proxy.begin_processing()
|
||||
self.task_proxy.succeed(result=None)
|
||||
output_logs = self.notifier.get_logs()
|
||||
self.assertEqual(len(output_logs), 2)
|
||||
self.assertEqual(2, len(output_logs))
|
||||
output_log = output_logs[1]
|
||||
self.assertEqual(output_log['notification_type'], 'INFO')
|
||||
self.assertEqual(output_log['event_type'], 'task.success')
|
||||
self.assertEqual(output_log['payload']['id'], self.task.task_id)
|
||||
self.assertEqual('INFO', output_log['notification_type'])
|
||||
self.assertEqual('task.success', output_log['event_type'])
|
||||
self.assertEqual(self.task.task_id, output_log['payload']['id'])
|
||||
|
||||
def test_task_failure_notification(self):
|
||||
self.task_proxy.fail(message=None)
|
||||
output_logs = self.notifier.get_logs()
|
||||
self.assertEqual(len(output_logs), 1)
|
||||
self.assertEqual(1, len(output_logs))
|
||||
output_log = output_logs[0]
|
||||
self.assertEqual(output_log['notification_type'], 'INFO')
|
||||
self.assertEqual(output_log['event_type'], 'task.failure')
|
||||
self.assertEqual(output_log['payload']['id'], self.task.task_id)
|
||||
self.assertEqual('INFO', output_log['notification_type'])
|
||||
self.assertEqual('task.failure', output_log['event_type'])
|
||||
self.assertEqual(self.task.task_id, output_log['payload']['id'])
|
||||
|
|
|
@ -156,7 +156,7 @@ class TestPolicyEnforcer(base.IsolatedUnitTest):
|
|||
enforcer = glance.api.policy.Enforcer()
|
||||
|
||||
context = glance.context.RequestContext(roles=[])
|
||||
self.assertEqual(enforcer.check(context, 'get_image', {}), False)
|
||||
self.assertEqual(False, enforcer.check(context, 'get_image', {}))
|
||||
|
||||
|
||||
class TestPolicyEnforcerNoFile(base.IsolatedUnitTest):
|
||||
|
@ -206,26 +206,26 @@ class TestImagePolicy(test_utils.BaseTestCase):
|
|||
image = glance.api.policy.ImageProxy(self.image_stub, {}, self.policy)
|
||||
self.assertRaises(exception.Forbidden,
|
||||
setattr, image, 'visibility', 'public')
|
||||
self.assertEqual(image.visibility, 'private')
|
||||
self.assertEqual('private', image.visibility)
|
||||
self.policy.enforce.assert_called_once_with({}, "publicize_image", {})
|
||||
|
||||
def test_publicize_image_allowed(self):
|
||||
image = glance.api.policy.ImageProxy(self.image_stub, {}, self.policy)
|
||||
image.visibility = 'public'
|
||||
self.assertEqual(image.visibility, 'public')
|
||||
self.assertEqual('public', image.visibility)
|
||||
self.policy.enforce.assert_called_once_with({}, "publicize_image", {})
|
||||
|
||||
def test_delete_image_not_allowed(self):
|
||||
self.policy.enforce.side_effect = exception.Forbidden
|
||||
image = glance.api.policy.ImageProxy(self.image_stub, {}, self.policy)
|
||||
self.assertRaises(exception.Forbidden, image.delete)
|
||||
self.assertEqual(image.status, 'active')
|
||||
self.assertEqual('active', image.status)
|
||||
self.policy.enforce.assert_called_once_with({}, "delete_image", {})
|
||||
|
||||
def test_delete_image_allowed(self):
|
||||
image = glance.api.policy.ImageProxy(self.image_stub, {}, self.policy)
|
||||
image.delete()
|
||||
self.assertEqual(image.status, 'deleted')
|
||||
self.assertEqual('deleted', image.status)
|
||||
self.policy.enforce.assert_called_once_with({}, "delete_image", {})
|
||||
|
||||
def test_get_image_not_allowed(self):
|
||||
|
@ -240,7 +240,7 @@ class TestImagePolicy(test_utils.BaseTestCase):
|
|||
{}, self.policy)
|
||||
output = image_repo.get(UUID1)
|
||||
self.assertIsInstance(output, glance.api.policy.ImageProxy)
|
||||
self.assertEqual(output.image, 'image_from_get')
|
||||
self.assertEqual('image_from_get', output.image)
|
||||
self.policy.enforce.assert_called_once_with({}, "get_image", {})
|
||||
|
||||
def test_get_images_not_allowed(self):
|
||||
|
@ -256,7 +256,7 @@ class TestImagePolicy(test_utils.BaseTestCase):
|
|||
images = image_repo.list()
|
||||
for i, image in enumerate(images):
|
||||
self.assertIsInstance(image, glance.api.policy.ImageProxy)
|
||||
self.assertEqual(image.image, 'image_from_list_%d' % i)
|
||||
self.assertEqual('image_from_list_%d' % i, image.image)
|
||||
self.policy.enforce.assert_called_once_with({}, "get_images", {})
|
||||
|
||||
def test_modify_image_not_allowed(self):
|
||||
|
@ -340,7 +340,7 @@ class TestMemberPolicy(test_utils.BaseTestCase):
|
|||
def test_add_member_allowed(self):
|
||||
image_member = ImageMembershipStub()
|
||||
self.member_repo.add(image_member)
|
||||
self.assertEqual(image_member.output, 'member_repo_add')
|
||||
self.assertEqual('member_repo_add', image_member.output)
|
||||
self.policy.enforce.assert_called_once_with({}, "add_member", {})
|
||||
|
||||
def test_get_member_not_allowed(self):
|
||||
|
@ -350,7 +350,7 @@ class TestMemberPolicy(test_utils.BaseTestCase):
|
|||
|
||||
def test_get_member_allowed(self):
|
||||
output = self.member_repo.get('')
|
||||
self.assertEqual(output, 'member_repo_get')
|
||||
self.assertEqual('member_repo_get', output)
|
||||
self.policy.enforce.assert_called_once_with({}, "get_member", {})
|
||||
|
||||
def test_modify_member_not_allowed(self):
|
||||
|
@ -361,7 +361,7 @@ class TestMemberPolicy(test_utils.BaseTestCase):
|
|||
def test_modify_member_allowed(self):
|
||||
image_member = ImageMembershipStub()
|
||||
self.member_repo.save(image_member)
|
||||
self.assertEqual(image_member.output, 'member_repo_save')
|
||||
self.assertEqual('member_repo_save', image_member.output)
|
||||
self.policy.enforce.assert_called_once_with({}, "modify_member", {})
|
||||
|
||||
def test_get_members_not_allowed(self):
|
||||
|
@ -371,7 +371,7 @@ class TestMemberPolicy(test_utils.BaseTestCase):
|
|||
|
||||
def test_get_members_allowed(self):
|
||||
output = self.member_repo.list('')
|
||||
self.assertEqual(output, 'member_repo_list')
|
||||
self.assertEqual('member_repo_list', output)
|
||||
self.policy.enforce.assert_called_once_with({}, "get_members", {})
|
||||
|
||||
def test_delete_member_not_allowed(self):
|
||||
|
@ -382,7 +382,7 @@ class TestMemberPolicy(test_utils.BaseTestCase):
|
|||
def test_delete_member_allowed(self):
|
||||
image_member = ImageMembershipStub()
|
||||
self.member_repo.remove(image_member)
|
||||
self.assertEqual(image_member.output, 'member_repo_remove')
|
||||
self.assertEqual('member_repo_remove', image_member.output)
|
||||
self.policy.enforce.assert_called_once_with({}, "delete_member", {})
|
||||
|
||||
|
||||
|
@ -416,7 +416,7 @@ class TestTaskPolicy(test_utils.BaseTestCase):
|
|||
)
|
||||
task = task_repo.get(UUID1)
|
||||
self.assertIsInstance(task, glance.api.policy.TaskProxy)
|
||||
self.assertEqual(task.task, 'task_from_get')
|
||||
self.assertEqual('task_from_get', task.task)
|
||||
|
||||
def test_get_tasks_not_allowed(self):
|
||||
rules = {"get_tasks": False}
|
||||
|
@ -439,7 +439,7 @@ class TestTaskPolicy(test_utils.BaseTestCase):
|
|||
tasks = task_repo.list()
|
||||
for i, task in enumerate(tasks):
|
||||
self.assertIsInstance(task, glance.api.policy.TaskStubProxy)
|
||||
self.assertEqual(task.task_stub, 'task_from_list_%d' % i)
|
||||
self.assertEqual('task_from_list_%d' % i, task.task_stub)
|
||||
|
||||
def test_add_task_not_allowed(self):
|
||||
rules = {"add_task": False}
|
||||
|
@ -480,7 +480,7 @@ class TestContextPolicyEnforcer(base.IsolatedUnitTest):
|
|||
context = glance.context.RequestContext(roles=[context_role],
|
||||
is_admin=context_is_admin,
|
||||
policy_enforcer=enforcer)
|
||||
self.assertEqual(context.is_admin, admin_expected)
|
||||
self.assertEqual(admin_expected, context.is_admin)
|
||||
|
||||
def test_context_admin_policy_admin(self):
|
||||
self._do_test_policy_influence_context_admin('test_admin',
|
||||
|
|
|
@ -492,7 +492,7 @@ class TestImageTagQuotas(test_utils.BaseTestCase):
|
|||
def test_replace_image_tag(self):
|
||||
self.config(image_tag_quota=1)
|
||||
self.image.tags = ['foo']
|
||||
self.assertEqual(len(self.image.tags), 1)
|
||||
self.assertEqual(1, len(self.image.tags))
|
||||
|
||||
def test_replace_too_many_image_tags(self):
|
||||
self.config(image_tag_quota=0)
|
||||
|
@ -500,17 +500,17 @@ class TestImageTagQuotas(test_utils.BaseTestCase):
|
|||
exc = self.assertRaises(exception.ImageTagLimitExceeded,
|
||||
setattr, self.image, 'tags', ['foo', 'bar'])
|
||||
self.assertIn('Attempted: 2, Maximum: 0', six.text_type(exc))
|
||||
self.assertEqual(len(self.image.tags), 0)
|
||||
self.assertEqual(0, len(self.image.tags))
|
||||
|
||||
def test_replace_unlimited_image_tags(self):
|
||||
self.config(image_tag_quota=-1)
|
||||
self.image.tags = ['foo']
|
||||
self.assertEqual(len(self.image.tags), 1)
|
||||
self.assertEqual(1, len(self.image.tags))
|
||||
|
||||
def test_add_image_tag(self):
|
||||
self.config(image_tag_quota=1)
|
||||
self.image.tags.add('foo')
|
||||
self.assertEqual(len(self.image.tags), 1)
|
||||
self.assertEqual(1, len(self.image.tags))
|
||||
|
||||
def test_add_too_many_image_tags(self):
|
||||
self.config(image_tag_quota=1)
|
||||
|
@ -522,15 +522,15 @@ class TestImageTagQuotas(test_utils.BaseTestCase):
|
|||
def test_add_unlimited_image_tags(self):
|
||||
self.config(image_tag_quota=-1)
|
||||
self.image.tags.add('foo')
|
||||
self.assertEqual(len(self.image.tags), 1)
|
||||
self.assertEqual(1, len(self.image.tags))
|
||||
|
||||
def test_remove_image_tag_while_over_quota(self):
|
||||
self.config(image_tag_quota=1)
|
||||
self.image.tags.add('foo')
|
||||
self.assertEqual(len(self.image.tags), 1)
|
||||
self.assertEqual(1, len(self.image.tags))
|
||||
self.config(image_tag_quota=0)
|
||||
self.image.tags.remove('foo')
|
||||
self.assertEqual(len(self.image.tags), 0)
|
||||
self.assertEqual(0, len(self.image.tags))
|
||||
|
||||
|
||||
class TestQuotaImageTagsProxy(test_utils.BaseTestCase):
|
||||
|
@ -562,15 +562,15 @@ class TestQuotaImageTagsProxy(test_utils.BaseTestCase):
|
|||
'bar',
|
||||
'baz',
|
||||
'niz']))
|
||||
self.assertEqual(len(proxy), 4)
|
||||
self.assertEqual(4, len(proxy))
|
||||
|
||||
def test_iter(self):
|
||||
items = set(['foo', 'bar', 'baz', 'niz'])
|
||||
proxy = glance.quota.QuotaImageTagsProxy(items.copy())
|
||||
self.assertEqual(len(items), 4)
|
||||
self.assertEqual(4, len(items))
|
||||
for item in proxy:
|
||||
items.remove(item)
|
||||
self.assertEqual(len(items), 0)
|
||||
self.assertEqual(0, len(items))
|
||||
|
||||
|
||||
class TestImageMemberQuotas(test_utils.BaseTestCase):
|
||||
|
@ -634,7 +634,7 @@ class TestImageLocationQuotas(test_utils.BaseTestCase):
|
|||
self.image.locations = [{"url": "file:///fake.img.tar.gz",
|
||||
"metadata": {}
|
||||
}]
|
||||
self.assertEqual(len(self.image.locations), 1)
|
||||
self.assertEqual(1, len(self.image.locations))
|
||||
|
||||
def test_replace_too_many_image_locations(self):
|
||||
self.config(image_location_quota=1)
|
||||
|
@ -649,20 +649,20 @@ class TestImageLocationQuotas(test_utils.BaseTestCase):
|
|||
exc = self.assertRaises(exception.ImageLocationLimitExceeded,
|
||||
setattr, self.image, 'locations', locations)
|
||||
self.assertIn('Attempted: 3, Maximum: 1', six.text_type(exc))
|
||||
self.assertEqual(len(self.image.locations), 1)
|
||||
self.assertEqual(1, len(self.image.locations))
|
||||
|
||||
def test_replace_unlimited_image_locations(self):
|
||||
self.config(image_location_quota=-1)
|
||||
self.image.locations = [{"url": "file:///fake.img.tar.gz",
|
||||
"metadata": {}}
|
||||
]
|
||||
self.assertEqual(len(self.image.locations), 1)
|
||||
self.assertEqual(1, len(self.image.locations))
|
||||
|
||||
def test_add_image_location(self):
|
||||
self.config(image_location_quota=1)
|
||||
location = {"url": "file:///fake.img.tar.gz", "metadata": {}}
|
||||
self.image.locations.append(location)
|
||||
self.assertEqual(len(self.image.locations), 1)
|
||||
self.assertEqual(1, len(self.image.locations))
|
||||
|
||||
def test_add_too_many_image_locations(self):
|
||||
self.config(image_location_quota=1)
|
||||
|
@ -677,13 +677,13 @@ class TestImageLocationQuotas(test_utils.BaseTestCase):
|
|||
self.config(image_location_quota=-1)
|
||||
location1 = {"url": "file:///fake1.img.tar.gz", "metadata": {}}
|
||||
self.image.locations.append(location1)
|
||||
self.assertEqual(len(self.image.locations), 1)
|
||||
self.assertEqual(1, len(self.image.locations))
|
||||
|
||||
def test_remove_image_location_while_over_quota(self):
|
||||
self.config(image_location_quota=1)
|
||||
location1 = {"url": "file:///fake1.img.tar.gz", "metadata": {}}
|
||||
self.image.locations.append(location1)
|
||||
self.assertEqual(len(self.image.locations), 1)
|
||||
self.assertEqual(1, len(self.image.locations))
|
||||
self.config(image_location_quota=0)
|
||||
self.image.locations.remove(location1)
|
||||
self.assertEqual(len(self.image.locations), 0)
|
||||
self.assertEqual(0, len(self.image.locations))
|
||||
|
|
|
@ -44,13 +44,13 @@ class TestBasicSchema(test_utils.BaseTestCase):
|
|||
obj = {'ham': 'virginia', 'eggs': 'scrambled', 'bacon': 'crispy'}
|
||||
filtered = self.schema.filter(obj)
|
||||
expected = {'ham': 'virginia', 'eggs': 'scrambled'}
|
||||
self.assertEqual(filtered, expected)
|
||||
self.assertEqual(expected, filtered)
|
||||
|
||||
def test_merge_properties(self):
|
||||
self.schema.merge_properties({'bacon': {'type': 'string'}})
|
||||
expected = set(['ham', 'eggs', 'bacon'])
|
||||
actual = set(self.schema.raw()['properties'].keys())
|
||||
self.assertEqual(actual, expected)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_merge_conflicting_properties(self):
|
||||
conflicts = {'eggs': {'type': 'integer'}}
|
||||
|
@ -62,7 +62,7 @@ class TestBasicSchema(test_utils.BaseTestCase):
|
|||
self.schema.merge_properties(conflicts) # no exception raised
|
||||
expected = set(['ham', 'eggs'])
|
||||
actual = set(self.schema.raw()['properties'].keys())
|
||||
self.assertEqual(actual, expected)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_raw_json_schema(self):
|
||||
expected = {
|
||||
|
@ -73,7 +73,7 @@ class TestBasicSchema(test_utils.BaseTestCase):
|
|||
},
|
||||
'additionalProperties': False,
|
||||
}
|
||||
self.assertEqual(self.schema.raw(), expected)
|
||||
self.assertEqual(expected, self.schema.raw())
|
||||
|
||||
|
||||
class TestBasicSchemaLinks(test_utils.BaseTestCase):
|
||||
|
@ -101,7 +101,7 @@ class TestBasicSchemaLinks(test_utils.BaseTestCase):
|
|||
],
|
||||
'additionalProperties': False,
|
||||
}
|
||||
self.assertEqual(self.schema.raw(), expected)
|
||||
self.assertEqual(expected, self.schema.raw())
|
||||
|
||||
|
||||
class TestPermissiveSchema(test_utils.BaseTestCase):
|
||||
|
@ -125,7 +125,7 @@ class TestPermissiveSchema(test_utils.BaseTestCase):
|
|||
def test_filter_passes_extra_properties(self):
|
||||
obj = {'ham': 'virginia', 'eggs': 'scrambled', 'bacon': 'crispy'}
|
||||
filtered = self.schema.filter(obj)
|
||||
self.assertEqual(filtered, obj)
|
||||
self.assertEqual(obj, filtered)
|
||||
|
||||
def test_raw_json_schema(self):
|
||||
expected = {
|
||||
|
@ -136,7 +136,7 @@ class TestPermissiveSchema(test_utils.BaseTestCase):
|
|||
},
|
||||
'additionalProperties': {'type': 'string'},
|
||||
}
|
||||
self.assertEqual(self.schema.raw(), expected)
|
||||
self.assertEqual(expected, self.schema.raw())
|
||||
|
||||
|
||||
class TestCollectionSchema(test_utils.BaseTestCase):
|
||||
|
@ -162,4 +162,4 @@ class TestCollectionSchema(test_utils.BaseTestCase):
|
|||
{'rel': 'describedby', 'href': '{schema}'},
|
||||
],
|
||||
}
|
||||
self.assertEqual(collection_schema.raw(), expected)
|
||||
self.assertEqual(expected, collection_schema.raw())
|
||||
|
|
|
@ -102,7 +102,7 @@ class TestStoreImage(utils.BaseTestCase):
|
|||
def test_image_get_data(self):
|
||||
image = glance.location.ImageProxy(self.image_stub, {},
|
||||
self.store_api, self.store_utils)
|
||||
self.assertEqual(image.get_data(), 'XXX')
|
||||
self.assertEqual('XXX', image.get_data())
|
||||
|
||||
def test_image_get_data_from_second_location(self):
|
||||
def fake_get_from_backend(self, location, offset=0,
|
||||
|
@ -114,23 +114,24 @@ class TestStoreImage(utils.BaseTestCase):
|
|||
|
||||
image1 = glance.location.ImageProxy(self.image_stub, {},
|
||||
self.store_api, self.store_utils)
|
||||
self.assertEqual(image1.get_data(), 'XXX')
|
||||
self.assertEqual('XXX', image1.get_data())
|
||||
# Multiple location support
|
||||
context = glance.context.RequestContext(user=USER1)
|
||||
(image2, image_stub2) = self._add_image(context, UUID2, 'ZZZ', 3)
|
||||
location_data = image2.locations[0]
|
||||
image1.locations.append(location_data)
|
||||
self.assertEqual(len(image1.locations), 2)
|
||||
self.assertEqual(location_data['url'], UUID2)
|
||||
self.assertEqual(2, len(image1.locations))
|
||||
self.assertEqual(UUID2, location_data['url'])
|
||||
|
||||
self.stubs.Set(unit_test_utils.FakeStoreAPI, 'get_from_backend',
|
||||
fake_get_from_backend)
|
||||
# This time, image1.get_data() returns the data wrapped in a
|
||||
# LimitingReader|CooperativeReader pipeline, so peeking under
|
||||
# the hood of those objects to get at the underlying string.
|
||||
self.assertEqual(image1.get_data().data.fd, 'ZZZ')
|
||||
self.assertEqual('ZZZ', image1.get_data().data.fd)
|
||||
|
||||
image1.locations.pop(0)
|
||||
self.assertEqual(len(image1.locations), 1)
|
||||
self.assertEqual(1, len(image1.locations))
|
||||
image2.delete()
|
||||
|
||||
def test_image_set_data(self):
|
||||
|
@ -141,9 +142,9 @@ class TestStoreImage(utils.BaseTestCase):
|
|||
image.set_data('YYYY', 4)
|
||||
self.assertEqual(image.size, 4)
|
||||
# NOTE(markwash): FakeStore returns image_id for location
|
||||
self.assertEqual(image.locations[0]['url'], UUID2)
|
||||
self.assertEqual(image.checksum, 'Z')
|
||||
self.assertEqual(image.status, 'active')
|
||||
self.assertEqual(UUID2, image.locations[0]['url'])
|
||||
self.assertEqual('Z', image.checksum)
|
||||
self.assertEqual('active', image.status)
|
||||
|
||||
def test_image_set_data_location_metadata(self):
|
||||
context = glance.context.RequestContext(user=USER1)
|
||||
|
@ -154,12 +155,12 @@ class TestStoreImage(utils.BaseTestCase):
|
|||
image = glance.location.ImageProxy(image_stub, context,
|
||||
store_api, store_utils)
|
||||
image.set_data('YYYY', 4)
|
||||
self.assertEqual(image.size, 4)
|
||||
self.assertEqual(4, image.size)
|
||||
location_data = image.locations[0]
|
||||
self.assertEqual(location_data['url'], UUID2)
|
||||
self.assertEqual(location_data['metadata'], loc_meta)
|
||||
self.assertEqual(image.checksum, 'Z')
|
||||
self.assertEqual(image.status, 'active')
|
||||
self.assertEqual(UUID2, location_data['url'])
|
||||
self.assertEqual(loc_meta, location_data['metadata'])
|
||||
self.assertEqual('Z', image.checksum)
|
||||
self.assertEqual('active', image.status)
|
||||
image.delete()
|
||||
self.assertEqual(image.status, 'deleted')
|
||||
self.assertRaises(glance_store.NotFound,
|
||||
|
@ -174,9 +175,9 @@ class TestStoreImage(utils.BaseTestCase):
|
|||
image.set_data('YYYY', None)
|
||||
self.assertEqual(image.size, 4)
|
||||
# NOTE(markwash): FakeStore returns image_id for location
|
||||
self.assertEqual(image.locations[0]['url'], UUID2)
|
||||
self.assertEqual(image.checksum, 'Z')
|
||||
self.assertEqual(image.status, 'active')
|
||||
self.assertEqual(UUID2, image.locations[0]['url'])
|
||||
self.assertEqual('Z', image.checksum)
|
||||
self.assertEqual('active', image.status)
|
||||
image.delete()
|
||||
self.assertEqual(image.status, 'deleted')
|
||||
self.assertRaises(glance_store.NotFound,
|
||||
|
@ -188,16 +189,16 @@ class TestStoreImage(utils.BaseTestCase):
|
|||
image = glance.location.ImageProxy(image_stub, context,
|
||||
self.store_api, self.store_utils)
|
||||
image.set_data(data, len)
|
||||
self.assertEqual(image.size, len)
|
||||
self.assertEqual(len, image.size)
|
||||
# NOTE(markwash): FakeStore returns image_id for location
|
||||
location = {'url': image_id, 'metadata': {}, 'status': 'active'}
|
||||
self.assertEqual(image.locations, [location])
|
||||
self.assertEqual(image_stub.locations, [location])
|
||||
self.assertEqual(image.status, 'active')
|
||||
self.assertEqual([location], image.locations)
|
||||
self.assertEqual([location], image_stub.locations)
|
||||
self.assertEqual('active', image.status)
|
||||
return (image, image_stub)
|
||||
|
||||
def test_image_change_append_invalid_location_uri(self):
|
||||
self.assertEqual(len(self.store_api.data.keys()), 2)
|
||||
self.assertEqual(2, len(self.store_api.data.keys()))
|
||||
|
||||
context = glance.context.RequestContext(user=USER1)
|
||||
(image1, image_stub1) = self._add_image(context, UUID2, 'XXXX', 4)
|
||||
|
@ -208,12 +209,12 @@ class TestStoreImage(utils.BaseTestCase):
|
|||
|
||||
image1.delete()
|
||||
|
||||
self.assertEqual(len(self.store_api.data.keys()), 2)
|
||||
self.assertEqual(2, len(self.store_api.data.keys()))
|
||||
self.assertNotIn(UUID2, self.store_api.data.keys())
|
||||
|
||||
def test_image_change_append_invalid_location_metatdata(self):
|
||||
UUID3 = 'a8a61ec4-d7a3-11e2-8c28-000c29c27581'
|
||||
self.assertEqual(len(self.store_api.data.keys()), 2)
|
||||
self.assertEqual(2, len(self.store_api.data.keys()))
|
||||
|
||||
context = glance.context.RequestContext(user=USER1)
|
||||
(image1, image_stub1) = self._add_image(context, UUID2, 'XXXX', 4)
|
||||
|
@ -232,13 +233,13 @@ class TestStoreImage(utils.BaseTestCase):
|
|||
image1.delete()
|
||||
image2.delete()
|
||||
|
||||
self.assertEqual(len(self.store_api.data.keys()), 2)
|
||||
self.assertEqual(2, len(self.store_api.data.keys()))
|
||||
self.assertNotIn(UUID2, self.store_api.data.keys())
|
||||
self.assertNotIn(UUID3, self.store_api.data.keys())
|
||||
|
||||
def test_image_change_append_locations(self):
|
||||
UUID3 = 'a8a61ec4-d7a3-11e2-8c28-000c29c27581'
|
||||
self.assertEqual(len(self.store_api.data.keys()), 2)
|
||||
self.assertEqual(2, len(self.store_api.data.keys()))
|
||||
|
||||
context = glance.context.RequestContext(user=USER1)
|
||||
(image1, image_stub1) = self._add_image(context, UUID2, 'XXXX', 4)
|
||||
|
@ -249,12 +250,12 @@ class TestStoreImage(utils.BaseTestCase):
|
|||
|
||||
image1.locations.append(location3)
|
||||
|
||||
self.assertEqual(image_stub1.locations, [location2, location3])
|
||||
self.assertEqual(image1.locations, [location2, location3])
|
||||
self.assertEqual([location2, location3], image_stub1.locations)
|
||||
self.assertEqual([location2, location3], image1.locations)
|
||||
|
||||
image1.delete()
|
||||
|
||||
self.assertEqual(len(self.store_api.data.keys()), 2)
|
||||
self.assertEqual(2, len(self.store_api.data.keys()))
|
||||
self.assertNotIn(UUID2, self.store_api.data.keys())
|
||||
self.assertNotIn(UUID3, self.store_api.data.keys())
|
||||
|
||||
|
@ -262,7 +263,7 @@ class TestStoreImage(utils.BaseTestCase):
|
|||
|
||||
def test_image_change_pop_location(self):
|
||||
UUID3 = 'a8a61ec4-d7a3-11e2-8c28-000c29c27581'
|
||||
self.assertEqual(len(self.store_api.data.keys()), 2)
|
||||
self.assertEqual(2, len(self.store_api.data.keys()))
|
||||
|
||||
context = glance.context.RequestContext(user=USER1)
|
||||
(image1, image_stub1) = self._add_image(context, UUID2, 'XXXX', 4)
|
||||
|
@ -273,24 +274,24 @@ class TestStoreImage(utils.BaseTestCase):
|
|||
|
||||
image1.locations.append(location3)
|
||||
|
||||
self.assertEqual(image_stub1.locations, [location2, location3])
|
||||
self.assertEqual(image1.locations, [location2, location3])
|
||||
self.assertEqual([location2, location3], image_stub1.locations)
|
||||
self.assertEqual([location2, location3], image1.locations)
|
||||
|
||||
image1.locations.pop()
|
||||
|
||||
self.assertEqual(image_stub1.locations, [location2])
|
||||
self.assertEqual(image1.locations, [location2])
|
||||
self.assertEqual([location2], image_stub1.locations)
|
||||
self.assertEqual([location2], image1.locations)
|
||||
|
||||
image1.delete()
|
||||
|
||||
self.assertEqual(len(self.store_api.data.keys()), 2)
|
||||
self.assertEqual(2, len(self.store_api.data.keys()))
|
||||
self.assertNotIn(UUID2, self.store_api.data.keys())
|
||||
self.assertNotIn(UUID3, self.store_api.data.keys())
|
||||
|
||||
image2.delete()
|
||||
|
||||
def test_image_change_extend_invalid_locations_uri(self):
|
||||
self.assertEqual(len(self.store_api.data.keys()), 2)
|
||||
self.assertEqual(2, len(self.store_api.data.keys()))
|
||||
|
||||
context = glance.context.RequestContext(user=USER1)
|
||||
(image1, image_stub1) = self._add_image(context, UUID2, 'XXXX', 4)
|
||||
|
@ -302,12 +303,12 @@ class TestStoreImage(utils.BaseTestCase):
|
|||
|
||||
image1.delete()
|
||||
|
||||
self.assertEqual(len(self.store_api.data.keys()), 2)
|
||||
self.assertEqual(2, len(self.store_api.data.keys()))
|
||||
self.assertNotIn(UUID2, self.store_api.data.keys())
|
||||
|
||||
def test_image_change_extend_invalid_locations_metadata(self):
|
||||
UUID3 = 'a8a61ec4-d7a3-11e2-8c28-000c29c27581'
|
||||
self.assertEqual(len(self.store_api.data.keys()), 2)
|
||||
self.assertEqual(2, len(self.store_api.data.keys()))
|
||||
|
||||
context = glance.context.RequestContext(user=USER1)
|
||||
(image1, image_stub1) = self._add_image(context, UUID2, 'XXXX', 4)
|
||||
|
@ -321,13 +322,13 @@ class TestStoreImage(utils.BaseTestCase):
|
|||
image1.delete()
|
||||
image2.delete()
|
||||
|
||||
self.assertEqual(len(self.store_api.data.keys()), 2)
|
||||
self.assertEqual(2, len(self.store_api.data.keys()))
|
||||
self.assertNotIn(UUID2, self.store_api.data.keys())
|
||||
self.assertNotIn(UUID3, self.store_api.data.keys())
|
||||
|
||||
def test_image_change_extend_locations(self):
|
||||
UUID3 = 'a8a61ec4-d7a3-11e2-8c28-000c29c27581'
|
||||
self.assertEqual(len(self.store_api.data.keys()), 2)
|
||||
self.assertEqual(2, len(self.store_api.data.keys()))
|
||||
|
||||
context = glance.context.RequestContext(user=USER1)
|
||||
(image1, image_stub1) = self._add_image(context, UUID2, 'XXXX', 4)
|
||||
|
@ -338,12 +339,12 @@ class TestStoreImage(utils.BaseTestCase):
|
|||
|
||||
image1.locations.extend([location3])
|
||||
|
||||
self.assertEqual(image_stub1.locations, [location2, location3])
|
||||
self.assertEqual(image1.locations, [location2, location3])
|
||||
self.assertEqual([location2, location3], image_stub1.locations)
|
||||
self.assertEqual([location2, location3], image1.locations)
|
||||
|
||||
image1.delete()
|
||||
|
||||
self.assertEqual(len(self.store_api.data.keys()), 2)
|
||||
self.assertEqual(2, len(self.store_api.data.keys()))
|
||||
self.assertNotIn(UUID2, self.store_api.data.keys())
|
||||
self.assertNotIn(UUID3, self.store_api.data.keys())
|
||||
|
||||
|
@ -351,7 +352,7 @@ class TestStoreImage(utils.BaseTestCase):
|
|||
|
||||
def test_image_change_remove_location(self):
|
||||
UUID3 = 'a8a61ec4-d7a3-11e2-8c28-000c29c27581'
|
||||
self.assertEqual(len(self.store_api.data.keys()), 2)
|
||||
self.assertEqual(2, len(self.store_api.data.keys()))
|
||||
|
||||
context = glance.context.RequestContext(user=USER1)
|
||||
(image1, image_stub1) = self._add_image(context, UUID2, 'XXXX', 4)
|
||||
|
@ -364,36 +365,36 @@ class TestStoreImage(utils.BaseTestCase):
|
|||
image1.locations.extend([location3])
|
||||
image1.locations.remove(location2)
|
||||
|
||||
self.assertEqual(image_stub1.locations, [location3])
|
||||
self.assertEqual(image1.locations, [location3])
|
||||
self.assertEqual([location3], image_stub1.locations)
|
||||
self.assertEqual([location3], image1.locations)
|
||||
self.assertRaises(ValueError,
|
||||
image1.locations.remove, location_bad)
|
||||
|
||||
image1.delete()
|
||||
image2.delete()
|
||||
|
||||
self.assertEqual(len(self.store_api.data.keys()), 2)
|
||||
self.assertEqual(2, len(self.store_api.data.keys()))
|
||||
self.assertNotIn(UUID2, self.store_api.data.keys())
|
||||
self.assertNotIn(UUID3, self.store_api.data.keys())
|
||||
|
||||
def test_image_change_delete_location(self):
|
||||
self.assertEqual(len(self.store_api.data.keys()), 2)
|
||||
self.assertEqual(2, len(self.store_api.data.keys()))
|
||||
|
||||
context = glance.context.RequestContext(user=USER1)
|
||||
(image1, image_stub1) = self._add_image(context, UUID2, 'XXXX', 4)
|
||||
|
||||
del image1.locations[0]
|
||||
|
||||
self.assertEqual(image_stub1.locations, [])
|
||||
self.assertEqual(len(image1.locations), 0)
|
||||
self.assertEqual([], image_stub1.locations)
|
||||
self.assertEqual(0, len(image1.locations))
|
||||
|
||||
self.assertEqual(len(self.store_api.data.keys()), 2)
|
||||
self.assertEqual(2, len(self.store_api.data.keys()))
|
||||
self.assertNotIn(UUID2, self.store_api.data.keys())
|
||||
|
||||
image1.delete()
|
||||
|
||||
def test_image_change_insert_invalid_location_uri(self):
|
||||
self.assertEqual(len(self.store_api.data.keys()), 2)
|
||||
self.assertEqual(2, len(self.store_api.data.keys()))
|
||||
|
||||
context = glance.context.RequestContext(user=USER1)
|
||||
(image1, image_stub1) = self._add_image(context, UUID2, 'XXXX', 4)
|
||||
|
@ -404,12 +405,12 @@ class TestStoreImage(utils.BaseTestCase):
|
|||
|
||||
image1.delete()
|
||||
|
||||
self.assertEqual(len(self.store_api.data.keys()), 2)
|
||||
self.assertEqual(2, len(self.store_api.data.keys()))
|
||||
self.assertNotIn(UUID2, self.store_api.data.keys())
|
||||
|
||||
def test_image_change_insert_invalid_location_metadata(self):
|
||||
UUID3 = 'a8a61ec4-d7a3-11e2-8c28-000c29c27581'
|
||||
self.assertEqual(len(self.store_api.data.keys()), 2)
|
||||
self.assertEqual(2, len(self.store_api.data.keys()))
|
||||
|
||||
context = glance.context.RequestContext(user=USER1)
|
||||
(image1, image_stub1) = self._add_image(context, UUID2, 'XXXX', 4)
|
||||
|
@ -423,13 +424,13 @@ class TestStoreImage(utils.BaseTestCase):
|
|||
image1.delete()
|
||||
image2.delete()
|
||||
|
||||
self.assertEqual(len(self.store_api.data.keys()), 2)
|
||||
self.assertEqual(2, len(self.store_api.data.keys()))
|
||||
self.assertNotIn(UUID2, self.store_api.data.keys())
|
||||
self.assertNotIn(UUID3, self.store_api.data.keys())
|
||||
|
||||
def test_image_change_insert_location(self):
|
||||
UUID3 = 'a8a61ec4-d7a3-11e2-8c28-000c29c27581'
|
||||
self.assertEqual(len(self.store_api.data.keys()), 2)
|
||||
self.assertEqual(2, len(self.store_api.data.keys()))
|
||||
|
||||
context = glance.context.RequestContext(user=USER1)
|
||||
(image1, image_stub1) = self._add_image(context, UUID2, 'XXXX', 4)
|
||||
|
@ -440,12 +441,12 @@ class TestStoreImage(utils.BaseTestCase):
|
|||
|
||||
image1.locations.insert(0, location3)
|
||||
|
||||
self.assertEqual(image_stub1.locations, [location3, location2])
|
||||
self.assertEqual(image1.locations, [location3, location2])
|
||||
self.assertEqual([location3, location2], image_stub1.locations)
|
||||
self.assertEqual([location3, location2], image1.locations)
|
||||
|
||||
image1.delete()
|
||||
|
||||
self.assertEqual(len(self.store_api.data.keys()), 2)
|
||||
self.assertEqual(2, len(self.store_api.data.keys()))
|
||||
self.assertNotIn(UUID2, self.store_api.data.keys())
|
||||
self.assertNotIn(UUID3, self.store_api.data.keys())
|
||||
|
||||
|
@ -453,7 +454,7 @@ class TestStoreImage(utils.BaseTestCase):
|
|||
|
||||
def test_image_change_delete_locations(self):
|
||||
UUID3 = 'a8a61ec4-d7a3-11e2-8c28-000c29c27581'
|
||||
self.assertEqual(len(self.store_api.data.keys()), 2)
|
||||
self.assertEqual(2, len(self.store_api.data.keys()))
|
||||
|
||||
context = glance.context.RequestContext(user=USER1)
|
||||
(image1, image_stub1) = self._add_image(context, UUID2, 'XXXX', 4)
|
||||
|
@ -465,8 +466,8 @@ class TestStoreImage(utils.BaseTestCase):
|
|||
image1.locations.insert(0, location3)
|
||||
del image1.locations[0:100]
|
||||
|
||||
self.assertEqual(image_stub1.locations, [])
|
||||
self.assertEqual(len(image1.locations), 0)
|
||||
self.assertEqual([], image_stub1.locations)
|
||||
self.assertEqual(0, len(image1.locations))
|
||||
self.assertRaises(exception.BadStoreUri,
|
||||
image1.locations.insert, 0, location2)
|
||||
self.assertRaises(exception.BadStoreUri,
|
||||
|
@ -475,12 +476,12 @@ class TestStoreImage(utils.BaseTestCase):
|
|||
image1.delete()
|
||||
image2.delete()
|
||||
|
||||
self.assertEqual(len(self.store_api.data.keys()), 2)
|
||||
self.assertEqual(2, len(self.store_api.data.keys()))
|
||||
self.assertNotIn(UUID2, self.store_api.data.keys())
|
||||
self.assertNotIn(UUID3, self.store_api.data.keys())
|
||||
|
||||
def test_image_change_adding_invalid_location_uri(self):
|
||||
self.assertEqual(len(self.store_api.data.keys()), 2)
|
||||
self.assertEqual(2, len(self.store_api.data.keys()))
|
||||
|
||||
context = glance.context.RequestContext(user=USER1)
|
||||
image_stub1 = ImageStub('fake_image_id', status='queued', locations=[])
|
||||
|
@ -491,16 +492,16 @@ class TestStoreImage(utils.BaseTestCase):
|
|||
|
||||
self.assertRaises(exception.BadStoreUri,
|
||||
image1.locations.__iadd__, [location_bad])
|
||||
self.assertEqual(image_stub1.locations, [])
|
||||
self.assertEqual(image1.locations, [])
|
||||
self.assertEqual([], image_stub1.locations)
|
||||
self.assertEqual([], image1.locations)
|
||||
|
||||
image1.delete()
|
||||
|
||||
self.assertEqual(len(self.store_api.data.keys()), 2)
|
||||
self.assertEqual(2, len(self.store_api.data.keys()))
|
||||
self.assertNotIn(UUID2, self.store_api.data.keys())
|
||||
|
||||
def test_image_change_adding_invalid_location_metadata(self):
|
||||
self.assertEqual(len(self.store_api.data.keys()), 2)
|
||||
self.assertEqual(2, len(self.store_api.data.keys()))
|
||||
|
||||
context = glance.context.RequestContext(user=USER1)
|
||||
(image1, image_stub1) = self._add_image(context, UUID2, 'XXXX', 4)
|
||||
|
@ -513,18 +514,18 @@ class TestStoreImage(utils.BaseTestCase):
|
|||
|
||||
self.assertRaises(glance_store.BackendException,
|
||||
image2.locations.__iadd__, [location_bad])
|
||||
self.assertEqual(image_stub2.locations, [])
|
||||
self.assertEqual(image2.locations, [])
|
||||
self.assertEqual([], image_stub2.locations)
|
||||
self.assertEqual([], image2.locations)
|
||||
|
||||
image1.delete()
|
||||
image2.delete()
|
||||
|
||||
self.assertEqual(len(self.store_api.data.keys()), 2)
|
||||
self.assertEqual(2, len(self.store_api.data.keys()))
|
||||
self.assertNotIn(UUID2, self.store_api.data.keys())
|
||||
|
||||
def test_image_change_adding_locations(self):
|
||||
UUID3 = 'a8a61ec4-d7a3-11e2-8c28-000c29c27581'
|
||||
self.assertEqual(len(self.store_api.data.keys()), 2)
|
||||
self.assertEqual(2, len(self.store_api.data.keys()))
|
||||
|
||||
context = glance.context.RequestContext(user=USER1)
|
||||
(image1, image_stub1) = self._add_image(context, UUID2, 'XXXX', 4)
|
||||
|
@ -539,12 +540,12 @@ class TestStoreImage(utils.BaseTestCase):
|
|||
|
||||
image3.locations += [location2, location3]
|
||||
|
||||
self.assertEqual(image_stub3.locations, [location2, location3])
|
||||
self.assertEqual(image3.locations, [location2, location3])
|
||||
self.assertEqual([location2, location3], image_stub3.locations)
|
||||
self.assertEqual([location2, location3], image3.locations)
|
||||
|
||||
image3.delete()
|
||||
|
||||
self.assertEqual(len(self.store_api.data.keys()), 2)
|
||||
self.assertEqual(2, len(self.store_api.data.keys()))
|
||||
self.assertNotIn(UUID2, self.store_api.data.keys())
|
||||
self.assertNotIn(UUID3, self.store_api.data.keys())
|
||||
|
||||
|
@ -553,7 +554,7 @@ class TestStoreImage(utils.BaseTestCase):
|
|||
|
||||
def test_image_get_location_index(self):
|
||||
UUID3 = 'a8a61ec4-d7a3-11e2-8c28-000c29c27581'
|
||||
self.assertEqual(len(self.store_api.data.keys()), 2)
|
||||
self.assertEqual(2, len(self.store_api.data.keys()))
|
||||
|
||||
context = glance.context.RequestContext(user=USER1)
|
||||
(image1, image_stub1) = self._add_image(context, UUID2, 'XXXX', 4)
|
||||
|
@ -568,11 +569,11 @@ class TestStoreImage(utils.BaseTestCase):
|
|||
|
||||
image3.locations += [location2, location3]
|
||||
|
||||
self.assertEqual(image_stub3.locations.index(location3), 1)
|
||||
self.assertEqual(1, image_stub3.locations.index(location3))
|
||||
|
||||
image3.delete()
|
||||
|
||||
self.assertEqual(len(self.store_api.data.keys()), 2)
|
||||
self.assertEqual(2, len(self.store_api.data.keys()))
|
||||
self.assertNotIn(UUID2, self.store_api.data.keys())
|
||||
self.assertNotIn(UUID3, self.store_api.data.keys())
|
||||
|
||||
|
@ -581,7 +582,7 @@ class TestStoreImage(utils.BaseTestCase):
|
|||
|
||||
def test_image_get_location_by_index(self):
|
||||
UUID3 = 'a8a61ec4-d7a3-11e2-8c28-000c29c27581'
|
||||
self.assertEqual(len(self.store_api.data.keys()), 2)
|
||||
self.assertEqual(2, len(self.store_api.data.keys()))
|
||||
|
||||
context = glance.context.RequestContext(user=USER1)
|
||||
(image1, image_stub1) = self._add_image(context, UUID2, 'XXXX', 4)
|
||||
|
@ -595,12 +596,12 @@ class TestStoreImage(utils.BaseTestCase):
|
|||
|
||||
image3.locations += [location2, location3]
|
||||
|
||||
self.assertEqual(image_stub3.locations.index(location3), 1)
|
||||
self.assertEqual(image_stub3.locations[0], location2)
|
||||
self.assertEqual(1, image_stub3.locations.index(location3))
|
||||
self.assertEqual(location2, image_stub3.locations[0])
|
||||
|
||||
image3.delete()
|
||||
|
||||
self.assertEqual(len(self.store_api.data.keys()), 2)
|
||||
self.assertEqual(2, len(self.store_api.data.keys()))
|
||||
self.assertNotIn(UUID2, self.store_api.data.keys())
|
||||
self.assertNotIn(UUID3, self.store_api.data.keys())
|
||||
|
||||
|
@ -609,7 +610,7 @@ class TestStoreImage(utils.BaseTestCase):
|
|||
|
||||
def test_image_checking_location_exists(self):
|
||||
UUID3 = 'a8a61ec4-d7a3-11e2-8c28-000c29c27581'
|
||||
self.assertEqual(len(self.store_api.data.keys()), 2)
|
||||
self.assertEqual(2, len(self.store_api.data.keys()))
|
||||
|
||||
context = glance.context.RequestContext(user=USER1)
|
||||
(image1, image_stub1) = self._add_image(context, UUID2, 'XXXX', 4)
|
||||
|
@ -630,7 +631,7 @@ class TestStoreImage(utils.BaseTestCase):
|
|||
|
||||
image3.delete()
|
||||
|
||||
self.assertEqual(len(self.store_api.data.keys()), 2)
|
||||
self.assertEqual(2, len(self.store_api.data.keys()))
|
||||
self.assertNotIn(UUID2, self.store_api.data.keys())
|
||||
self.assertNotIn(UUID3, self.store_api.data.keys())
|
||||
|
||||
|
@ -639,7 +640,7 @@ class TestStoreImage(utils.BaseTestCase):
|
|||
|
||||
def test_image_reverse_locations_order(self):
|
||||
UUID3 = 'a8a61ec4-d7a3-11e2-8c28-000c29c27581'
|
||||
self.assertEqual(len(self.store_api.data.keys()), 2)
|
||||
self.assertEqual(2, len(self.store_api.data.keys()))
|
||||
|
||||
context = glance.context.RequestContext(user=USER1)
|
||||
(image1, image_stub1) = self._add_image(context, UUID2, 'XXXX', 4)
|
||||
|
@ -655,12 +656,12 @@ class TestStoreImage(utils.BaseTestCase):
|
|||
|
||||
image_stub3.locations.reverse()
|
||||
|
||||
self.assertEqual(image_stub3.locations, [location3, location2])
|
||||
self.assertEqual(image3.locations, [location3, location2])
|
||||
self.assertEqual([location3, location2], image_stub3.locations)
|
||||
self.assertEqual([location3, location2], image3.locations)
|
||||
|
||||
image3.delete()
|
||||
|
||||
self.assertEqual(len(self.store_api.data.keys()), 2)
|
||||
self.assertEqual(2, len(self.store_api.data.keys()))
|
||||
self.assertNotIn(UUID2, self.store_api.data.keys())
|
||||
self.assertNotIn(UUID3, self.store_api.data.keys())
|
||||
|
||||
|
@ -689,17 +690,17 @@ class TestStoreImageRepo(utils.BaseTestCase):
|
|||
self.image_stub.visibility = 'public'
|
||||
self.image_repo.add(self.image)
|
||||
self.assertTrue(self.store_api.acls['foo']['public'])
|
||||
self.assertEqual(self.store_api.acls['foo']['read'], [])
|
||||
self.assertEqual(self.store_api.acls['foo']['write'], [])
|
||||
self.assertEqual([], self.store_api.acls['foo']['read'])
|
||||
self.assertEqual([], self.store_api.acls['foo']['write'])
|
||||
self.assertTrue(self.store_api.acls['bar']['public'])
|
||||
self.assertEqual(self.store_api.acls['bar']['read'], [])
|
||||
self.assertEqual(self.store_api.acls['bar']['write'], [])
|
||||
self.assertEqual([], self.store_api.acls['bar']['read'])
|
||||
self.assertEqual([], self.store_api.acls['bar']['write'])
|
||||
|
||||
def test_add_ignores_acls_if_no_locations(self):
|
||||
self.image_stub.locations = []
|
||||
self.image_stub.visibility = 'public'
|
||||
self.image_repo.add(self.image)
|
||||
self.assertEqual(len(self.store_api.acls), 0)
|
||||
self.assertEqual(0, len(self.store_api.acls))
|
||||
|
||||
def test_save_updates_acls(self):
|
||||
self.image_stub.locations = [{'url': 'foo', 'metadata': {},
|
||||
|
@ -715,8 +716,8 @@ class TestStoreImageRepo(utils.BaseTestCase):
|
|||
self.assertIn('glue', self.store_api.acls)
|
||||
acls = self.store_api.acls['glue']
|
||||
self.assertFalse(acls['public'])
|
||||
self.assertEqual(acls['write'], [])
|
||||
self.assertEqual(acls['read'], [TENANT1, TENANT2])
|
||||
self.assertEqual([], acls['write'])
|
||||
self.assertEqual([TENANT1, TENANT2], acls['read'])
|
||||
|
||||
def test_save_fetches_members_if_private(self):
|
||||
self.image_stub.locations = [{'url': 'glue', 'metadata': {},
|
||||
|
@ -726,8 +727,8 @@ class TestStoreImageRepo(utils.BaseTestCase):
|
|||
self.assertIn('glue', self.store_api.acls)
|
||||
acls = self.store_api.acls['glue']
|
||||
self.assertFalse(acls['public'])
|
||||
self.assertEqual(acls['write'], [])
|
||||
self.assertEqual(acls['read'], [TENANT1, TENANT2])
|
||||
self.assertEqual([], acls['write'])
|
||||
self.assertEqual([TENANT1, TENANT2], acls['read'])
|
||||
|
||||
def test_member_addition_updates_acls(self):
|
||||
self.image_stub.locations = [{'url': 'glug', 'metadata': {},
|
||||
|
@ -740,8 +741,8 @@ class TestStoreImageRepo(utils.BaseTestCase):
|
|||
self.assertIn('glug', self.store_api.acls)
|
||||
acls = self.store_api.acls['glug']
|
||||
self.assertFalse(acls['public'])
|
||||
self.assertEqual(acls['write'], [])
|
||||
self.assertEqual(acls['read'], [TENANT1, TENANT2, TENANT3])
|
||||
self.assertEqual([], acls['write'])
|
||||
self.assertEqual([TENANT1, TENANT2, TENANT3], acls['read'])
|
||||
|
||||
def test_member_removal_updates_acls(self):
|
||||
self.image_stub.locations = [{'url': 'glug', 'metadata': {},
|
||||
|
@ -754,8 +755,8 @@ class TestStoreImageRepo(utils.BaseTestCase):
|
|||
self.assertIn('glug', self.store_api.acls)
|
||||
acls = self.store_api.acls['glug']
|
||||
self.assertFalse(acls['public'])
|
||||
self.assertEqual(acls['write'], [])
|
||||
self.assertEqual(acls['read'], [TENANT2])
|
||||
self.assertEqual([], acls['write'])
|
||||
self.assertEqual([TENANT2], acls['read'])
|
||||
|
||||
|
||||
class TestImageFactory(utils.BaseTestCase):
|
||||
|
@ -774,14 +775,14 @@ class TestImageFactory(utils.BaseTestCase):
|
|||
image = self.image_factory.new_image()
|
||||
self.assertIsNone(image.image_id)
|
||||
self.assertIsNone(image.status)
|
||||
self.assertEqual(image.visibility, 'private')
|
||||
self.assertEqual(image.locations, [])
|
||||
self.assertEqual('private', image.visibility)
|
||||
self.assertEqual([], image.locations)
|
||||
|
||||
def test_new_image_with_location(self):
|
||||
locations = [{'url': '%s/%s' % (BASE_URI, UUID1),
|
||||
'metadata': {}}]
|
||||
image = self.image_factory.new_image(locations=locations)
|
||||
self.assertEqual(image.locations, locations)
|
||||
self.assertEqual(locations, image.locations)
|
||||
location_bad = {'url': 'unknown://location', 'metadata': {}}
|
||||
self.assertRaises(exception.BadStoreUri,
|
||||
self.image_factory.new_image,
|
||||
|
|
|
@ -30,8 +30,8 @@ class VersionsTest(base.IsolatedUnitTest):
|
|||
req.accept = 'application/json'
|
||||
self.config(bind_host='127.0.0.1', bind_port=9292)
|
||||
res = versions.Controller().index(req)
|
||||
self.assertEqual(res.status_int, 300)
|
||||
self.assertEqual(res.content_type, 'application/json')
|
||||
self.assertEqual(300, res.status_int)
|
||||
self.assertEqual('application/json', res.content_type)
|
||||
results = jsonutils.loads(res.body)['versions']
|
||||
expected = [
|
||||
{
|
||||
|
@ -65,7 +65,7 @@ class VersionsTest(base.IsolatedUnitTest):
|
|||
'href': 'http://127.0.0.1:9292/v1/'}],
|
||||
},
|
||||
]
|
||||
self.assertEqual(results, expected)
|
||||
self.assertEqual(expected, results)
|
||||
|
||||
|
||||
class VersionNegotiationTest(base.IsolatedUnitTest):
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -149,7 +149,7 @@ class TestRegistryAPI(base.IsolatedUnitTest, test_utils.RegistryAPIMixIn):
|
|||
res_dict = jsonutils.loads(res.body)
|
||||
|
||||
images = res_dict['images']
|
||||
self.assertEqual(len(images), 1)
|
||||
self.assertEqual(1, len(images))
|
||||
|
||||
for k, v in six.iteritems(fixture):
|
||||
self.assertEqual(v, images[0][k])
|
||||
|
@ -164,7 +164,7 @@ class TestRegistryAPI(base.IsolatedUnitTest, test_utils.RegistryAPIMixIn):
|
|||
res_dict = jsonutils.loads(res.body)
|
||||
|
||||
images = res_dict['images']
|
||||
self.assertEqual(len(images), 1)
|
||||
self.assertEqual(1, len(images))
|
||||
|
||||
for k, v in six.iteritems(fixture):
|
||||
self.assertEqual(v, images[0][k])
|
||||
|
@ -240,10 +240,10 @@ class TestRegistryAPI(base.IsolatedUnitTest, test_utils.RegistryAPIMixIn):
|
|||
res_dict = jsonutils.loads(res.body)
|
||||
|
||||
images = res_dict['images']
|
||||
self.assertEqual(len(images), 1)
|
||||
self.assertEqual(1, len(images))
|
||||
|
||||
# expect list to be sorted by created_at desc
|
||||
self.assertEqual(images[0]['id'], UUID4)
|
||||
self.assertEqual(UUID4, images[0]['id'])
|
||||
|
||||
def test_get_index_limit_negative(self):
|
||||
"""
|
||||
|
@ -300,9 +300,9 @@ class TestRegistryAPI(base.IsolatedUnitTest, test_utils.RegistryAPIMixIn):
|
|||
res = self.get_api_response_ext(200, url='/images?'
|
||||
'property-distro=ubuntu')
|
||||
images = jsonutils.loads(res.body)['images']
|
||||
self.assertEqual(len(images), 2)
|
||||
self.assertEqual(images[0]['id'], image2_id)
|
||||
self.assertEqual(images[1]['id'], image1_id)
|
||||
self.assertEqual(2, len(images))
|
||||
self.assertEqual(image2_id, images[0]['id'])
|
||||
self.assertEqual(image1_id, images[1]['id'])
|
||||
|
||||
# Test index with filter containing one user-defined property but
|
||||
# non-existent value. Filter is 'property-distro=fedora'.
|
||||
|
@ -310,7 +310,7 @@ class TestRegistryAPI(base.IsolatedUnitTest, test_utils.RegistryAPIMixIn):
|
|||
res = self.get_api_response_ext(200, url='/images?'
|
||||
'property-distro=fedora')
|
||||
images = jsonutils.loads(res.body)['images']
|
||||
self.assertEqual(len(images), 0)
|
||||
self.assertEqual(0, len(images))
|
||||
|
||||
# Test index with filter containing one user-defined property but
|
||||
# unique value. Filter is 'property-arch=i386'.
|
||||
|
@ -318,8 +318,8 @@ class TestRegistryAPI(base.IsolatedUnitTest, test_utils.RegistryAPIMixIn):
|
|||
res = self.get_api_response_ext(200, url='/images?'
|
||||
'property-arch=i386')
|
||||
images = jsonutils.loads(res.body)['images']
|
||||
self.assertEqual(len(images), 1)
|
||||
self.assertEqual(images[0]['id'], image1_id)
|
||||
self.assertEqual(1, len(images))
|
||||
self.assertEqual(image1_id, images[0]['id'])
|
||||
|
||||
# Test index with filter containing one user-defined property but
|
||||
# unique value. Filter is 'property-arch=x86_64'.
|
||||
|
@ -327,23 +327,23 @@ class TestRegistryAPI(base.IsolatedUnitTest, test_utils.RegistryAPIMixIn):
|
|||
res = self.get_api_response_ext(200, url='/images?'
|
||||
'property-arch=x86_64')
|
||||
images = jsonutils.loads(res.body)['images']
|
||||
self.assertEqual(len(images), 1)
|
||||
self.assertEqual(images[0]['id'], image2_id)
|
||||
self.assertEqual(1, len(images))
|
||||
self.assertEqual(image2_id, images[0]['id'])
|
||||
|
||||
# Test index with filter containing unique user-defined property.
|
||||
# Filter is 'property-foo=bar'.
|
||||
# Verify only image2 is returned.
|
||||
res = self.get_api_response_ext(200, url='/images?property-foo=bar')
|
||||
images = jsonutils.loads(res.body)['images']
|
||||
self.assertEqual(len(images), 1)
|
||||
self.assertEqual(images[0]['id'], image2_id)
|
||||
self.assertEqual(1, len(images))
|
||||
self.assertEqual(image2_id, images[0]['id'])
|
||||
|
||||
# Test index with filter containing unique user-defined property but
|
||||
# .value is non-existent. Filter is 'property-foo=baz'.
|
||||
# Verify neither images are returned.
|
||||
res = self.get_api_response_ext(200, url='/images?property-foo=baz')
|
||||
images = jsonutils.loads(res.body)['images']
|
||||
self.assertEqual(len(images), 0)
|
||||
self.assertEqual(0, len(images))
|
||||
|
||||
# Test index with filter containing multiple user-defined properties
|
||||
# Filter is 'property-arch=x86_64&property-distro=ubuntu'.
|
||||
|
@ -352,8 +352,8 @@ class TestRegistryAPI(base.IsolatedUnitTest, test_utils.RegistryAPIMixIn):
|
|||
'property-arch=x86_64&'
|
||||
'property-distro=ubuntu')
|
||||
images = jsonutils.loads(res.body)['images']
|
||||
self.assertEqual(len(images), 1)
|
||||
self.assertEqual(images[0]['id'], image2_id)
|
||||
self.assertEqual(1, len(images))
|
||||
self.assertEqual(image2_id, images[0]['id'])
|
||||
|
||||
# Test index with filter containing multiple user-defined properties
|
||||
# Filter is 'property-arch=i386&property-distro=ubuntu'.
|
||||
|
@ -361,8 +361,8 @@ class TestRegistryAPI(base.IsolatedUnitTest, test_utils.RegistryAPIMixIn):
|
|||
res = self.get_api_response_ext(200, url='/images?property-arch=i386&'
|
||||
'property-distro=ubuntu')
|
||||
images = jsonutils.loads(res.body)['images']
|
||||
self.assertEqual(len(images), 1)
|
||||
self.assertEqual(images[0]['id'], image1_id)
|
||||
self.assertEqual(1, len(images))
|
||||
self.assertEqual(image1_id, images[0]['id'])
|
||||
|
||||
# Test index with filter containing multiple user-defined properties.
|
||||
# Filter is 'property-arch=random&property-distro=ubuntu'.
|
||||
|
@ -371,7 +371,7 @@ class TestRegistryAPI(base.IsolatedUnitTest, test_utils.RegistryAPIMixIn):
|
|||
'property-arch=random&'
|
||||
'property-distro=ubuntu')
|
||||
images = jsonutils.loads(res.body)['images']
|
||||
self.assertEqual(len(images), 0)
|
||||
self.assertEqual(0, len(images))
|
||||
|
||||
# Test index with filter containing multiple user-defined properties.
|
||||
# Filter is 'property-arch=random&property-distro=random'.
|
||||
|
@ -380,7 +380,7 @@ class TestRegistryAPI(base.IsolatedUnitTest, test_utils.RegistryAPIMixIn):
|
|||
'property-arch=random&'
|
||||
'property-distro=random')
|
||||
images = jsonutils.loads(res.body)['images']
|
||||
self.assertEqual(len(images), 0)
|
||||
self.assertEqual(0, len(images))
|
||||
|
||||
# Test index with filter containing multiple user-defined properties.
|
||||
# Filter is 'property-boo=far&property-poo=far'.
|
||||
|
@ -388,7 +388,7 @@ class TestRegistryAPI(base.IsolatedUnitTest, test_utils.RegistryAPIMixIn):
|
|||
res = self.get_api_response_ext(200, url='/images?property-boo=far&'
|
||||
'property-poo=far')
|
||||
images = jsonutils.loads(res.body)['images']
|
||||
self.assertEqual(len(images), 0)
|
||||
self.assertEqual(0, len(images))
|
||||
|
||||
# Test index with filter containing multiple user-defined properties.
|
||||
# Filter is 'property-foo=bar&property-poo=far'.
|
||||
|
@ -396,7 +396,7 @@ class TestRegistryAPI(base.IsolatedUnitTest, test_utils.RegistryAPIMixIn):
|
|||
res = self.get_api_response_ext(200, url='/images?property-foo=bar&'
|
||||
'property-poo=far')
|
||||
images = jsonutils.loads(res.body)['images']
|
||||
self.assertEqual(len(images), 0)
|
||||
self.assertEqual(0, len(images))
|
||||
|
||||
def test_get_index_filter_name(self):
|
||||
"""
|
||||
|
@ -417,7 +417,7 @@ class TestRegistryAPI(base.IsolatedUnitTest, test_utils.RegistryAPIMixIn):
|
|||
res_dict = jsonutils.loads(res.body)
|
||||
|
||||
images = res_dict['images']
|
||||
self.assertEqual(len(images), 2)
|
||||
self.assertEqual(2, len(images))
|
||||
|
||||
for image in images:
|
||||
self.assertEqual('new name! #123', image['name'])
|
||||
|
@ -667,7 +667,7 @@ class TestRegistryAPI(base.IsolatedUnitTest, test_utils.RegistryAPIMixIn):
|
|||
res_dict = jsonutils.loads(res.body)
|
||||
|
||||
images = res_dict['images']
|
||||
self.assertEqual(len(images), 1)
|
||||
self.assertEqual(1, len(images))
|
||||
|
||||
for k, v in six.iteritems(fixture):
|
||||
self.assertEqual(v, images[0][k])
|
||||
|
@ -693,10 +693,10 @@ class TestRegistryAPI(base.IsolatedUnitTest, test_utils.RegistryAPIMixIn):
|
|||
res_dict = jsonutils.loads(res.body)
|
||||
|
||||
images = res_dict['images']
|
||||
self.assertEqual(len(images), 1)
|
||||
self.assertEqual(1, len(images))
|
||||
|
||||
# expect list to be sorted by created_at desc
|
||||
self.assertEqual(images[0]['id'], UUID2)
|
||||
self.assertEqual(UUID2, images[0]['id'])
|
||||
|
||||
def test_get_details_invalid_marker(self):
|
||||
"""
|
||||
|
@ -744,7 +744,7 @@ class TestRegistryAPI(base.IsolatedUnitTest, test_utils.RegistryAPIMixIn):
|
|||
res_dict = jsonutils.loads(res.body)
|
||||
|
||||
images = res_dict['images']
|
||||
self.assertEqual(len(images), 2)
|
||||
self.assertEqual(2, len(images))
|
||||
|
||||
for image in images:
|
||||
self.assertEqual('new name! #123', image['name'])
|
||||
|
@ -768,7 +768,7 @@ class TestRegistryAPI(base.IsolatedUnitTest, test_utils.RegistryAPIMixIn):
|
|||
res_dict = jsonutils.loads(res.body)
|
||||
|
||||
images = res_dict['images']
|
||||
self.assertEqual(len(images), 1)
|
||||
self.assertEqual(1, len(images))
|
||||
|
||||
for image in images:
|
||||
self.assertEqual('saving', image['status'])
|
||||
|
@ -793,7 +793,7 @@ class TestRegistryAPI(base.IsolatedUnitTest, test_utils.RegistryAPIMixIn):
|
|||
res_dict = jsonutils.loads(res.body)
|
||||
|
||||
images = res_dict['images']
|
||||
self.assertEqual(len(images), 2)
|
||||
self.assertEqual(2, len(images))
|
||||
|
||||
for image in images:
|
||||
self.assertEqual('ovf', image['container_format'])
|
||||
|
@ -816,7 +816,7 @@ class TestRegistryAPI(base.IsolatedUnitTest, test_utils.RegistryAPIMixIn):
|
|||
res_dict = jsonutils.loads(res.body)
|
||||
|
||||
images = res_dict['images']
|
||||
self.assertEqual(len(images), 1)
|
||||
self.assertEqual(1, len(images))
|
||||
|
||||
for image in images:
|
||||
self.assertEqual(7, image['min_disk'])
|
||||
|
@ -839,7 +839,7 @@ class TestRegistryAPI(base.IsolatedUnitTest, test_utils.RegistryAPIMixIn):
|
|||
res_dict = jsonutils.loads(res.body)
|
||||
|
||||
images = res_dict['images']
|
||||
self.assertEqual(len(images), 1)
|
||||
self.assertEqual(1, len(images))
|
||||
|
||||
for image in images:
|
||||
self.assertEqual(514, image['min_ram'])
|
||||
|
@ -863,7 +863,7 @@ class TestRegistryAPI(base.IsolatedUnitTest, test_utils.RegistryAPIMixIn):
|
|||
res_dict = jsonutils.loads(res.body)
|
||||
|
||||
images = res_dict['images']
|
||||
self.assertEqual(len(images), 2)
|
||||
self.assertEqual(2, len(images))
|
||||
|
||||
for image in images:
|
||||
self.assertEqual('vhd', image['disk_format'])
|
||||
|
@ -886,7 +886,7 @@ class TestRegistryAPI(base.IsolatedUnitTest, test_utils.RegistryAPIMixIn):
|
|||
res_dict = jsonutils.loads(res.body)
|
||||
|
||||
images = res_dict['images']
|
||||
self.assertEqual(len(images), 2)
|
||||
self.assertEqual(2, len(images))
|
||||
|
||||
for image in images:
|
||||
self.assertTrue(image['size'] >= 19)
|
||||
|
@ -909,7 +909,7 @@ class TestRegistryAPI(base.IsolatedUnitTest, test_utils.RegistryAPIMixIn):
|
|||
res_dict = jsonutils.loads(res.body)
|
||||
|
||||
images = res_dict['images']
|
||||
self.assertEqual(len(images), 2)
|
||||
self.assertEqual(2, len(images))
|
||||
|
||||
for image in images:
|
||||
self.assertTrue(image['size'] <= 19)
|
||||
|
@ -938,7 +938,7 @@ class TestRegistryAPI(base.IsolatedUnitTest, test_utils.RegistryAPIMixIn):
|
|||
res_dict = jsonutils.loads(res.body)
|
||||
|
||||
images = res_dict['images']
|
||||
self.assertEqual(len(images), 2)
|
||||
self.assertEqual(2, len(images))
|
||||
|
||||
for image in images:
|
||||
self.assertTrue(18 <= image['size'] <= 19)
|
||||
|
@ -1041,7 +1041,7 @@ class TestRegistryAPI(base.IsolatedUnitTest, test_utils.RegistryAPIMixIn):
|
|||
res_dict = jsonutils.loads(res.body)
|
||||
|
||||
images = res_dict['images']
|
||||
self.assertEqual(len(images), 1)
|
||||
self.assertEqual(1, len(images))
|
||||
|
||||
for image in images:
|
||||
self.assertEqual('v a', image['properties']['prop_123'])
|
||||
|
@ -1061,7 +1061,7 @@ class TestRegistryAPI(base.IsolatedUnitTest, test_utils.RegistryAPIMixIn):
|
|||
res_dict = jsonutils.loads(res.body)
|
||||
|
||||
images = res_dict['images']
|
||||
self.assertEqual(len(images), 3)
|
||||
self.assertEqual(3, len(images))
|
||||
|
||||
def test_get_details_filter_public_false(self):
|
||||
"""
|
||||
|
@ -1078,7 +1078,7 @@ class TestRegistryAPI(base.IsolatedUnitTest, test_utils.RegistryAPIMixIn):
|
|||
res_dict = jsonutils.loads(res.body)
|
||||
|
||||
images = res_dict['images']
|
||||
self.assertEqual(len(images), 2)
|
||||
self.assertEqual(2, len(images))
|
||||
|
||||
for image in images:
|
||||
self.assertEqual(False, image['is_public'])
|
||||
|
@ -1098,7 +1098,7 @@ class TestRegistryAPI(base.IsolatedUnitTest, test_utils.RegistryAPIMixIn):
|
|||
res_dict = jsonutils.loads(res.body)
|
||||
|
||||
images = res_dict['images']
|
||||
self.assertEqual(len(images), 1)
|
||||
self.assertEqual(1, len(images))
|
||||
|
||||
for image in images:
|
||||
self.assertTrue(image['is_public'])
|
||||
|
@ -1158,7 +1158,7 @@ class TestRegistryAPI(base.IsolatedUnitTest, test_utils.RegistryAPIMixIn):
|
|||
res_dict = jsonutils.loads(res.body)
|
||||
|
||||
images = res_dict['images']
|
||||
self.assertEqual(len(images), 1)
|
||||
self.assertEqual(1, len(images))
|
||||
# Check that for non admin user only is_public = True images returns
|
||||
for image in images:
|
||||
self.assertTrue(image['is_public'])
|
||||
|
@ -1829,7 +1829,7 @@ class TestRegistryAPILocations(base.IsolatedUnitTest,
|
|||
def test_show_from_locations(self):
|
||||
req = webob.Request.blank('/images/%s' % UUID1)
|
||||
res = req.get_response(self.api)
|
||||
self.assertEqual(res.status_int, 200)
|
||||
self.assertEqual(200, res.status_int)
|
||||
res_dict = jsonutils.loads(res.body)
|
||||
image = res_dict['image']
|
||||
self.assertIn('id', image['location_data'][0])
|
||||
|
@ -1844,7 +1844,7 @@ class TestRegistryAPILocations(base.IsolatedUnitTest,
|
|||
def test_show_from_location_data(self):
|
||||
req = webob.Request.blank('/images/%s' % UUID2)
|
||||
res = req.get_response(self.api)
|
||||
self.assertEqual(res.status_int, 200)
|
||||
self.assertEqual(200, res.status_int)
|
||||
res_dict = jsonutils.loads(res.body)
|
||||
image = res_dict['image']
|
||||
self.assertIn('id', image['location_data'][0])
|
||||
|
@ -1888,13 +1888,13 @@ class TestRegistryAPILocations(base.IsolatedUnitTest,
|
|||
req.body = jsonutils.dumps(dict(image=fixture))
|
||||
|
||||
res = req.get_response(self.api)
|
||||
self.assertEqual(res.status_int, 200)
|
||||
self.assertEqual(200, res.status_int)
|
||||
res_dict = jsonutils.loads(res.body)
|
||||
image = res_dict['image']
|
||||
# NOTE(zhiyan) _normalize_image_location_for_db() function will
|
||||
# not re-encrypted the url within location.
|
||||
self.assertEqual(fixture['location'], image['location'])
|
||||
self.assertEqual(len(image['location_data']), 2)
|
||||
self.assertEqual(2, len(image['location_data']))
|
||||
self.assertEqual(fixture['location_data'][0]['url'],
|
||||
image['location_data'][0]['url'])
|
||||
self.assertEqual(fixture['location_data'][0]['metadata'],
|
||||
|
|
|
@ -321,7 +321,7 @@ class TestRegistryV1Client(base.IsolatedUnitTest, test_utils.RegistryAPIMixIn):
|
|||
db_api.image_create(self.context, extra_fixture)
|
||||
|
||||
images = self.client.get_images(limit=2)
|
||||
self.assertEqual(len(images), 2)
|
||||
self.assertEqual(2, len(images))
|
||||
|
||||
def test_get_image_index_marker_limit(self):
|
||||
"""Test correct set of images returned with marker/limit params."""
|
||||
|
@ -352,7 +352,7 @@ class TestRegistryV1Client(base.IsolatedUnitTest, test_utils.RegistryAPIMixIn):
|
|||
db_api.image_create(self.context, extra_fixture)
|
||||
|
||||
images = self.client.get_images(limit=None)
|
||||
self.assertEqual(len(images), 3)
|
||||
self.assertEqual(3, len(images))
|
||||
|
||||
def test_get_image_index_by_name(self):
|
||||
"""
|
||||
|
@ -364,7 +364,7 @@ class TestRegistryV1Client(base.IsolatedUnitTest, test_utils.RegistryAPIMixIn):
|
|||
db_api.image_create(self.context, extra_fixture)
|
||||
|
||||
images = self.client.get_images(filters={'name': 'new name! #123'})
|
||||
self.assertEqual(len(images), 1)
|
||||
self.assertEqual(1, len(images))
|
||||
|
||||
for image in images:
|
||||
self.assertEqual('new name! #123', image['name'])
|
||||
|
@ -376,7 +376,7 @@ class TestRegistryV1Client(base.IsolatedUnitTest, test_utils.RegistryAPIMixIn):
|
|||
|
||||
images = self.client.get_images_detailed()
|
||||
|
||||
self.assertEqual(len(images), 1)
|
||||
self.assertEqual(1, len(images))
|
||||
for k, v in fixture.items():
|
||||
self.assertEqual(v, images[0][k])
|
||||
|
||||
|
@ -442,7 +442,7 @@ class TestRegistryV1Client(base.IsolatedUnitTest, test_utils.RegistryAPIMixIn):
|
|||
filters = {'name': 'new name! #123'}
|
||||
images = self.client.get_images_detailed(filters=filters)
|
||||
|
||||
self.assertEqual(len(images), 1)
|
||||
self.assertEqual(1, len(images))
|
||||
for image in images:
|
||||
self.assertEqual('new name! #123', image['name'])
|
||||
|
||||
|
@ -454,7 +454,7 @@ class TestRegistryV1Client(base.IsolatedUnitTest, test_utils.RegistryAPIMixIn):
|
|||
|
||||
images = self.client.get_images_detailed(filters={'status': 'saving'})
|
||||
|
||||
self.assertEqual(len(images), 1)
|
||||
self.assertEqual(1, len(images))
|
||||
for image in images:
|
||||
self.assertEqual('saving', image['status'])
|
||||
|
||||
|
@ -467,7 +467,7 @@ class TestRegistryV1Client(base.IsolatedUnitTest, test_utils.RegistryAPIMixIn):
|
|||
filters = {'container_format': 'ovf'}
|
||||
images = self.client.get_images_detailed(filters=filters)
|
||||
|
||||
self.assertEqual(len(images), 2)
|
||||
self.assertEqual(2, len(images))
|
||||
for image in images:
|
||||
self.assertEqual('ovf', image['container_format'])
|
||||
|
||||
|
@ -480,7 +480,7 @@ class TestRegistryV1Client(base.IsolatedUnitTest, test_utils.RegistryAPIMixIn):
|
|||
filters = {'disk_format': 'vhd'}
|
||||
images = self.client.get_images_detailed(filters=filters)
|
||||
|
||||
self.assertEqual(len(images), 2)
|
||||
self.assertEqual(2, len(images))
|
||||
for image in images:
|
||||
self.assertEqual('vhd', image['disk_format'])
|
||||
|
||||
|
@ -493,7 +493,7 @@ class TestRegistryV1Client(base.IsolatedUnitTest, test_utils.RegistryAPIMixIn):
|
|||
|
||||
images = self.client.get_images_detailed(filters={'size_max': 20})
|
||||
|
||||
self.assertEqual(len(images), 1)
|
||||
self.assertEqual(1, len(images))
|
||||
for image in images:
|
||||
self.assertTrue(image['size'] <= 20)
|
||||
|
||||
|
@ -505,7 +505,7 @@ class TestRegistryV1Client(base.IsolatedUnitTest, test_utils.RegistryAPIMixIn):
|
|||
|
||||
images = self.client.get_images_detailed(filters={'size_min': 20})
|
||||
|
||||
self.assertEqual(len(images), 1)
|
||||
self.assertEqual(1, len(images))
|
||||
for image in images:
|
||||
self.assertTrue(image['size'] >= 20)
|
||||
|
||||
|
@ -560,7 +560,7 @@ class TestRegistryV1Client(base.IsolatedUnitTest, test_utils.RegistryAPIMixIn):
|
|||
db_api.image_create(self.context, extra_fixture)
|
||||
|
||||
images = self.client.get_images_detailed(filters={'size_min': 20})
|
||||
self.assertEqual(len(images), 1)
|
||||
self.assertEqual(1, len(images))
|
||||
|
||||
for image in images:
|
||||
self.assertTrue(image['size'] >= 20)
|
||||
|
@ -574,7 +574,7 @@ class TestRegistryV1Client(base.IsolatedUnitTest, test_utils.RegistryAPIMixIn):
|
|||
|
||||
filters = {'property-p a': 'v a'}
|
||||
images = self.client.get_images_detailed(filters=filters)
|
||||
self.assertEqual(len(images), 1)
|
||||
self.assertEqual(1, len(images))
|
||||
|
||||
for image in images:
|
||||
self.assertEqual('v a', image['properties']['p a'])
|
||||
|
@ -589,7 +589,7 @@ class TestRegistryV1Client(base.IsolatedUnitTest, test_utils.RegistryAPIMixIn):
|
|||
|
||||
filters = {'property-is_public': 'avalue'}
|
||||
images = self.client.get_images_detailed(filters=filters)
|
||||
self.assertEqual(len(images), 1)
|
||||
self.assertEqual(1, len(images))
|
||||
|
||||
for image in images:
|
||||
self.assertEqual('avalue', image['properties']['is_public'])
|
||||
|
@ -683,9 +683,9 @@ class TestRegistryV1Client(base.IsolatedUnitTest, test_utils.RegistryAPIMixIn):
|
|||
|
||||
new_image = self.client.add_image(fixture)
|
||||
|
||||
self.assertEqual(new_image['location'], location)
|
||||
self.assertEqual(new_image['location_data'][0]['url'], location)
|
||||
self.assertEqual(new_image['location_data'][0]['metadata'], loc_meta)
|
||||
self.assertEqual(location, new_image['location'])
|
||||
self.assertEqual(location, new_image['location_data'][0]['url'])
|
||||
self.assertEqual(loc_meta, new_image['location_data'][0]['metadata'])
|
||||
|
||||
def test_add_image_with_location_data_with_encryption(self):
|
||||
"""Tests that we can add image metadata with properties and
|
||||
|
@ -710,12 +710,12 @@ class TestRegistryV1Client(base.IsolatedUnitTest, test_utils.RegistryAPIMixIn):
|
|||
|
||||
new_image = self.client.add_image(fixture)
|
||||
|
||||
self.assertEqual(new_image['location'], location % 1)
|
||||
self.assertEqual(len(new_image['location_data']), 2)
|
||||
self.assertEqual(new_image['location_data'][0]['url'], location % 1)
|
||||
self.assertEqual(new_image['location_data'][0]['metadata'], loc_meta)
|
||||
self.assertEqual(new_image['location_data'][1]['url'], location % 2)
|
||||
self.assertEqual(new_image['location_data'][1]['metadata'], {})
|
||||
self.assertEqual(location % 1, new_image['location'])
|
||||
self.assertEqual(2, len(new_image['location_data']))
|
||||
self.assertEqual(location % 1, new_image['location_data'][0]['url'])
|
||||
self.assertEqual(loc_meta, new_image['location_data'][0]['metadata'])
|
||||
self.assertEqual(location % 2, new_image['location_data'][1]['url'])
|
||||
self.assertEqual({}, new_image['location_data'][1]['metadata'])
|
||||
|
||||
self.client.metadata_encryption_key = None
|
||||
|
||||
|
@ -787,7 +787,7 @@ class TestRegistryV1Client(base.IsolatedUnitTest, test_utils.RegistryAPIMixIn):
|
|||
"""Test getting image members."""
|
||||
memb_list = self.client.get_image_members(UUID2)
|
||||
num_members = len(memb_list)
|
||||
self.assertEqual(num_members, 0)
|
||||
self.assertEqual(0, num_members)
|
||||
|
||||
def test_get_image_members_not_existing(self):
|
||||
"""Test getting non-existent image members."""
|
||||
|
@ -799,7 +799,7 @@ class TestRegistryV1Client(base.IsolatedUnitTest, test_utils.RegistryAPIMixIn):
|
|||
"""Test getting member images."""
|
||||
memb_list = self.client.get_member_images('pattieblack')
|
||||
num_members = len(memb_list)
|
||||
self.assertEqual(num_members, 0)
|
||||
self.assertEqual(0, num_members)
|
||||
|
||||
def test_add_replace_members(self):
|
||||
"""Test replacing image members."""
|
||||
|
@ -862,8 +862,8 @@ class TestRegistryV1ClientApi(base.IsolatedUnitTest):
|
|||
'X-Service-Catalog': 'null',
|
||||
}
|
||||
actual_client = rapi.get_registry_client(self.context)
|
||||
self.assertEqual(actual_client.identity_headers,
|
||||
expected_identity_headers)
|
||||
self.assertEqual(expected_identity_headers,
|
||||
actual_client.identity_headers)
|
||||
|
||||
def test_configure_registry_client_not_using_use_user_token(self):
|
||||
self.config(use_user_token=False)
|
||||
|
@ -894,7 +894,7 @@ class TestRegistryV1ClientApi(base.IsolatedUnitTest):
|
|||
|
||||
self.assertIsNone(rapi._CLIENT_CREDS)
|
||||
rapi.configure_registry_admin_creds()
|
||||
self.assertEqual(rapi._CLIENT_CREDS, expected)
|
||||
self.assertEqual(expected, rapi._CLIENT_CREDS)
|
||||
|
||||
def test_configure_registry_admin_creds_with_auth_url(self):
|
||||
expected = self._get_fake_config_creds()
|
||||
|
@ -907,7 +907,7 @@ class TestRegistryV1ClientApi(base.IsolatedUnitTest):
|
|||
|
||||
self.assertIsNone(rapi._CLIENT_CREDS)
|
||||
rapi.configure_registry_admin_creds()
|
||||
self.assertEqual(rapi._CLIENT_CREDS, expected)
|
||||
self.assertEqual(expected, rapi._CLIENT_CREDS)
|
||||
|
||||
|
||||
class FakeResponse():
|
||||
|
|
|
@ -108,7 +108,7 @@ class TestImagesController(base.StoreClearingUnitTest):
|
|||
'metadata': {}, 'status': 'active'}])
|
||||
self.image_repo.result = image
|
||||
image = self.controller.download(request, unit_test_utils.UUID1)
|
||||
self.assertEqual(image.image_id, 'abcd')
|
||||
self.assertEqual('abcd', image.image_id)
|
||||
|
||||
def test_download_no_location(self):
|
||||
request = unit_test_utils.get_fake_request()
|
||||
|
@ -145,8 +145,8 @@ class TestImagesController(base.StoreClearingUnitTest):
|
|||
image = FakeImage('abcd')
|
||||
self.image_repo.result = image
|
||||
self.controller.upload(request, unit_test_utils.UUID2, 'YYYY', 4)
|
||||
self.assertEqual(image.data, 'YYYY')
|
||||
self.assertEqual(image.size, 4)
|
||||
self.assertEqual('YYYY', image.data)
|
||||
self.assertEqual(4, image.size)
|
||||
|
||||
def test_upload_status(self):
|
||||
request = unit_test_utils.get_fake_request()
|
||||
|
@ -156,21 +156,21 @@ class TestImagesController(base.StoreClearingUnitTest):
|
|||
|
||||
def read_data():
|
||||
insurance['called'] = True
|
||||
self.assertEqual(self.image_repo.saved_image.status, 'saving')
|
||||
self.assertEqual('saving', self.image_repo.saved_image.status)
|
||||
yield 'YYYY'
|
||||
|
||||
self.controller.upload(request, unit_test_utils.UUID2,
|
||||
read_data(), None)
|
||||
self.assertTrue(insurance['called'])
|
||||
self.assertEqual(self.image_repo.saved_image.status,
|
||||
'modified-by-fake')
|
||||
self.assertEqual('modified-by-fake',
|
||||
self.image_repo.saved_image.status)
|
||||
|
||||
def test_upload_no_size(self):
|
||||
request = unit_test_utils.get_fake_request()
|
||||
image = FakeImage('abcd')
|
||||
self.image_repo.result = image
|
||||
self.controller.upload(request, unit_test_utils.UUID2, 'YYYY', None)
|
||||
self.assertEqual(image.data, 'YYYY')
|
||||
self.assertEqual('YYYY', image.data)
|
||||
self.assertIsNone(image.size)
|
||||
|
||||
def test_upload_invalid(self):
|
||||
|
@ -301,7 +301,7 @@ class TestImagesController(base.StoreClearingUnitTest):
|
|||
'event_type': "image.prepare",
|
||||
'payload': prepare_payload,
|
||||
}
|
||||
self.assertEqual(len(output_log), 3)
|
||||
self.assertEqual(3, len(output_log))
|
||||
prepare_updated_at = output_log[0]['payload']['updated_at']
|
||||
del output_log[0]['payload']['updated_at']
|
||||
self.assertTrue(prepare_updated_at <= output['meta']['updated_at'])
|
||||
|
@ -318,7 +318,7 @@ class TestImagesController(base.StoreClearingUnitTest):
|
|||
'event_type': "image.upload",
|
||||
'payload': upload_payload,
|
||||
}
|
||||
self.assertEqual(len(output_log), 3)
|
||||
self.assertEqual(3, len(output_log))
|
||||
self.assertEqual(output_log[1], upload_log)
|
||||
|
||||
def _test_upload_download_activate_notification(self):
|
||||
|
@ -332,7 +332,7 @@ class TestImagesController(base.StoreClearingUnitTest):
|
|||
'event_type': "image.activate",
|
||||
'payload': activate_payload,
|
||||
}
|
||||
self.assertEqual(len(output_log), 3)
|
||||
self.assertEqual(3, len(output_log))
|
||||
self.assertEqual(output_log[2], activate_log)
|
||||
|
||||
def test_restore_image_when_upload_failed(self):
|
||||
|
@ -343,7 +343,7 @@ class TestImagesController(base.StoreClearingUnitTest):
|
|||
self.assertRaises(webob.exc.HTTPServiceUnavailable,
|
||||
self.controller.upload,
|
||||
request, unit_test_utils.UUID2, 'ZZZ', 3)
|
||||
self.assertEqual(self.image_repo.saved_image.status, 'queued')
|
||||
self.assertEqual('queued', self.image_repo.saved_image.status)
|
||||
|
||||
|
||||
class TestImageDataDeserializer(test_utils.BaseTestCase):
|
||||
|
@ -359,7 +359,7 @@ class TestImageDataDeserializer(test_utils.BaseTestCase):
|
|||
request.headers['Content-Length'] = 3
|
||||
output = self.deserializer.upload(request)
|
||||
data = output.pop('data')
|
||||
self.assertEqual(data.read(), 'YYY')
|
||||
self.assertEqual('YYY', data.read())
|
||||
expected = {'size': 3}
|
||||
self.assertEqual(expected, output)
|
||||
|
||||
|
@ -371,7 +371,7 @@ class TestImageDataDeserializer(test_utils.BaseTestCase):
|
|||
request.body_file = six.StringIO('YYY')
|
||||
output = self.deserializer.upload(request)
|
||||
data = output.pop('data')
|
||||
self.assertEqual(data.read(), 'YYY')
|
||||
self.assertEqual('YYY', data.read())
|
||||
expected = {'size': None}
|
||||
self.assertEqual(expected, output)
|
||||
|
||||
|
@ -384,7 +384,7 @@ class TestImageDataDeserializer(test_utils.BaseTestCase):
|
|||
request.headers['Content-Length'] = 3
|
||||
output = self.deserializer.upload(request)
|
||||
data = output.pop('data')
|
||||
self.assertEqual(data.read(), 'YYY')
|
||||
self.assertEqual('YYY', data.read())
|
||||
expected = {'size': 3}
|
||||
self.assertEqual(expected, output)
|
||||
|
||||
|
@ -398,7 +398,7 @@ class TestImageDataDeserializer(test_utils.BaseTestCase):
|
|||
request.headers['Content-Length'] = 4
|
||||
output = self.deserializer.upload(request)
|
||||
data = output.pop('data')
|
||||
self.assertEqual(data.read(), 'YYY')
|
||||
self.assertEqual('YYY', data.read())
|
||||
expected = {'size': 4}
|
||||
self.assertEqual(expected, output)
|
||||
|
||||
|
|
|
@ -136,7 +136,7 @@ class TestImageMembersController(test_utils.BaseTestCase):
|
|||
actual = set([image_member.member_id
|
||||
for image_member in output['members']])
|
||||
expected = set([TENANT4])
|
||||
self.assertEqual(actual, expected)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_index_no_members(self):
|
||||
request = unit_test_utils.get_fake_request()
|
||||
|
@ -154,7 +154,7 @@ class TestImageMembersController(test_utils.BaseTestCase):
|
|||
actual = set([image_member.member_id
|
||||
for image_member in output['members']])
|
||||
expected = set([TENANT4])
|
||||
self.assertEqual(actual, expected)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_index_private_image(self):
|
||||
request = unit_test_utils.get_fake_request(tenant=TENANT2)
|
||||
|
@ -173,7 +173,7 @@ class TestImageMembersController(test_utils.BaseTestCase):
|
|||
actual = set([image_member.member_id
|
||||
for image_member in output['members']])
|
||||
expected = set([TENANT1])
|
||||
self.assertEqual(actual, expected)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_index_allowed_by_get_members_policy(self):
|
||||
rules = {"get_members": True}
|
||||
|
@ -193,17 +193,17 @@ class TestImageMembersController(test_utils.BaseTestCase):
|
|||
request = unit_test_utils.get_fake_request(tenant=TENANT1)
|
||||
output = self.controller.show(request, UUID2, TENANT4)
|
||||
expected = self.image_members[0]
|
||||
self.assertEqual(output.image_id, expected['image_id'])
|
||||
self.assertEqual(output.member_id, expected['member'])
|
||||
self.assertEqual(output.status, expected['status'])
|
||||
self.assertEqual(expected['image_id'], output.image_id)
|
||||
self.assertEqual(expected['member'], output.member_id)
|
||||
self.assertEqual(expected['status'], output.status)
|
||||
|
||||
def test_show_by_member(self):
|
||||
request = unit_test_utils.get_fake_request(tenant=TENANT4)
|
||||
output = self.controller.show(request, UUID2, TENANT4)
|
||||
expected = self.image_members[0]
|
||||
self.assertEqual(output.image_id, expected['image_id'])
|
||||
self.assertEqual(output.member_id, expected['member'])
|
||||
self.assertEqual(output.status, expected['status'])
|
||||
self.assertEqual(expected['image_id'], output.image_id)
|
||||
self.assertEqual(expected['member'], output.member_id)
|
||||
self.assertEqual(expected['status'], output.status)
|
||||
|
||||
def test_show_forbidden(self):
|
||||
request = unit_test_utils.get_fake_request(tenant=TENANT2)
|
||||
|
@ -340,11 +340,11 @@ class TestImageMembersController(test_utils.BaseTestCase):
|
|||
member_id = TENANT4
|
||||
image_id = UUID2
|
||||
res = self.controller.delete(request, image_id, member_id)
|
||||
self.assertEqual(res.body, '')
|
||||
self.assertEqual(res.status_code, 204)
|
||||
self.assertEqual('', res.body)
|
||||
self.assertEqual(204, res.status_code)
|
||||
found_member = self.db.image_member_find(
|
||||
request.context, image_id=image_id, member=member_id)
|
||||
self.assertEqual(found_member, [])
|
||||
self.assertEqual([], found_member)
|
||||
|
||||
def test_delete_by_member(self):
|
||||
request = unit_test_utils.get_fake_request(tenant=TENANT4)
|
||||
|
@ -356,7 +356,7 @@ class TestImageMembersController(test_utils.BaseTestCase):
|
|||
actual = set([image_member.member_id
|
||||
for image_member in output['members']])
|
||||
expected = set([TENANT4])
|
||||
self.assertEqual(actual, expected)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_delete_allowed_by_policies(self):
|
||||
rules = {"get_member": True, "delete_member": True}
|
||||
|
@ -405,7 +405,7 @@ class TestImageMembersController(test_utils.BaseTestCase):
|
|||
image_id = UUID2
|
||||
found_member = self.db.image_member_find(
|
||||
request.context, image_id=image_id, member=member_id)
|
||||
self.assertEqual(found_member, [])
|
||||
self.assertEqual([], found_member)
|
||||
self.assertRaises(webob.exc.HTTPNotFound, self.controller.delete,
|
||||
request, image_id, member_id)
|
||||
|
||||
|
|
|
@ -175,7 +175,7 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
self.assertEqual(1, len(output['images']))
|
||||
actual = set([image.image_id for image in output['images']])
|
||||
expected = set([UUID3])
|
||||
self.assertEqual(actual, expected)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_index_member_status_accepted(self):
|
||||
self.config(limit_param_default=5, api_limit_max=5)
|
||||
|
@ -185,14 +185,14 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
actual = set([image.image_id for image in output['images']])
|
||||
expected = set([UUID1, UUID2, UUID3])
|
||||
# can see only the public image
|
||||
self.assertEqual(actual, expected)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
request = unit_test_utils.get_fake_request(tenant=TENANT3)
|
||||
output = self.controller.index(request)
|
||||
self.assertEqual(4, len(output['images']))
|
||||
actual = set([image.image_id for image in output['images']])
|
||||
expected = set([UUID1, UUID2, UUID3, UUID4])
|
||||
self.assertEqual(actual, expected)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_index_admin(self):
|
||||
request = unit_test_utils.get_fake_request(is_admin=True)
|
||||
|
@ -206,7 +206,7 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
self.assertEqual(3, len(output['images']))
|
||||
actual = set([image.image_id for image in output['images']])
|
||||
expected = set([UUID2, UUID3, UUID4])
|
||||
self.assertEqual(actual, expected)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_index_return_parameters(self):
|
||||
self.config(limit_param_default=1, api_limit_max=3)
|
||||
|
@ -226,7 +226,7 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
self.assertEqual(2, len(output['images']))
|
||||
actual = set([image.image_id for image in output['images']])
|
||||
expected = set([UUID2, UUID1])
|
||||
self.assertEqual(actual, expected)
|
||||
self.assertEqual(expected, actual)
|
||||
self.assertEqual(UUID1, output['next_marker'])
|
||||
|
||||
def test_index_no_next_marker(self):
|
||||
|
@ -236,7 +236,7 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
self.assertEqual(0, len(output['images']))
|
||||
actual = set([image.image_id for image in output['images']])
|
||||
expected = set([])
|
||||
self.assertEqual(actual, expected)
|
||||
self.assertEqual(expected, actual)
|
||||
self.assertNotIn('next_marker', output)
|
||||
|
||||
def test_index_with_id_filter(self):
|
||||
|
@ -245,7 +245,7 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
self.assertEqual(1, len(output['images']))
|
||||
actual = set([image.image_id for image in output['images']])
|
||||
expected = set([UUID1])
|
||||
self.assertEqual(actual, expected)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_index_with_checksum_filter_single_image(self):
|
||||
req = unit_test_utils.get_fake_request('/images?checksum=%s' % CHKSUM)
|
||||
|
@ -253,7 +253,7 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
self.assertEqual(1, len(output['images']))
|
||||
actual = list([image.image_id for image in output['images']])
|
||||
expected = [UUID1]
|
||||
self.assertEqual(actual, expected)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_index_with_checksum_filter_multiple_images(self):
|
||||
req = unit_test_utils.get_fake_request('/images?checksum=%s' % CHKSUM1)
|
||||
|
@ -261,7 +261,7 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
self.assertEqual(2, len(output['images']))
|
||||
actual = list([image.image_id for image in output['images']])
|
||||
expected = [UUID3, UUID2]
|
||||
self.assertEqual(actual, expected)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_index_with_non_existent_checksum(self):
|
||||
req = unit_test_utils.get_fake_request('/images?checksum=236231827')
|
||||
|
@ -274,7 +274,7 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
self.assertEqual(3, len(output['images']))
|
||||
actual = set([image.image_id for image in output['images']])
|
||||
expected = set([UUID1, UUID2, UUID3])
|
||||
self.assertEqual(actual, expected)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_index_size_min_filter(self):
|
||||
request = unit_test_utils.get_fake_request('/images?size_min=512')
|
||||
|
@ -282,7 +282,7 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
self.assertEqual(2, len(output['images']))
|
||||
actual = set([image.image_id for image in output['images']])
|
||||
expected = set([UUID2, UUID3])
|
||||
self.assertEqual(actual, expected)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_index_size_range_filter(self):
|
||||
path = '/images?size_min=512&size_max=512'
|
||||
|
@ -293,7 +293,7 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
self.assertEqual(2, len(output['images']))
|
||||
actual = set([image.image_id for image in output['images']])
|
||||
expected = set([UUID2, UUID3])
|
||||
self.assertEqual(actual, expected)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_index_virtual_size_max_filter(self):
|
||||
ref = '/images?virtual_size_max=2048'
|
||||
|
@ -303,7 +303,7 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
self.assertEqual(3, len(output['images']))
|
||||
actual = set([image.image_id for image in output['images']])
|
||||
expected = set([UUID1, UUID2, UUID3])
|
||||
self.assertEqual(actual, expected)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_index_virtual_size_min_filter(self):
|
||||
ref = '/images?virtual_size_min=2048'
|
||||
|
@ -313,7 +313,7 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
self.assertEqual(2, len(output['images']))
|
||||
actual = set([image.image_id for image in output['images']])
|
||||
expected = set([UUID2, UUID3])
|
||||
self.assertEqual(actual, expected)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_index_virtual_size_range_filter(self):
|
||||
path = '/images?virtual_size_min=512&virtual_size_max=2048'
|
||||
|
@ -324,7 +324,7 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
self.assertEqual(2, len(output['images']))
|
||||
actual = set([image.image_id for image in output['images']])
|
||||
expected = set([UUID2, UUID3])
|
||||
self.assertEqual(actual, expected)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_index_with_invalid_max_range_filter_value(self):
|
||||
request = unit_test_utils.get_fake_request('/images?size_max=blah')
|
||||
|
@ -340,7 +340,7 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
self.assertEqual(1, len(output['images']))
|
||||
actual = set([image.image_id for image in output['images']])
|
||||
expected = set([UUID3])
|
||||
self.assertEqual(actual, expected)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_index_with_nonexistent_name_filter(self):
|
||||
request = unit_test_utils.get_fake_request('/images?name=%s' % 'blah')
|
||||
|
@ -370,7 +370,7 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
self.assertEqual(1, len(output['images']))
|
||||
actual = set([image.image_id for image in output['images']])
|
||||
expected = set([UUID3])
|
||||
self.assertEqual(actual, expected)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_index_with_marker(self):
|
||||
self.config(limit_param_default=1, api_limit_max=3)
|
||||
|
@ -513,7 +513,7 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
output = self.controller.index(request,
|
||||
filters={'abc': 'xyz',
|
||||
'pudding': 'banana'})
|
||||
self.assertEqual(len(output['images']), 0)
|
||||
self.assertEqual(0, len(output['images']))
|
||||
|
||||
def test_index_with_non_existent_tags(self):
|
||||
path = '/images?tag=fake'
|
||||
|
@ -545,7 +545,7 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
|
||||
request = unit_test_utils.get_fake_request()
|
||||
output = self.controller.show(request, image['id'])
|
||||
self.assertEqual(output.extra_properties['yin'], 'yang')
|
||||
self.assertEqual('yang', output.extra_properties['yin'])
|
||||
|
||||
def test_show_non_existent(self):
|
||||
request = unit_test_utils.get_fake_request()
|
||||
|
@ -561,7 +561,7 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
|
||||
def test_show_not_allowed(self):
|
||||
request = unit_test_utils.get_fake_request()
|
||||
self.assertEqual(request.context.tenant, TENANT1)
|
||||
self.assertEqual(TENANT1, request.context.tenant)
|
||||
self.assertRaises(webob.exc.HTTPNotFound,
|
||||
self.controller.show, request, UUID4)
|
||||
|
||||
|
@ -576,11 +576,11 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
self.assertEqual(set([]), output.tags)
|
||||
self.assertEqual('private', output.visibility)
|
||||
output_logs = self.notifier.get_logs()
|
||||
self.assertEqual(len(output_logs), 1)
|
||||
self.assertEqual(1, len(output_logs))
|
||||
output_log = output_logs[0]
|
||||
self.assertEqual(output_log['notification_type'], 'INFO')
|
||||
self.assertEqual(output_log['event_type'], 'image.create')
|
||||
self.assertEqual(output_log['payload']['name'], 'image-1')
|
||||
self.assertEqual('INFO', output_log['notification_type'])
|
||||
self.assertEqual('image.create', output_log['event_type'])
|
||||
self.assertEqual('image-1', output_log['payload']['name'])
|
||||
|
||||
def test_create_with_properties(self):
|
||||
request = unit_test_utils.get_fake_request()
|
||||
|
@ -594,11 +594,11 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
self.assertEqual(set([]), output.tags)
|
||||
self.assertEqual('private', output.visibility)
|
||||
output_logs = self.notifier.get_logs()
|
||||
self.assertEqual(len(output_logs), 1)
|
||||
self.assertEqual(1, len(output_logs))
|
||||
output_log = output_logs[0]
|
||||
self.assertEqual(output_log['notification_type'], 'INFO')
|
||||
self.assertEqual(output_log['event_type'], 'image.create')
|
||||
self.assertEqual(output_log['payload']['name'], 'image-1')
|
||||
self.assertEqual('INFO', output_log['notification_type'])
|
||||
self.assertEqual('image.create', output_log['event_type'])
|
||||
self.assertEqual('image-1', output_log['payload']['name'])
|
||||
|
||||
def test_create_with_too_many_properties(self):
|
||||
self.config(image_property_quota=1)
|
||||
|
@ -636,11 +636,11 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
extra_properties={}, tags=[])
|
||||
self.assertEqual('public', output.visibility)
|
||||
output_logs = self.notifier.get_logs()
|
||||
self.assertEqual(len(output_logs), 1)
|
||||
self.assertEqual(1, len(output_logs))
|
||||
output_log = output_logs[0]
|
||||
self.assertEqual(output_log['notification_type'], 'INFO')
|
||||
self.assertEqual(output_log['event_type'], 'image.create')
|
||||
self.assertEqual(output_log['payload']['id'], output.image_id)
|
||||
self.assertEqual('INFO', output_log['notification_type'])
|
||||
self.assertEqual('image.create', output_log['event_type'])
|
||||
self.assertEqual(output.image_id, output_log['payload']['id'])
|
||||
|
||||
def test_create_dup_id(self):
|
||||
request = unit_test_utils.get_fake_request()
|
||||
|
@ -660,11 +660,11 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
extra_properties={}, tags=tags)
|
||||
self.assertEqual(set(['ping']), output.tags)
|
||||
output_logs = self.notifier.get_logs()
|
||||
self.assertEqual(len(output_logs), 1)
|
||||
self.assertEqual(1, len(output_logs))
|
||||
output_log = output_logs[0]
|
||||
self.assertEqual(output_log['notification_type'], 'INFO')
|
||||
self.assertEqual(output_log['event_type'], 'image.create')
|
||||
self.assertEqual(output_log['payload']['id'], output.image_id)
|
||||
self.assertEqual('INFO', output_log['notification_type'])
|
||||
self.assertEqual('image.create', output_log['event_type'])
|
||||
self.assertEqual(output.image_id, output_log['payload']['id'])
|
||||
|
||||
def test_create_with_too_many_tags(self):
|
||||
self.config(image_tag_quota=1)
|
||||
|
@ -686,9 +686,9 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
def test_update_no_changes(self):
|
||||
request = unit_test_utils.get_fake_request()
|
||||
output = self.controller.update(request, UUID1, changes=[])
|
||||
self.assertEqual(output.image_id, UUID1)
|
||||
self.assertEqual(UUID1, output.image_id)
|
||||
self.assertEqual(output.created_at, output.updated_at)
|
||||
self.assertEqual(len(output.tags), 2)
|
||||
self.assertEqual(2, len(output.tags))
|
||||
self.assertIn('ping', output.tags)
|
||||
self.assertIn('pong', output.tags)
|
||||
output_logs = self.notifier.get_logs()
|
||||
|
@ -733,9 +733,9 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
request = unit_test_utils.get_fake_request()
|
||||
changes = [{'op': 'replace', 'path': ['name'], 'value': 'fedora'}]
|
||||
output = self.controller.update(request, UUID1, changes)
|
||||
self.assertEqual(output.image_id, UUID1)
|
||||
self.assertEqual(output.name, 'fedora')
|
||||
self.assertEqual(output.extra_properties, {'foo': 'bar'})
|
||||
self.assertEqual(UUID1, output.image_id)
|
||||
self.assertEqual('fedora', output.name)
|
||||
self.assertEqual({'foo': 'bar'}, output.extra_properties)
|
||||
self.assertNotEqual(output.created_at, output.updated_at)
|
||||
|
||||
def test_update_replace_tags(self):
|
||||
|
@ -745,7 +745,7 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
]
|
||||
output = self.controller.update(request, UUID1, changes)
|
||||
self.assertEqual(output.image_id, UUID1)
|
||||
self.assertEqual(len(output.tags), 2)
|
||||
self.assertEqual(2, len(output.tags))
|
||||
self.assertIn('king', output.tags)
|
||||
self.assertIn('kong', output.tags)
|
||||
self.assertNotEqual(output.created_at, output.updated_at)
|
||||
|
@ -756,16 +756,16 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
self.db.image_update(None, UUID1, {'properties': properties})
|
||||
|
||||
output = self.controller.show(request, UUID1)
|
||||
self.assertEqual(output.extra_properties['foo'], 'bar')
|
||||
self.assertEqual(output.extra_properties['snitch'], 'golden')
|
||||
self.assertEqual('bar', output.extra_properties['foo'])
|
||||
self.assertEqual('golden', output.extra_properties['snitch'])
|
||||
|
||||
changes = [
|
||||
{'op': 'replace', 'path': ['foo'], 'value': 'baz'},
|
||||
]
|
||||
output = self.controller.update(request, UUID1, changes)
|
||||
self.assertEqual(output.image_id, UUID1)
|
||||
self.assertEqual(output.extra_properties['foo'], 'baz')
|
||||
self.assertEqual(output.extra_properties['snitch'], 'golden')
|
||||
self.assertEqual(UUID1, output.image_id)
|
||||
self.assertEqual('baz', output.extra_properties['foo'])
|
||||
self.assertEqual('golden', output.extra_properties['snitch'])
|
||||
self.assertNotEqual(output.created_at, output.updated_at)
|
||||
|
||||
def test_update_add_too_many_properties(self):
|
||||
|
@ -809,7 +809,7 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
'path': ['foo'],
|
||||
'value': 'bar'}]
|
||||
output = self.controller.update(request, UUID1, changes)
|
||||
self.assertEqual(output.image_id, UUID1)
|
||||
self.assertEqual(UUID1, output.image_id)
|
||||
self.assertNotEqual(output.created_at, output.updated_at)
|
||||
|
||||
def test_update_format_properties(self):
|
||||
|
@ -844,8 +844,8 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
{'op': 'replace', 'path': ['container_format'], 'value': 'bare'},
|
||||
]
|
||||
resp = self.controller.update(request, image['id'], changes)
|
||||
self.assertEqual(resp.disk_format, 'raw')
|
||||
self.assertEqual(resp.container_format, 'bare')
|
||||
self.assertEqual('raw', resp.disk_format)
|
||||
self.assertEqual('bare', resp.container_format)
|
||||
|
||||
def test_update_remove_property_while_over_limit(self):
|
||||
"""Ensure that image properties can be removed.
|
||||
|
@ -872,9 +872,9 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
{'op': 'remove', 'path': ['snitch']},
|
||||
]
|
||||
output = self.controller.update(request, UUID1, changes)
|
||||
self.assertEqual(output.image_id, UUID1)
|
||||
self.assertEqual(len(output.extra_properties), 1)
|
||||
self.assertEqual(output.extra_properties['fizz'], 'buzz')
|
||||
self.assertEqual(UUID1, output.image_id)
|
||||
self.assertEqual(1, len(output.extra_properties))
|
||||
self.assertEqual('buzz', output.extra_properties['fizz'])
|
||||
self.assertNotEqual(output.created_at, output.updated_at)
|
||||
|
||||
def test_update_add_and_remove_property_under_limit(self):
|
||||
|
@ -902,9 +902,9 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
{'op': 'add', 'path': ['fizz'], 'value': 'buzz'},
|
||||
]
|
||||
output = self.controller.update(request, UUID1, changes)
|
||||
self.assertEqual(output.image_id, UUID1)
|
||||
self.assertEqual(len(output.extra_properties), 1)
|
||||
self.assertEqual(output.extra_properties['fizz'], 'buzz')
|
||||
self.assertEqual(UUID1, output.image_id)
|
||||
self.assertEqual(1, len(output.extra_properties))
|
||||
self.assertEqual('buzz', output.extra_properties['fizz'])
|
||||
self.assertNotEqual(output.created_at, output.updated_at)
|
||||
|
||||
def test_update_replace_missing_property(self):
|
||||
|
@ -934,7 +934,7 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
]
|
||||
output = self.controller.update(another_request,
|
||||
created_image.image_id, changes)
|
||||
self.assertEqual(output.extra_properties['x_owner_foo'], 'bar')
|
||||
self.assertEqual('bar', output.extra_properties['x_owner_foo'])
|
||||
|
||||
def test_prop_protection_with_update_and_permitted_policy(self):
|
||||
self.set_property_protections(use_policies=True)
|
||||
|
@ -949,8 +949,8 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
created_image = self.controller.create(request, image=image,
|
||||
extra_properties=extra_props,
|
||||
tags=[])
|
||||
self.assertEqual(created_image.extra_properties['spl_creator_policy'],
|
||||
'bar')
|
||||
self.assertEqual('bar',
|
||||
created_image.extra_properties['spl_creator_policy'])
|
||||
|
||||
another_request = unit_test_utils.get_fake_request(roles=['spl_role'])
|
||||
changes = [
|
||||
|
@ -961,8 +961,8 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
another_request = unit_test_utils.get_fake_request(roles=['admin'])
|
||||
output = self.controller.update(another_request,
|
||||
created_image.image_id, changes)
|
||||
self.assertEqual(output.extra_properties['spl_creator_policy'],
|
||||
'par')
|
||||
self.assertEqual('par',
|
||||
output.extra_properties['spl_creator_policy'])
|
||||
|
||||
def test_prop_protection_with_create_with_patch_and_policy(self):
|
||||
self.set_property_protections(use_policies=True)
|
||||
|
@ -987,8 +987,8 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
another_request = unit_test_utils.get_fake_request(roles=['spl_role'])
|
||||
output = self.controller.update(another_request,
|
||||
created_image.image_id, changes)
|
||||
self.assertEqual(output.extra_properties['spl_creator_policy'],
|
||||
'bar')
|
||||
self.assertEqual('bar',
|
||||
output.extra_properties['spl_creator_policy'])
|
||||
|
||||
def test_prop_protection_with_create_and_unpermitted_role(self):
|
||||
enforcer = glance.api.policy.Enforcer()
|
||||
|
@ -1026,7 +1026,7 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
tags=[])
|
||||
another_request = unit_test_utils.get_fake_request(roles=['member'])
|
||||
output = self.controller.show(another_request, created_image.image_id)
|
||||
self.assertEqual(output.extra_properties['x_owner_foo'], 'bar')
|
||||
self.assertEqual('bar', output.extra_properties['x_owner_foo'])
|
||||
|
||||
def test_prop_protection_with_show_and_unpermitted_role(self):
|
||||
enforcer = glance.api.policy.Enforcer()
|
||||
|
@ -1065,7 +1065,7 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
]
|
||||
output = self.controller.update(another_request,
|
||||
created_image.image_id, changes)
|
||||
self.assertEqual(output.extra_properties['x_owner_foo'], 'baz')
|
||||
self.assertEqual('baz', output.extra_properties['x_owner_foo'])
|
||||
|
||||
def test_prop_protection_with_update_and_unpermitted_role(self):
|
||||
enforcer = glance.api.policy.Enforcer()
|
||||
|
@ -1138,15 +1138,15 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
created_image = self.controller.create(request, image=image,
|
||||
extra_properties=extra_props,
|
||||
tags=[])
|
||||
self.assertEqual(created_image.extra_properties['x_all_permitted_1'],
|
||||
'1')
|
||||
self.assertEqual('1',
|
||||
created_image.extra_properties['x_all_permitted_1'])
|
||||
another_request = unit_test_utils.get_fake_request(roles=['joe_soap'])
|
||||
extra_props = {'x_all_permitted_2': '2'}
|
||||
created_image = self.controller.create(another_request, image=image,
|
||||
extra_properties=extra_props,
|
||||
tags=[])
|
||||
self.assertEqual(created_image.extra_properties['x_all_permitted_2'],
|
||||
'2')
|
||||
self.assertEqual('2',
|
||||
created_image.extra_properties['x_all_permitted_2'])
|
||||
|
||||
def test_read_non_protected_prop(self):
|
||||
"""Property marked with special char @ readable by an unknown role"""
|
||||
|
@ -1159,7 +1159,7 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
tags=[])
|
||||
another_request = unit_test_utils.get_fake_request(roles=['joe_soap'])
|
||||
output = self.controller.show(another_request, created_image.image_id)
|
||||
self.assertEqual(output.extra_properties['x_all_permitted'], '1')
|
||||
self.assertEqual('1', output.extra_properties['x_all_permitted'])
|
||||
|
||||
def test_update_non_protected_prop(self):
|
||||
"""Property marked with special char @ updatable by an unknown role"""
|
||||
|
@ -1176,7 +1176,7 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
]
|
||||
output = self.controller.update(another_request,
|
||||
created_image.image_id, changes)
|
||||
self.assertEqual(output.extra_properties['x_all_permitted'], 'baz')
|
||||
self.assertEqual('baz', output.extra_properties['x_all_permitted'])
|
||||
|
||||
def test_delete_non_protected_prop(self):
|
||||
"""Property marked with special char @ deletable by an unknown role"""
|
||||
|
@ -1265,19 +1265,19 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
request = unit_test_utils.get_fake_request()
|
||||
changes = [{'op': 'replace', 'path': ['locations'], 'value': []}]
|
||||
output = self.controller.update(request, UUID1, changes)
|
||||
self.assertEqual(output.image_id, UUID1)
|
||||
self.assertEqual(len(output.locations), 0)
|
||||
self.assertEqual(output.status, 'queued')
|
||||
self.assertEqual(UUID1, output.image_id)
|
||||
self.assertEqual(0, len(output.locations))
|
||||
self.assertEqual('queued', output.status)
|
||||
self.assertIsNone(output.size)
|
||||
|
||||
new_location = {'url': '%s/fake_location' % BASE_URI, 'metadata': {}}
|
||||
changes = [{'op': 'replace', 'path': ['locations'],
|
||||
'value': [new_location]}]
|
||||
output = self.controller.update(request, UUID1, changes)
|
||||
self.assertEqual(output.image_id, UUID1)
|
||||
self.assertEqual(len(output.locations), 1)
|
||||
self.assertEqual(UUID1, output.image_id)
|
||||
self.assertEqual(1, len(output.locations))
|
||||
self.assertEqual(new_location, output.locations[0])
|
||||
self.assertEqual(output.status, 'active')
|
||||
self.assertEqual('active', output.status)
|
||||
|
||||
def test_update_replace_locations_non_empty(self):
|
||||
new_location = {'url': '%s/fake_location' % BASE_URI, 'metadata': {}}
|
||||
|
@ -1291,9 +1291,9 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
request = unit_test_utils.get_fake_request()
|
||||
changes = [{'op': 'replace', 'path': ['locations'], 'value': []}]
|
||||
output = self.controller.update(request, UUID1, changes)
|
||||
self.assertEqual(output.image_id, UUID1)
|
||||
self.assertEqual(len(output.locations), 0)
|
||||
self.assertEqual(output.status, 'queued')
|
||||
self.assertEqual(UUID1, output.image_id)
|
||||
self.assertEqual(0, len(output.locations))
|
||||
self.assertEqual('queued', output.status)
|
||||
|
||||
request = unit_test_utils.get_fake_request()
|
||||
changes = [{'op': 'replace', 'path': ['locations'],
|
||||
|
@ -1305,9 +1305,9 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
request = unit_test_utils.get_fake_request()
|
||||
changes = [{'op': 'replace', 'path': ['locations'], 'value': []}]
|
||||
output = self.controller.update(request, UUID2, changes)
|
||||
self.assertEqual(output.image_id, UUID2)
|
||||
self.assertEqual(len(output.locations), 0)
|
||||
self.assertEqual(output.status, 'queued')
|
||||
self.assertEqual(UUID2, output.image_id)
|
||||
self.assertEqual(0, len(output.locations))
|
||||
self.assertEqual('queued', output.status)
|
||||
|
||||
self.db.image_update(None, UUID2, {'disk_format': None})
|
||||
|
||||
|
@ -1325,9 +1325,9 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
{'op': 'add', 'path': ['snitch'], 'value': 'golden'},
|
||||
]
|
||||
output = self.controller.update(request, UUID1, changes)
|
||||
self.assertEqual(output.image_id, UUID1)
|
||||
self.assertEqual(output.extra_properties['foo'], 'baz')
|
||||
self.assertEqual(output.extra_properties['snitch'], 'golden')
|
||||
self.assertEqual(UUID1, output.image_id)
|
||||
self.assertEqual('baz', output.extra_properties['foo'])
|
||||
self.assertEqual('golden', output.extra_properties['snitch'])
|
||||
self.assertNotEqual(output.created_at, output.updated_at)
|
||||
|
||||
def test_update_add_base_property_json_schema_version_4(self):
|
||||
|
@ -1376,7 +1376,7 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
self.db.image_update(None, UUID1, {'properties': properties})
|
||||
|
||||
output = self.controller.show(request, UUID1)
|
||||
self.assertEqual(output.extra_properties['foo'], 'bar')
|
||||
self.assertEqual('bar', output.extra_properties['foo'])
|
||||
|
||||
changes = [
|
||||
{'json_schema_version': 4, 'op': 'add',
|
||||
|
@ -1407,8 +1407,8 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
changes = [{'op': 'add', 'path': ['locations', '-'],
|
||||
'value': new_location}]
|
||||
output = self.controller.update(request, UUID1, changes)
|
||||
self.assertEqual(output.image_id, UUID1)
|
||||
self.assertEqual(len(output.locations), 2)
|
||||
self.assertEqual(UUID1, output.image_id)
|
||||
self.assertEqual(2, len(output.locations))
|
||||
self.assertEqual(new_location, output.locations[1])
|
||||
|
||||
def test_update_add_locations_insertion(self):
|
||||
|
@ -1417,8 +1417,8 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
changes = [{'op': 'add', 'path': ['locations', '0'],
|
||||
'value': new_location}]
|
||||
output = self.controller.update(request, UUID1, changes)
|
||||
self.assertEqual(output.image_id, UUID1)
|
||||
self.assertEqual(len(output.locations), 2)
|
||||
self.assertEqual(UUID1, output.image_id)
|
||||
self.assertEqual(2, len(output.locations))
|
||||
self.assertEqual(new_location, output.locations[0])
|
||||
|
||||
def test_update_add_locations_list(self):
|
||||
|
@ -1444,9 +1444,9 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
request = unit_test_utils.get_fake_request()
|
||||
changes = [{'op': 'replace', 'path': ['locations'], 'value': []}]
|
||||
output = self.controller.update(request, UUID2, changes)
|
||||
self.assertEqual(output.image_id, UUID2)
|
||||
self.assertEqual(len(output.locations), 0)
|
||||
self.assertEqual(output.status, 'queued')
|
||||
self.assertEqual(UUID2, output.image_id)
|
||||
self.assertEqual(0, len(output.locations))
|
||||
self.assertEqual('queued', output.status)
|
||||
|
||||
self.db.image_update(None, UUID2, {'disk_format': None})
|
||||
|
||||
|
@ -1462,8 +1462,8 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
changes = [{'op': 'add', 'path': ['locations', '-'],
|
||||
'value': new_location}]
|
||||
output = self.controller.update(request, UUID1, changes)
|
||||
self.assertEqual(output.image_id, UUID1)
|
||||
self.assertEqual(len(output.locations), 2)
|
||||
self.assertEqual(UUID1, output.image_id)
|
||||
self.assertEqual(2, len(output.locations))
|
||||
self.assertEqual(new_location, output.locations[1])
|
||||
|
||||
self.assertRaises(webob.exc.HTTPBadRequest, self.controller.update,
|
||||
|
@ -1473,9 +1473,9 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
request = unit_test_utils.get_fake_request()
|
||||
changes = [{'op': 'replace', 'path': ['locations'], 'value': []}]
|
||||
output = self.controller.update(request, UUID1, changes)
|
||||
self.assertEqual(output.image_id, UUID1)
|
||||
self.assertEqual(len(output.locations), 0)
|
||||
self.assertEqual(output.status, 'queued')
|
||||
self.assertEqual(UUID1, output.image_id)
|
||||
self.assertEqual(0, len(output.locations))
|
||||
self.assertEqual('queued', output.status)
|
||||
|
||||
new_location = {'url': '%s/fake_location' % BASE_URI, 'metadata': {}}
|
||||
changes = [{'op': 'replace', 'path': ['locations'],
|
||||
|
@ -1533,7 +1533,7 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
'metadata': {}}},
|
||||
]
|
||||
output = self.controller.update(request, UUID1, changes)
|
||||
self.assertEqual(output.image_id, UUID1)
|
||||
self.assertEqual(UUID1, output.image_id)
|
||||
self.assertNotEqual(output.created_at, output.updated_at)
|
||||
|
||||
def test_update_remove_location_while_over_limit(self):
|
||||
|
@ -1563,8 +1563,8 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
{'op': 'remove', 'path': ['locations', '0']},
|
||||
]
|
||||
output = self.controller.update(request, UUID1, changes)
|
||||
self.assertEqual(output.image_id, UUID1)
|
||||
self.assertEqual(len(output.locations), 1)
|
||||
self.assertEqual(UUID1, output.image_id)
|
||||
self.assertEqual(1, len(output.locations))
|
||||
self.assertIn('fake_location_2', output.locations[0]['url'])
|
||||
self.assertNotEqual(output.created_at, output.updated_at)
|
||||
|
||||
|
@ -1598,8 +1598,8 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
'metadata': {}}},
|
||||
]
|
||||
output = self.controller.update(request, UUID1, changes)
|
||||
self.assertEqual(output.image_id, UUID1)
|
||||
self.assertEqual(len(output.locations), 1)
|
||||
self.assertEqual(UUID1, output.image_id)
|
||||
self.assertEqual(1, len(output.locations))
|
||||
self.assertIn('fake_location_3', output.locations[0]['url'])
|
||||
self.assertNotEqual(output.created_at, output.updated_at)
|
||||
|
||||
|
@ -1616,15 +1616,15 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
self.db.image_update(None, UUID1, {'properties': properties})
|
||||
|
||||
output = self.controller.show(request, UUID1)
|
||||
self.assertEqual(output.extra_properties['foo'], 'bar')
|
||||
self.assertEqual(output.extra_properties['snitch'], 'golden')
|
||||
self.assertEqual('bar', output.extra_properties['foo'])
|
||||
self.assertEqual('golden', output.extra_properties['snitch'])
|
||||
|
||||
changes = [
|
||||
{'op': 'remove', 'path': ['snitch']},
|
||||
]
|
||||
output = self.controller.update(request, UUID1, changes)
|
||||
self.assertEqual(output.image_id, UUID1)
|
||||
self.assertEqual(output.extra_properties, {'foo': 'bar'})
|
||||
self.assertEqual(UUID1, output.image_id)
|
||||
self.assertEqual({'foo': 'bar'}, output.extra_properties)
|
||||
self.assertNotEqual(output.created_at, output.updated_at)
|
||||
|
||||
def test_update_remove_missing_property(self):
|
||||
|
@ -1644,18 +1644,18 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
changes = [{'op': 'remove', 'path': ['locations', '0']}]
|
||||
output = self.controller.update(request, UUID1, changes)
|
||||
self.assertEqual(output.image_id, UUID1)
|
||||
self.assertEqual(len(output.locations), 0)
|
||||
self.assertEqual(output.status, 'queued')
|
||||
self.assertEqual(0, len(output.locations))
|
||||
self.assertEqual('queued', output.status)
|
||||
self.assertIsNone(output.size)
|
||||
|
||||
new_location = {'url': '%s/fake_location' % BASE_URI, 'metadata': {}}
|
||||
changes = [{'op': 'add', 'path': ['locations', '-'],
|
||||
'value': new_location}]
|
||||
output = self.controller.update(request, UUID1, changes)
|
||||
self.assertEqual(output.image_id, UUID1)
|
||||
self.assertEqual(len(output.locations), 1)
|
||||
self.assertEqual(UUID1, output.image_id)
|
||||
self.assertEqual(1, len(output.locations))
|
||||
self.assertEqual(new_location, output.locations[0])
|
||||
self.assertEqual(output.status, 'active')
|
||||
self.assertEqual('active', output.status)
|
||||
|
||||
def test_update_remove_location_invalid_pos(self):
|
||||
request = unit_test_utils.get_fake_request()
|
||||
|
@ -1696,14 +1696,14 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
{'op': 'add', 'path': ['kb'], 'value': 'dvorak'},
|
||||
]
|
||||
output = self.controller.update(request, UUID1, changes)
|
||||
self.assertEqual(output.image_id, UUID1)
|
||||
self.assertEqual(output.min_ram, 128)
|
||||
self.assertEqual(UUID1, output.image_id)
|
||||
self.assertEqual(128, output.min_ram)
|
||||
self.addDetail('extra_properties',
|
||||
testtools.content.json_content(
|
||||
jsonutils.dumps(output.extra_properties)))
|
||||
self.assertEqual(len(output.extra_properties), 2)
|
||||
self.assertEqual(output.extra_properties['foo'], 'baz')
|
||||
self.assertEqual(output.extra_properties['kb'], 'dvorak')
|
||||
self.assertEqual(2, len(output.extra_properties))
|
||||
self.assertEqual('baz', output.extra_properties['foo'])
|
||||
self.assertEqual('dvorak', output.extra_properties['kb'])
|
||||
self.assertNotEqual(output.created_at, output.updated_at)
|
||||
|
||||
def test_update_invalid_operation(self):
|
||||
|
@ -1722,14 +1722,14 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
{'op': 'replace', 'path': ['tags'], 'value': ['ping', 'ping']},
|
||||
]
|
||||
output = self.controller.update(request, UUID1, changes)
|
||||
self.assertEqual(len(output.tags), 1)
|
||||
self.assertEqual(1, len(output.tags))
|
||||
self.assertIn('ping', output.tags)
|
||||
output_logs = self.notifier.get_logs()
|
||||
self.assertEqual(len(output_logs), 1)
|
||||
self.assertEqual(1, len(output_logs))
|
||||
output_log = output_logs[0]
|
||||
self.assertEqual(output_log['notification_type'], 'INFO')
|
||||
self.assertEqual(output_log['event_type'], 'image.update')
|
||||
self.assertEqual(output_log['payload']['id'], UUID1)
|
||||
self.assertEqual('INFO', output_log['notification_type'])
|
||||
self.assertEqual('image.update', output_log['event_type'])
|
||||
self.assertEqual(UUID1, output_log['payload']['id'])
|
||||
|
||||
def test_delete(self):
|
||||
request = unit_test_utils.get_fake_request()
|
||||
|
@ -1737,17 +1737,17 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
try:
|
||||
self.controller.delete(request, UUID1)
|
||||
output_logs = self.notifier.get_logs()
|
||||
self.assertEqual(len(output_logs), 1)
|
||||
self.assertEqual(1, len(output_logs))
|
||||
output_log = output_logs[0]
|
||||
self.assertEqual(output_log['notification_type'], "INFO")
|
||||
self.assertEqual(output_log['event_type'], "image.delete")
|
||||
self.assertEqual('INFO', output_log['notification_type'])
|
||||
self.assertEqual("image.delete", output_log['event_type'])
|
||||
except Exception as e:
|
||||
self.fail("Delete raised exception: %s" % e)
|
||||
|
||||
deleted_img = self.db.image_get(request.context, UUID1,
|
||||
force_show_deleted=True)
|
||||
self.assertTrue(deleted_img['deleted'])
|
||||
self.assertEqual(deleted_img['status'], 'deleted')
|
||||
self.assertEqual('deleted', deleted_img['status'])
|
||||
self.assertNotIn('%s/%s' % (BASE_URI, UUID1), self.store.data)
|
||||
|
||||
def test_delete_queued_updates_status(self):
|
||||
|
@ -1760,7 +1760,7 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
image = self.db.image_get(request.context, image_id,
|
||||
force_show_deleted=True)
|
||||
self.assertTrue(image['deleted'])
|
||||
self.assertEqual(image['status'], 'deleted')
|
||||
self.assertEqual('deleted', image['status'])
|
||||
|
||||
def test_delete_queued_updates_status_delayed_delete(self):
|
||||
"""Ensure status of queued image is updated (LP bug #1048851).
|
||||
|
@ -1778,7 +1778,7 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
image = self.db.image_get(request.context, image_id,
|
||||
force_show_deleted=True)
|
||||
self.assertTrue(image['deleted'])
|
||||
self.assertEqual(image['status'], 'deleted')
|
||||
self.assertEqual('deleted', image['status'])
|
||||
|
||||
def test_delete_not_in_store(self):
|
||||
request = unit_test_utils.get_fake_request()
|
||||
|
@ -1792,7 +1792,7 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
deleted_img = self.db.image_get(request.context, UUID1,
|
||||
force_show_deleted=True)
|
||||
self.assertTrue(deleted_img['deleted'])
|
||||
self.assertEqual(deleted_img['status'], 'deleted')
|
||||
self.assertEqual('deleted', deleted_img['status'])
|
||||
self.assertNotIn('%s/%s' % (BASE_URI, UUID1), self.store.data)
|
||||
|
||||
def test_delayed_delete(self):
|
||||
|
@ -1805,7 +1805,7 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
deleted_img = self.db.image_get(request.context, UUID1,
|
||||
force_show_deleted=True)
|
||||
self.assertTrue(deleted_img['deleted'])
|
||||
self.assertEqual(deleted_img['status'], 'pending_delete')
|
||||
self.assertEqual('pending_delete', deleted_img['status'])
|
||||
self.assertIn('%s/%s' % (BASE_URI, UUID1), self.store.data)
|
||||
|
||||
def test_delete_non_existent(self):
|
||||
|
@ -1915,7 +1915,7 @@ class TestImagesControllerPolicies(base.IsolatedUnitTest):
|
|||
changes = [{'op': 'replace', 'path': ['visibility'],
|
||||
'value': 'private'}]
|
||||
output = self.controller.update(request, UUID1, changes)
|
||||
self.assertEqual(output.visibility, 'private')
|
||||
self.assertEqual('private', output.visibility)
|
||||
|
||||
def test_update_get_image_location_unauthorized(self):
|
||||
rules = {"get_image_location": False}
|
||||
|
@ -2053,7 +2053,7 @@ class TestImagesDeserializer(test_utils.BaseTestCase):
|
|||
request.body = jsonutils.dumps([])
|
||||
output = self.deserializer.update(request)
|
||||
expected = {'changes': []}
|
||||
self.assertEqual(output, expected)
|
||||
self.assertEqual(expected, output)
|
||||
|
||||
def test_update_unsupported_content_type(self):
|
||||
request = unit_test_utils.get_fake_request()
|
||||
|
@ -2066,7 +2066,7 @@ class TestImagesDeserializer(test_utils.BaseTestCase):
|
|||
accept_patch = ['application/openstack-images-v2.1-json-patch',
|
||||
'application/openstack-images-v2.0-json-patch']
|
||||
expected = ', '.join(sorted(accept_patch))
|
||||
self.assertEqual(e.headers['Accept-Patch'], expected)
|
||||
self.assertEqual(expected, e.headers['Accept-Patch'])
|
||||
else:
|
||||
self.fail('Did not raise HTTPUnsupportedMediaType')
|
||||
|
||||
|
@ -2146,7 +2146,7 @@ class TestImagesDeserializer(test_utils.BaseTestCase):
|
|||
'value': [{'url': 'scheme5://path5', 'metadata': {}},
|
||||
{'url': 'scheme6://path6', 'metadata': {}}]},
|
||||
]}
|
||||
self.assertEqual(output, expected)
|
||||
self.assertEqual(expected, output)
|
||||
|
||||
def test_update_v2_0_compatibility(self):
|
||||
request = self._get_fake_patch_request(content_type_minor_version=0)
|
||||
|
@ -2192,7 +2192,7 @@ class TestImagesDeserializer(test_utils.BaseTestCase):
|
|||
'value': [{'url': 'scheme5://path5', 'metadata': {}},
|
||||
{'url': 'scheme6://path6', 'metadata': {}}]},
|
||||
]}
|
||||
self.assertEqual(output, expected)
|
||||
self.assertEqual(expected, output)
|
||||
|
||||
def test_update_base_attributes(self):
|
||||
request = self._get_fake_patch_request()
|
||||
|
@ -2238,7 +2238,7 @@ class TestImagesDeserializer(test_utils.BaseTestCase):
|
|||
'value': [{'url': 'scheme5://path5', 'metadata': {}},
|
||||
{'url': 'scheme6://path6', 'metadata': {}}]}
|
||||
]}
|
||||
self.assertEqual(output, expected)
|
||||
self.assertEqual(expected, output)
|
||||
|
||||
def test_update_disallowed_attributes(self):
|
||||
samples = {
|
||||
|
@ -2404,22 +2404,22 @@ class TestImagesDeserializer(test_utils.BaseTestCase):
|
|||
'member_status': 'pending',
|
||||
'filters': {}}
|
||||
output = self.deserializer.index(request)
|
||||
self.assertEqual(output, expected)
|
||||
self.assertEqual(expected, output)
|
||||
|
||||
def test_index_with_filter(self):
|
||||
name = 'My Little Image'
|
||||
path = '/images?name=%s' % name
|
||||
request = unit_test_utils.get_fake_request(path)
|
||||
output = self.deserializer.index(request)
|
||||
self.assertEqual(output['filters']['name'], name)
|
||||
self.assertEqual(name, output['filters']['name'])
|
||||
|
||||
def test_index_strip_params_from_filters(self):
|
||||
name = 'My Little Image'
|
||||
path = '/images?name=%s' % name
|
||||
request = unit_test_utils.get_fake_request(path)
|
||||
output = self.deserializer.index(request)
|
||||
self.assertEqual(output['filters']['name'], name)
|
||||
self.assertEqual(len(output['filters']), 1)
|
||||
self.assertEqual(name, output['filters']['name'])
|
||||
self.assertEqual(1, len(output['filters']))
|
||||
|
||||
def test_index_with_many_filter(self):
|
||||
name = 'My Little Image'
|
||||
|
@ -2428,16 +2428,16 @@ class TestImagesDeserializer(test_utils.BaseTestCase):
|
|||
{'name': name, 'instance_id': instance_id})
|
||||
request = unit_test_utils.get_fake_request(path)
|
||||
output = self.deserializer.index(request)
|
||||
self.assertEqual(output['filters']['name'], name)
|
||||
self.assertEqual(output['filters']['id'], instance_id)
|
||||
self.assertEqual(name, output['filters']['name'])
|
||||
self.assertEqual(instance_id, output['filters']['id'])
|
||||
|
||||
def test_index_with_filter_and_limit(self):
|
||||
name = 'My Little Image'
|
||||
path = '/images?name=%s&limit=1' % name
|
||||
request = unit_test_utils.get_fake_request(path)
|
||||
output = self.deserializer.index(request)
|
||||
self.assertEqual(output['filters']['name'], name)
|
||||
self.assertEqual(output['limit'], 1)
|
||||
self.assertEqual(name, output['filters']['name'])
|
||||
self.assertEqual(1, output['limit'])
|
||||
|
||||
def test_index_non_integer_limit(self):
|
||||
request = unit_test_utils.get_fake_request('/images?limit=blah')
|
||||
|
@ -2496,7 +2496,7 @@ class TestImagesDeserializer(test_utils.BaseTestCase):
|
|||
'member_status': 'accepted',
|
||||
'filters': {}
|
||||
}
|
||||
self.assertEqual(output, expected)
|
||||
self.assertEqual(expected, output)
|
||||
|
||||
def test_index_sort_dir_asc(self):
|
||||
request = unit_test_utils.get_fake_request('/images?sort_dir=asc')
|
||||
|
@ -2506,7 +2506,7 @@ class TestImagesDeserializer(test_utils.BaseTestCase):
|
|||
'sort_dir': 'asc',
|
||||
'member_status': 'accepted',
|
||||
'filters': {}}
|
||||
self.assertEqual(output, expected)
|
||||
self.assertEqual(expected, output)
|
||||
|
||||
def test_index_sort_dir_bad_value(self):
|
||||
request = unit_test_utils.get_fake_request('/images?sort_dir=blah')
|
||||
|
@ -2628,7 +2628,7 @@ class TestImagesDeserializerWithAdditionalProperties(test_utils.BaseTestCase):
|
|||
'json_schema_version': 10, 'op': 'add',
|
||||
'path': ['foo'], 'value': 'bar'
|
||||
}
|
||||
self.assertEqual(output, {'changes': [change]})
|
||||
self.assertEqual({'changes': [change]}, output)
|
||||
|
||||
|
||||
class TestImagesDeserializerNoAdditionalProperties(test_utils.BaseTestCase):
|
||||
|
@ -2765,12 +2765,12 @@ class TestImagesSerializer(test_utils.BaseTestCase):
|
|||
request = webob.Request.blank(url)
|
||||
response = webob.Response(request=request)
|
||||
result = {'images': self.fixtures}
|
||||
self.assertEqual(response.status_int, 200)
|
||||
self.assertEqual(200, response.status_int)
|
||||
|
||||
# The image index should work though the user is forbidden
|
||||
result['images'][0].locations = ImageLocations()
|
||||
self.serializer.index(response, result)
|
||||
self.assertEqual(response.status_int, 200)
|
||||
self.assertEqual(200, response.status_int)
|
||||
|
||||
def test_show_full_fixture(self):
|
||||
expected = {
|
||||
|
@ -2847,7 +2847,7 @@ class TestImagesSerializer(test_utils.BaseTestCase):
|
|||
actual['tags'] = sorted(actual['tags'])
|
||||
self.assertEqual(expected, actual)
|
||||
self.assertEqual('application/json', response.content_type)
|
||||
self.assertEqual(response.location, '/v2/images/%s' % UUID1)
|
||||
self.assertEqual('/v2/images/%s' % UUID1, response.location)
|
||||
|
||||
def test_update(self):
|
||||
expected = {
|
||||
|
@ -3006,7 +3006,7 @@ class TestImagesSerializerWithUnicode(test_utils.BaseTestCase):
|
|||
actual['tags'] = sorted(actual['tags'])
|
||||
self.assertEqual(expected, actual)
|
||||
self.assertEqual('application/json', response.content_type)
|
||||
self.assertEqual(response.location, '/v2/images/%s' % UUID1)
|
||||
self.assertEqual('/v2/images/%s' % UUID1, response.location)
|
||||
|
||||
def test_update(self):
|
||||
expected = {
|
||||
|
@ -3245,10 +3245,10 @@ class TestImagesSerializerDirectUrl(test_utils.BaseTestCase):
|
|||
images = self._do_index()
|
||||
|
||||
# NOTE(markwash): ordering sanity check
|
||||
self.assertEqual(images[0]['id'], UUID1)
|
||||
self.assertEqual(images[1]['id'], UUID2)
|
||||
self.assertEqual(UUID1, images[0]['id'])
|
||||
self.assertEqual(UUID2, images[1]['id'])
|
||||
|
||||
self.assertEqual(images[0]['direct_url'], 'http://some/fake/location')
|
||||
self.assertEqual('http://some/fake/location', images[0]['direct_url'])
|
||||
self.assertNotIn('direct_url', images[1])
|
||||
|
||||
def test_index_store_multiple_location_enabled(self):
|
||||
|
@ -3271,7 +3271,7 @@ class TestImagesSerializerDirectUrl(test_utils.BaseTestCase):
|
|||
def test_show_location_enabled(self):
|
||||
self.config(show_image_direct_url=True)
|
||||
image = self._do_show(self.active_image)
|
||||
self.assertEqual(image['direct_url'], 'http://some/fake/location')
|
||||
self.assertEqual('http://some/fake/location', image['direct_url'])
|
||||
|
||||
def test_show_location_enabled_but_not_set(self):
|
||||
self.config(show_image_direct_url=True)
|
||||
|
|
|
@ -128,7 +128,7 @@ class TestRegistryRPC(base.IsolatedUnitTest):
|
|||
}]
|
||||
req.body = jsonutils.dumps(cmd)
|
||||
res = req.get_response(self.api)
|
||||
self.assertEqual(res.status_int, 200)
|
||||
self.assertEqual(200, res.status_int)
|
||||
res_dict = jsonutils.loads(res.body)[0]
|
||||
image = res_dict
|
||||
for k, v in six.iteritems(fixture):
|
||||
|
@ -145,8 +145,8 @@ class TestRegistryRPC(base.IsolatedUnitTest):
|
|||
req.body = jsonutils.dumps(cmd)
|
||||
res = req.get_response(self.api)
|
||||
res_dict = jsonutils.loads(res.body)[0]
|
||||
self.assertEqual(res_dict["_error"]["cls"],
|
||||
'glance.common.exception.NotFound')
|
||||
self.assertEqual('glance.common.exception.NotFound',
|
||||
res_dict["_error"]["cls"])
|
||||
|
||||
def test_get_index(self):
|
||||
"""Tests that the image_get_all command returns list of images."""
|
||||
|
@ -164,10 +164,10 @@ class TestRegistryRPC(base.IsolatedUnitTest):
|
|||
req.body = jsonutils.dumps(cmd)
|
||||
|
||||
res = req.get_response(self.api)
|
||||
self.assertEqual(res.status_int, 200)
|
||||
self.assertEqual(200, res.status_int)
|
||||
|
||||
images = jsonutils.loads(res.body)[0]
|
||||
self.assertEqual(len(images), 1)
|
||||
self.assertEqual(1, len(images))
|
||||
|
||||
for k, v in six.iteritems(fixture):
|
||||
self.assertEqual(v, images[0][k])
|
||||
|
@ -232,14 +232,14 @@ class TestRegistryRPC(base.IsolatedUnitTest):
|
|||
req.body = jsonutils.dumps(cmd)
|
||||
|
||||
res = req.get_response(self.api)
|
||||
self.assertEqual(res.status_int, 200)
|
||||
self.assertEqual(200, res.status_int)
|
||||
|
||||
images = jsonutils.loads(res.body)[0]
|
||||
# should be sorted by created_at desc, id desc
|
||||
# page should start after marker 4
|
||||
self.assertEqual(len(images), 2)
|
||||
self.assertEqual(images[0]['id'], UUID5)
|
||||
self.assertEqual(images[1]['id'], UUID2)
|
||||
self.assertEqual(2, len(images))
|
||||
self.assertEqual(UUID5, images[0]['id'])
|
||||
self.assertEqual(UUID2, images[1]['id'])
|
||||
|
||||
def test_get_index_marker_and_name_asc(self):
|
||||
"""Test marker and null name ascending
|
||||
|
@ -270,9 +270,9 @@ class TestRegistryRPC(base.IsolatedUnitTest):
|
|||
req.body = jsonutils.dumps(cmd)
|
||||
|
||||
res = req.get_response(self.api)
|
||||
self.assertEqual(res.status_int, 200)
|
||||
self.assertEqual(200, res.status_int)
|
||||
images = jsonutils.loads(res.body)[0]
|
||||
self.assertEqual(len(images), 2)
|
||||
self.assertEqual(2, len(images))
|
||||
|
||||
def test_get_index_marker_and_name_desc(self):
|
||||
"""Test marker and null name descending
|
||||
|
@ -303,9 +303,9 @@ class TestRegistryRPC(base.IsolatedUnitTest):
|
|||
req.body = jsonutils.dumps(cmd)
|
||||
|
||||
res = req.get_response(self.api)
|
||||
self.assertEqual(res.status_int, 200)
|
||||
self.assertEqual(200, res.status_int)
|
||||
images = jsonutils.loads(res.body)[0]
|
||||
self.assertEqual(len(images), 0)
|
||||
self.assertEqual(0, len(images))
|
||||
|
||||
def test_get_index_marker_and_disk_format_asc(self):
|
||||
"""Test marker and null disk format ascending
|
||||
|
@ -336,9 +336,9 @@ class TestRegistryRPC(base.IsolatedUnitTest):
|
|||
req.body = jsonutils.dumps(cmd)
|
||||
|
||||
res = req.get_response(self.api)
|
||||
self.assertEqual(res.status_int, 200)
|
||||
self.assertEqual(200, res.status_int)
|
||||
images = jsonutils.loads(res.body)[0]
|
||||
self.assertEqual(len(images), 2)
|
||||
self.assertEqual(2, len(images))
|
||||
|
||||
def test_get_index_marker_and_disk_format_desc(self):
|
||||
"""Test marker and null disk format descending
|
||||
|
@ -369,9 +369,9 @@ class TestRegistryRPC(base.IsolatedUnitTest):
|
|||
req.body = jsonutils.dumps(cmd)
|
||||
|
||||
res = req.get_response(self.api)
|
||||
self.assertEqual(res.status_int, 200)
|
||||
self.assertEqual(200, res.status_int)
|
||||
images = jsonutils.loads(res.body)[0]
|
||||
self.assertEqual(len(images), 0)
|
||||
self.assertEqual(0, len(images))
|
||||
|
||||
def test_get_index_marker_and_container_format_asc(self):
|
||||
"""Test marker and null container format ascending
|
||||
|
@ -402,9 +402,9 @@ class TestRegistryRPC(base.IsolatedUnitTest):
|
|||
req.body = jsonutils.dumps(cmd)
|
||||
|
||||
res = req.get_response(self.api)
|
||||
self.assertEqual(res.status_int, 200)
|
||||
self.assertEqual(200, res.status_int)
|
||||
images = jsonutils.loads(res.body)[0]
|
||||
self.assertEqual(len(images), 2)
|
||||
self.assertEqual(2, len(images))
|
||||
|
||||
def test_get_index_marker_and_container_format_desc(self):
|
||||
"""Test marker and null container format descending
|
||||
|
@ -435,9 +435,9 @@ class TestRegistryRPC(base.IsolatedUnitTest):
|
|||
req.body = jsonutils.dumps(cmd)
|
||||
|
||||
res = req.get_response(self.api)
|
||||
self.assertEqual(res.status_int, 200)
|
||||
self.assertEqual(200, res.status_int)
|
||||
images = jsonutils.loads(res.body)[0]
|
||||
self.assertEqual(len(images), 0)
|
||||
self.assertEqual(0, len(images))
|
||||
|
||||
def test_get_index_unknown_marker(self):
|
||||
"""Tests the registry API returns a NotFound with unknown marker."""
|
||||
|
@ -499,13 +499,13 @@ class TestRegistryRPC(base.IsolatedUnitTest):
|
|||
req.body = jsonutils.dumps(cmd)
|
||||
res = req.get_response(self.api)
|
||||
res_dict = jsonutils.loads(res.body)[0]
|
||||
self.assertEqual(res.status_int, 200)
|
||||
self.assertEqual(200, res.status_int)
|
||||
|
||||
images = res_dict
|
||||
self.assertEqual(len(images), 1)
|
||||
self.assertEqual(1, len(images))
|
||||
|
||||
# expect list to be sorted by created_at desc
|
||||
self.assertEqual(images[0]['id'], UUID4)
|
||||
self.assertEqual(UUID4, images[0]['id'])
|
||||
|
||||
def test_get_index_limit_marker(self):
|
||||
"""Tests that the registry API returns list of public images.
|
||||
|
@ -551,13 +551,13 @@ class TestRegistryRPC(base.IsolatedUnitTest):
|
|||
req.body = jsonutils.dumps(cmd)
|
||||
res = req.get_response(self.api)
|
||||
res_dict = jsonutils.loads(res.body)[0]
|
||||
self.assertEqual(res.status_int, 200)
|
||||
self.assertEqual(200, res.status_int)
|
||||
|
||||
images = res_dict
|
||||
self.assertEqual(len(images), 1)
|
||||
self.assertEqual(1, len(images))
|
||||
|
||||
# expect list to be sorted by created_at desc
|
||||
self.assertEqual(images[0]['id'], UUID2)
|
||||
self.assertEqual(UUID2, images[0]['id'])
|
||||
|
||||
def test_get_index_filter_name(self):
|
||||
"""Tests that the registry API returns list of public images.
|
||||
|
@ -597,10 +597,10 @@ class TestRegistryRPC(base.IsolatedUnitTest):
|
|||
req.body = jsonutils.dumps(cmd)
|
||||
res = req.get_response(self.api)
|
||||
res_dict = jsonutils.loads(res.body)[0]
|
||||
self.assertEqual(res.status_int, 200)
|
||||
self.assertEqual(200, res.status_int)
|
||||
|
||||
images = res_dict
|
||||
self.assertEqual(len(images), 2)
|
||||
self.assertEqual(2, len(images))
|
||||
|
||||
for image in images:
|
||||
self.assertEqual('new name! #123', image['name'])
|
||||
|
@ -631,11 +631,11 @@ class TestRegistryRPC(base.IsolatedUnitTest):
|
|||
}]
|
||||
req.body = jsonutils.dumps(cmd)
|
||||
res = req.get_response(self.api)
|
||||
self.assertEqual(res.status_int, 200)
|
||||
self.assertEqual(200, res.status_int)
|
||||
images = jsonutils.loads(res.body)[0]
|
||||
self.assertEqual(len(images), 2)
|
||||
self.assertEqual(images[0]['id'], extra_id)
|
||||
self.assertEqual(images[1]['id'], UUID1)
|
||||
self.assertEqual(2, len(images))
|
||||
self.assertEqual(extra_id, images[0]['id'])
|
||||
self.assertEqual(UUID1, images[1]['id'])
|
||||
|
||||
# testing with a non-existent value for a common property.
|
||||
cmd = [{
|
||||
|
@ -644,9 +644,9 @@ class TestRegistryRPC(base.IsolatedUnitTest):
|
|||
}]
|
||||
req.body = jsonutils.dumps(cmd)
|
||||
res = req.get_response(self.api)
|
||||
self.assertEqual(res.status_int, 200)
|
||||
self.assertEqual(200, res.status_int)
|
||||
images = jsonutils.loads(res.body)[0]
|
||||
self.assertEqual(len(images), 0)
|
||||
self.assertEqual(0, len(images))
|
||||
|
||||
# testing with a non-existent value for a common property.
|
||||
cmd = [{
|
||||
|
@ -655,9 +655,9 @@ class TestRegistryRPC(base.IsolatedUnitTest):
|
|||
}]
|
||||
req.body = jsonutils.dumps(cmd)
|
||||
res = req.get_response(self.api)
|
||||
self.assertEqual(res.status_int, 200)
|
||||
self.assertEqual(200, res.status_int)
|
||||
images = jsonutils.loads(res.body)[0]
|
||||
self.assertEqual(len(images), 0)
|
||||
self.assertEqual(0, len(images))
|
||||
|
||||
# testing with a non-existent property.
|
||||
cmd = [{
|
||||
|
@ -666,9 +666,9 @@ class TestRegistryRPC(base.IsolatedUnitTest):
|
|||
}]
|
||||
req.body = jsonutils.dumps(cmd)
|
||||
res = req.get_response(self.api)
|
||||
self.assertEqual(res.status_int, 200)
|
||||
self.assertEqual(200, res.status_int)
|
||||
images = jsonutils.loads(res.body)[0]
|
||||
self.assertEqual(len(images), 0)
|
||||
self.assertEqual(0, len(images))
|
||||
|
||||
# testing with multiple existing properties.
|
||||
cmd = [{
|
||||
|
@ -677,10 +677,10 @@ class TestRegistryRPC(base.IsolatedUnitTest):
|
|||
}]
|
||||
req.body = jsonutils.dumps(cmd)
|
||||
res = req.get_response(self.api)
|
||||
self.assertEqual(res.status_int, 200)
|
||||
self.assertEqual(200, res.status_int)
|
||||
images = jsonutils.loads(res.body)[0]
|
||||
self.assertEqual(len(images), 1)
|
||||
self.assertEqual(images[0]['id'], extra_id)
|
||||
self.assertEqual(1, len(images))
|
||||
self.assertEqual(extra_id, images[0]['id'])
|
||||
|
||||
# testing with multiple existing properties but non-existent values.
|
||||
cmd = [{
|
||||
|
@ -689,9 +689,9 @@ class TestRegistryRPC(base.IsolatedUnitTest):
|
|||
}]
|
||||
req.body = jsonutils.dumps(cmd)
|
||||
res = req.get_response(self.api)
|
||||
self.assertEqual(res.status_int, 200)
|
||||
self.assertEqual(200, res.status_int)
|
||||
images = jsonutils.loads(res.body)[0]
|
||||
self.assertEqual(len(images), 0)
|
||||
self.assertEqual(0, len(images))
|
||||
|
||||
# testing with multiple non-existing properties.
|
||||
cmd = [{
|
||||
|
@ -700,9 +700,9 @@ class TestRegistryRPC(base.IsolatedUnitTest):
|
|||
}]
|
||||
req.body = jsonutils.dumps(cmd)
|
||||
res = req.get_response(self.api)
|
||||
self.assertEqual(res.status_int, 200)
|
||||
self.assertEqual(200, res.status_int)
|
||||
images = jsonutils.loads(res.body)[0]
|
||||
self.assertEqual(len(images), 0)
|
||||
self.assertEqual(0, len(images))
|
||||
|
||||
# testing with one existing property and the other non-existing.
|
||||
cmd = [{
|
||||
|
@ -711,9 +711,9 @@ class TestRegistryRPC(base.IsolatedUnitTest):
|
|||
}]
|
||||
req.body = jsonutils.dumps(cmd)
|
||||
res = req.get_response(self.api)
|
||||
self.assertEqual(res.status_int, 200)
|
||||
self.assertEqual(200, res.status_int)
|
||||
images = jsonutils.loads(res.body)[0]
|
||||
self.assertEqual(len(images), 0)
|
||||
self.assertEqual(0, len(images))
|
||||
|
||||
def test_get_index_sort_default_created_at_desc(self):
|
||||
"""Tests that the registry API returns list of public images.
|
||||
|
@ -774,18 +774,18 @@ class TestRegistryRPC(base.IsolatedUnitTest):
|
|||
req.body = jsonutils.dumps(cmd)
|
||||
res = req.get_response(self.api)
|
||||
res_dict = jsonutils.loads(res.body)[0]
|
||||
self.assertEqual(res.status_int, 200)
|
||||
self.assertEqual(200, res.status_int)
|
||||
|
||||
images = res_dict
|
||||
# (flaper87)registry's v1 forced is_public to True
|
||||
# when no value was specified. This is not
|
||||
# the default behaviour anymore.
|
||||
self.assertEqual(len(images), 5)
|
||||
self.assertEqual(images[0]['id'], UUID3)
|
||||
self.assertEqual(images[1]['id'], UUID4)
|
||||
self.assertEqual(images[2]['id'], UUID5)
|
||||
self.assertEqual(images[3]['id'], UUID2)
|
||||
self.assertEqual(images[4]['id'], UUID1)
|
||||
self.assertEqual(5, len(images))
|
||||
self.assertEqual(UUID3, images[0]['id'])
|
||||
self.assertEqual(UUID4, images[1]['id'])
|
||||
self.assertEqual(UUID5, images[2]['id'])
|
||||
self.assertEqual(UUID2, images[3]['id'])
|
||||
self.assertEqual(UUID1, images[4]['id'])
|
||||
|
||||
def test_get_index_sort_name_asc(self):
|
||||
"""Tests that the registry API returns list of public images.
|
||||
|
@ -835,16 +835,16 @@ class TestRegistryRPC(base.IsolatedUnitTest):
|
|||
}]
|
||||
req.body = jsonutils.dumps(cmd)
|
||||
res = req.get_response(self.api)
|
||||
self.assertEqual(res.status_int, 200)
|
||||
self.assertEqual(200, res.status_int)
|
||||
res_dict = jsonutils.loads(res.body)[0]
|
||||
|
||||
images = res_dict
|
||||
self.assertEqual(len(images), 5)
|
||||
self.assertEqual(images[0]['id'], UUID5)
|
||||
self.assertEqual(images[1]['id'], UUID3)
|
||||
self.assertEqual(images[2]['id'], UUID1)
|
||||
self.assertEqual(images[3]['id'], UUID2)
|
||||
self.assertEqual(images[4]['id'], UUID4)
|
||||
self.assertEqual(5, len(images))
|
||||
self.assertEqual(UUID5, images[0]['id'])
|
||||
self.assertEqual(UUID3, images[1]['id'])
|
||||
self.assertEqual(UUID1, images[2]['id'])
|
||||
self.assertEqual(UUID2, images[3]['id'])
|
||||
self.assertEqual(UUID4, images[4]['id'])
|
||||
|
||||
def test_get_index_sort_status_desc(self):
|
||||
"""Tests that the registry API returns list of public images.
|
||||
|
@ -887,15 +887,15 @@ class TestRegistryRPC(base.IsolatedUnitTest):
|
|||
}]
|
||||
req.body = jsonutils.dumps(cmd)
|
||||
res = req.get_response(self.api)
|
||||
self.assertEqual(res.status_int, 200)
|
||||
self.assertEqual(200, res.status_int)
|
||||
res_dict = jsonutils.loads(res.body)[0]
|
||||
|
||||
images = res_dict
|
||||
self.assertEqual(len(images), 4)
|
||||
self.assertEqual(images[0]['id'], UUID1)
|
||||
self.assertEqual(images[1]['id'], UUID2)
|
||||
self.assertEqual(images[2]['id'], UUID4)
|
||||
self.assertEqual(images[3]['id'], UUID3)
|
||||
self.assertEqual(4, len(images))
|
||||
self.assertEqual(UUID1, images[0]['id'])
|
||||
self.assertEqual(UUID2, images[1]['id'])
|
||||
self.assertEqual(UUID4, images[2]['id'])
|
||||
self.assertEqual(UUID3, images[3]['id'])
|
||||
|
||||
def test_get_index_sort_disk_format_asc(self):
|
||||
"""Tests that the registry API returns list of public images.
|
||||
|
@ -938,15 +938,15 @@ class TestRegistryRPC(base.IsolatedUnitTest):
|
|||
}]
|
||||
req.body = jsonutils.dumps(cmd)
|
||||
res = req.get_response(self.api)
|
||||
self.assertEqual(res.status_int, 200)
|
||||
self.assertEqual(200, res.status_int)
|
||||
res_dict = jsonutils.loads(res.body)[0]
|
||||
|
||||
images = res_dict
|
||||
self.assertEqual(len(images), 4)
|
||||
self.assertEqual(images[0]['id'], UUID1)
|
||||
self.assertEqual(images[1]['id'], UUID3)
|
||||
self.assertEqual(images[2]['id'], UUID4)
|
||||
self.assertEqual(images[3]['id'], UUID2)
|
||||
self.assertEqual(4, len(images))
|
||||
self.assertEqual(UUID1, images[0]['id'])
|
||||
self.assertEqual(UUID3, images[1]['id'])
|
||||
self.assertEqual(UUID4, images[2]['id'])
|
||||
self.assertEqual(UUID2, images[3]['id'])
|
||||
|
||||
def test_get_index_sort_container_format_desc(self):
|
||||
"""Tests that the registry API returns list of public images.
|
||||
|
@ -990,15 +990,15 @@ class TestRegistryRPC(base.IsolatedUnitTest):
|
|||
}]
|
||||
req.body = jsonutils.dumps(cmd)
|
||||
res = req.get_response(self.api)
|
||||
self.assertEqual(res.status_int, 200)
|
||||
self.assertEqual(200, res.status_int)
|
||||
res_dict = jsonutils.loads(res.body)[0]
|
||||
|
||||
images = res_dict
|
||||
self.assertEqual(len(images), 4)
|
||||
self.assertEqual(images[0]['id'], UUID2)
|
||||
self.assertEqual(images[1]['id'], UUID4)
|
||||
self.assertEqual(images[2]['id'], UUID3)
|
||||
self.assertEqual(images[3]['id'], UUID1)
|
||||
self.assertEqual(4, len(images))
|
||||
self.assertEqual(UUID2, images[0]['id'])
|
||||
self.assertEqual(UUID4, images[1]['id'])
|
||||
self.assertEqual(UUID3, images[2]['id'])
|
||||
self.assertEqual(UUID1, images[3]['id'])
|
||||
|
||||
def test_get_index_sort_size_asc(self):
|
||||
"""Tests that the registry API returns list of public images.
|
||||
|
@ -1038,15 +1038,15 @@ class TestRegistryRPC(base.IsolatedUnitTest):
|
|||
}]
|
||||
req.body = jsonutils.dumps(cmd)
|
||||
res = req.get_response(self.api)
|
||||
self.assertEqual(res.status_int, 200)
|
||||
self.assertEqual(200, res.status_int)
|
||||
res_dict = jsonutils.loads(res.body)[0]
|
||||
|
||||
images = res_dict
|
||||
self.assertEqual(len(images), 4)
|
||||
self.assertEqual(images[0]['id'], UUID4)
|
||||
self.assertEqual(images[1]['id'], UUID1)
|
||||
self.assertEqual(images[2]['id'], UUID2)
|
||||
self.assertEqual(images[3]['id'], UUID3)
|
||||
self.assertEqual(4, len(images))
|
||||
self.assertEqual(UUID4, images[0]['id'])
|
||||
self.assertEqual(UUID1, images[1]['id'])
|
||||
self.assertEqual(UUID2, images[2]['id'])
|
||||
self.assertEqual(UUID3, images[3]['id'])
|
||||
|
||||
def test_get_index_sort_created_at_asc(self):
|
||||
"""Tests that the registry API returns list of public images.
|
||||
|
@ -1093,15 +1093,15 @@ class TestRegistryRPC(base.IsolatedUnitTest):
|
|||
}]
|
||||
req.body = jsonutils.dumps(cmd)
|
||||
res = req.get_response(self.api)
|
||||
self.assertEqual(res.status_int, 200)
|
||||
self.assertEqual(200, res.status_int)
|
||||
res_dict = jsonutils.loads(res.body)[0]
|
||||
|
||||
images = res_dict
|
||||
self.assertEqual(len(images), 4)
|
||||
self.assertEqual(images[0]['id'], UUID1)
|
||||
self.assertEqual(images[1]['id'], UUID2)
|
||||
self.assertEqual(images[2]['id'], UUID4)
|
||||
self.assertEqual(images[3]['id'], UUID3)
|
||||
self.assertEqual(4, len(images))
|
||||
self.assertEqual(UUID1, images[0]['id'])
|
||||
self.assertEqual(UUID2, images[1]['id'])
|
||||
self.assertEqual(UUID4, images[2]['id'])
|
||||
self.assertEqual(UUID3, images[3]['id'])
|
||||
|
||||
def test_get_index_sort_updated_at_desc(self):
|
||||
"""Tests that the registry API returns list of public images.
|
||||
|
@ -1148,15 +1148,15 @@ class TestRegistryRPC(base.IsolatedUnitTest):
|
|||
}]
|
||||
req.body = jsonutils.dumps(cmd)
|
||||
res = req.get_response(self.api)
|
||||
self.assertEqual(res.status_int, 200)
|
||||
self.assertEqual(200, res.status_int)
|
||||
res_dict = jsonutils.loads(res.body)[0]
|
||||
|
||||
images = res_dict
|
||||
self.assertEqual(len(images), 4)
|
||||
self.assertEqual(images[0]['id'], UUID3)
|
||||
self.assertEqual(images[1]['id'], UUID4)
|
||||
self.assertEqual(images[2]['id'], UUID2)
|
||||
self.assertEqual(images[3]['id'], UUID1)
|
||||
self.assertEqual(4, len(images))
|
||||
self.assertEqual(UUID3, images[0]['id'])
|
||||
self.assertEqual(UUID4, images[1]['id'])
|
||||
self.assertEqual(UUID2, images[2]['id'])
|
||||
self.assertEqual(UUID1, images[3]['id'])
|
||||
|
||||
def test_create_image(self):
|
||||
"""Tests that the registry API creates the image"""
|
||||
|
@ -1175,7 +1175,7 @@ class TestRegistryRPC(base.IsolatedUnitTest):
|
|||
req.body = jsonutils.dumps(cmd)
|
||||
res = req.get_response(self.api)
|
||||
|
||||
self.assertEqual(res.status_int, 200)
|
||||
self.assertEqual(200, res.status_int)
|
||||
|
||||
res_dict = jsonutils.loads(res.body)[0]
|
||||
|
||||
|
@ -1203,7 +1203,7 @@ class TestRegistryRPC(base.IsolatedUnitTest):
|
|||
req.body = jsonutils.dumps(cmd)
|
||||
|
||||
res = req.get_response(self.api)
|
||||
self.assertEqual(res.status_int, 200)
|
||||
self.assertEqual(200, res.status_int)
|
||||
|
||||
res_dict = jsonutils.loads(res.body)[0]
|
||||
|
||||
|
@ -1227,7 +1227,7 @@ class TestRegistryRPC(base.IsolatedUnitTest):
|
|||
req.body = jsonutils.dumps(cmd)
|
||||
|
||||
res = req.get_response(self.api)
|
||||
self.assertEqual(res.status_int, 200)
|
||||
self.assertEqual(200, res.status_int)
|
||||
|
||||
res_dict = jsonutils.loads(res.body)[0]
|
||||
|
||||
|
@ -1250,7 +1250,7 @@ class TestRegistryRPC(base.IsolatedUnitTest):
|
|||
req.body = jsonutils.dumps(cmd)
|
||||
|
||||
res = req.get_response(self.api)
|
||||
self.assertEqual(res.status_int, 200)
|
||||
self.assertEqual(200, res.status_int)
|
||||
|
||||
res_dict = jsonutils.loads(res.body)[0]
|
||||
|
||||
|
@ -1273,7 +1273,7 @@ class TestRegistryRPC(base.IsolatedUnitTest):
|
|||
req.body = jsonutils.dumps(cmd)
|
||||
|
||||
res = req.get_response(self.api)
|
||||
self.assertEqual(res.status_int, 200)
|
||||
self.assertEqual(200, res.status_int)
|
||||
|
||||
res_dict = jsonutils.loads(res.body)[0]
|
||||
|
||||
|
@ -1296,7 +1296,7 @@ class TestRegistryRPC(base.IsolatedUnitTest):
|
|||
req.body = jsonutils.dumps(cmd)
|
||||
|
||||
res = req.get_response(self.api)
|
||||
self.assertEqual(res.status_int, 200)
|
||||
self.assertEqual(200, res.status_int)
|
||||
|
||||
res_dict = jsonutils.loads(res.body)[0]
|
||||
|
||||
|
@ -1319,7 +1319,7 @@ class TestRegistryRPC(base.IsolatedUnitTest):
|
|||
req.body = jsonutils.dumps(cmd)
|
||||
res = req.get_response(self.api)
|
||||
res_dict = jsonutils.loads(res.body)[0]
|
||||
self.assertEqual(res.status_int, 200)
|
||||
self.assertEqual(200, res.status_int)
|
||||
|
||||
orig_num_images = len(res_dict)
|
||||
|
||||
|
@ -1331,7 +1331,7 @@ class TestRegistryRPC(base.IsolatedUnitTest):
|
|||
req.body = jsonutils.dumps(cmd)
|
||||
|
||||
res = req.get_response(self.api)
|
||||
self.assertEqual(res.status_int, 200)
|
||||
self.assertEqual(200, res.status_int)
|
||||
|
||||
# Verify one less image
|
||||
cmd = [{
|
||||
|
@ -1341,7 +1341,7 @@ class TestRegistryRPC(base.IsolatedUnitTest):
|
|||
req.body = jsonutils.dumps(cmd)
|
||||
res = req.get_response(self.api)
|
||||
res_dict = jsonutils.loads(res.body)[0]
|
||||
self.assertEqual(res.status_int, 200)
|
||||
self.assertEqual(200, res.status_int)
|
||||
|
||||
new_num_images = len(res_dict)
|
||||
self.assertEqual(new_num_images, orig_num_images - 1)
|
||||
|
@ -1359,7 +1359,7 @@ class TestRegistryRPC(base.IsolatedUnitTest):
|
|||
req.body = jsonutils.dumps(cmd)
|
||||
res = req.get_response(self.api)
|
||||
|
||||
self.assertEqual(res.status_int, 200)
|
||||
self.assertEqual(200, res.status_int)
|
||||
deleted_image = jsonutils.loads(res.body)[0]
|
||||
|
||||
self.assertEqual(image['id'], deleted_image['id'])
|
||||
|
@ -1377,7 +1377,7 @@ class TestRegistryRPC(base.IsolatedUnitTest):
|
|||
req.body = jsonutils.dumps(cmd)
|
||||
|
||||
res = req.get_response(self.api)
|
||||
self.assertEqual(res.status_int, 200)
|
||||
self.assertEqual(200, res.status_int)
|
||||
|
||||
memb_list = jsonutils.loads(res.body)[0]
|
||||
self.assertEqual(len(memb_list), 0)
|
||||
self.assertEqual(0, len(memb_list))
|
||||
|
|
|
@ -88,7 +88,7 @@ class TestRegistryV2Client(base.IsolatedUnitTest,
|
|||
def test_image_get_index(self):
|
||||
"""Test correct set of public image returned"""
|
||||
images = self.client.image_get_all()
|
||||
self.assertEqual(len(images), 2)
|
||||
self.assertEqual(2, len(images))
|
||||
|
||||
def test_create_image_with_null_min_disk_min_ram(self):
|
||||
UUID3 = _gen_uuid()
|
||||
|
@ -306,7 +306,7 @@ class TestRegistryV2Client(base.IsolatedUnitTest,
|
|||
db_api.image_create(self.context, extra_fixture)
|
||||
|
||||
images = self.client.image_get_all(limit=2)
|
||||
self.assertEqual(len(images), 2)
|
||||
self.assertEqual(2, len(images))
|
||||
|
||||
def test_image_get_index_marker_limit(self):
|
||||
"""Test correct set of images returned with marker/limit params."""
|
||||
|
@ -346,7 +346,7 @@ class TestRegistryV2Client(base.IsolatedUnitTest,
|
|||
db_api.image_create(self.context, extra_fixture)
|
||||
|
||||
images = self.client.image_get_all(limit=None)
|
||||
self.assertEqual(len(images), 4)
|
||||
self.assertEqual(4, len(images))
|
||||
|
||||
def test_image_get_index_by_name(self):
|
||||
"""Test correct set of public, name-filtered image returned.
|
||||
|
@ -359,7 +359,7 @@ class TestRegistryV2Client(base.IsolatedUnitTest,
|
|||
db_api.image_create(self.context, extra_fixture)
|
||||
|
||||
images = self.client.image_get_all(filters={'name': 'new name! #123'})
|
||||
self.assertEqual(len(images), 1)
|
||||
self.assertEqual(1, len(images))
|
||||
|
||||
for image in images:
|
||||
self.assertEqual('new name! #123', image['name'])
|
||||
|
@ -374,7 +374,7 @@ class TestRegistryV2Client(base.IsolatedUnitTest,
|
|||
|
||||
filters = {'is_public': 'avalue'}
|
||||
images = self.client.image_get_all(filters=filters)
|
||||
self.assertEqual(len(images), 1)
|
||||
self.assertEqual(1, len(images))
|
||||
|
||||
for image in images:
|
||||
self.assertEqual('avalue', image['properties'][0]['value'])
|
||||
|
@ -479,7 +479,7 @@ class TestRegistryV2Client(base.IsolatedUnitTest,
|
|||
|
||||
image = self.client.image_get(image_id=UUID2)
|
||||
current = image['status']
|
||||
self.assertEqual(current, 'active')
|
||||
self.assertEqual('active', current)
|
||||
|
||||
# image is in 'active' state so this should cause a failure.
|
||||
from_state = 'saving'
|
||||
|
@ -537,7 +537,7 @@ class TestRegistryV2Client(base.IsolatedUnitTest,
|
|||
"""Tests getting image members"""
|
||||
memb_list = self.client.image_member_find(image_id=UUID2)
|
||||
num_members = len(memb_list)
|
||||
self.assertEqual(num_members, 0)
|
||||
self.assertEqual(0, num_members)
|
||||
|
||||
def test_image_get_members_not_existing(self):
|
||||
"""Tests getting non-existent image members"""
|
||||
|
@ -549,7 +549,7 @@ class TestRegistryV2Client(base.IsolatedUnitTest,
|
|||
"""Tests getting member images"""
|
||||
memb_list = self.client.image_member_find(member='pattieblack')
|
||||
num_members = len(memb_list)
|
||||
self.assertEqual(num_members, 0)
|
||||
self.assertEqual(0, num_members)
|
||||
|
||||
def test_add_update_members(self):
|
||||
"""Tests updating image members"""
|
||||
|
@ -568,7 +568,7 @@ class TestRegistryV2Client(base.IsolatedUnitTest,
|
|||
|
||||
self.client.image_member_delete(memb_id=member['id'])
|
||||
memb_list = self.client.image_member_find(member='pattieblack')
|
||||
self.assertEqual(len(memb_list), 0)
|
||||
self.assertEqual(0, len(memb_list))
|
||||
|
||||
|
||||
class TestRegistryV2ClientApi(base.IsolatedUnitTest):
|
||||
|
@ -616,7 +616,7 @@ class TestRegistryV2ClientApi(base.IsolatedUnitTest):
|
|||
|
||||
self.assertIsNone(rapi._CLIENT_CREDS)
|
||||
rapi.configure_registry_admin_creds()
|
||||
self.assertEqual(rapi._CLIENT_CREDS, expected)
|
||||
self.assertEqual(expected, rapi._CLIENT_CREDS)
|
||||
|
||||
def test_configure_registry_admin_creds_with_auth_url(self):
|
||||
expected = self._get_fake_config_creds()
|
||||
|
@ -629,4 +629,4 @@ class TestRegistryV2ClientApi(base.IsolatedUnitTest):
|
|||
|
||||
self.assertIsNone(rapi._CLIENT_CREDS)
|
||||
rapi.configure_registry_admin_creds()
|
||||
self.assertEqual(rapi._CLIENT_CREDS, expected)
|
||||
self.assertEqual(expected, rapi._CLIENT_CREDS)
|
||||
|
|
|
@ -27,23 +27,23 @@ class TestSchemasController(test_utils.BaseTestCase):
|
|||
def test_image(self):
|
||||
req = unit_test_utils.get_fake_request()
|
||||
output = self.controller.image(req)
|
||||
self.assertEqual(output['name'], 'image')
|
||||
self.assertEqual('image', output['name'])
|
||||
expected = set(['status', 'name', 'tags', 'checksum', 'created_at',
|
||||
'disk_format', 'updated_at', 'visibility', 'self',
|
||||
'file', 'container_format', 'schema', 'id', 'size',
|
||||
'direct_url', 'min_ram', 'min_disk', 'protected',
|
||||
'locations', 'owner', 'virtual_size'])
|
||||
self.assertEqual(set(output['properties'].keys()), expected)
|
||||
self.assertEqual(expected, set(output['properties'].keys()))
|
||||
|
||||
def test_images(self):
|
||||
req = unit_test_utils.get_fake_request()
|
||||
output = self.controller.images(req)
|
||||
self.assertEqual(output['name'], 'images')
|
||||
self.assertEqual('images', output['name'])
|
||||
expected = set(['images', 'schema', 'first', 'next'])
|
||||
self.assertEqual(set(output['properties'].keys()), expected)
|
||||
self.assertEqual(expected, set(output['properties'].keys()))
|
||||
expected = set(['{schema}', '{first}', '{next}'])
|
||||
actual = set([link['href'] for link in output['links']])
|
||||
self.assertEqual(actual, expected)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_member(self):
|
||||
req = unit_test_utils.get_fake_request()
|
||||
|
|
|
@ -119,7 +119,7 @@ class TestTasksController(test_utils.BaseTestCase):
|
|||
self.assertEqual(1, len(output['tasks']))
|
||||
actual = set([task.task_id for task in output['tasks']])
|
||||
expected = set([UUID1])
|
||||
self.assertEqual(actual, expected)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_index_admin(self):
|
||||
request = unit_test_utils.get_fake_request(is_admin=True)
|
||||
|
@ -144,7 +144,7 @@ class TestTasksController(test_utils.BaseTestCase):
|
|||
self.assertEqual(2, len(output['tasks']))
|
||||
actual = set([task.task_id for task in output['tasks']])
|
||||
expected = set([UUID2, UUID1])
|
||||
self.assertEqual(actual, expected)
|
||||
self.assertEqual(expected, actual)
|
||||
self.assertEqual(UUID1, output['next_marker'])
|
||||
|
||||
def test_index_no_next_marker(self):
|
||||
|
@ -154,7 +154,7 @@ class TestTasksController(test_utils.BaseTestCase):
|
|||
self.assertEqual(0, len(output['tasks']))
|
||||
actual = set([task.task_id for task in output['tasks']])
|
||||
expected = set([])
|
||||
self.assertEqual(actual, expected)
|
||||
self.assertEqual(expected, actual)
|
||||
self.assertNotIn('next_marker', output)
|
||||
|
||||
def test_index_with_id_filter(self):
|
||||
|
@ -163,7 +163,7 @@ class TestTasksController(test_utils.BaseTestCase):
|
|||
self.assertEqual(1, len(output['tasks']))
|
||||
actual = set([task.task_id for task in output['tasks']])
|
||||
expected = set([UUID1])
|
||||
self.assertEqual(actual, expected)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_index_with_filters_return_many(self):
|
||||
path = '/tasks?status=pending'
|
||||
|
@ -186,7 +186,7 @@ class TestTasksController(test_utils.BaseTestCase):
|
|||
self.assertEqual(1, len(output['tasks']))
|
||||
actual = set([task.task_id for task in output['tasks']])
|
||||
expected = set([UUID1])
|
||||
self.assertEqual(actual, expected)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_index_with_marker(self):
|
||||
self.config(limit_param_default=1, api_limit_max=3)
|
||||
|
@ -228,7 +228,7 @@ class TestTasksController(test_utils.BaseTestCase):
|
|||
output = self.controller.index(request, sort_dir='asc', limit=3)
|
||||
actual = [task.task_id for task in output['tasks']]
|
||||
self.assertEqual(3, len(actual))
|
||||
self.assertEqual(actual, [UUID1, UUID2, UUID3])
|
||||
self.assertEqual([UUID1, UUID2, UUID3], actual)
|
||||
|
||||
def test_index_with_sort_key(self):
|
||||
path = '/tasks'
|
||||
|
@ -280,7 +280,7 @@ class TestTasksController(test_utils.BaseTestCase):
|
|||
|
||||
def test_get_not_allowed(self):
|
||||
request = unit_test_utils.get_fake_request()
|
||||
self.assertEqual(request.context.tenant, TENANT1)
|
||||
self.assertEqual(TENANT1, request.context.tenant)
|
||||
self.assertRaises(webob.exc.HTTPNotFound,
|
||||
self.controller.get, request, UUID4)
|
||||
|
||||
|
@ -327,10 +327,10 @@ class TestTasksController(test_utils.BaseTestCase):
|
|||
"image_from_format": "qcow2"}, task.task_input)
|
||||
output_logs = [nlog for nlog in self.notifier.get_logs()
|
||||
if nlog['event_type'] == 'task.create']
|
||||
self.assertEqual(len(output_logs), 1)
|
||||
self.assertEqual(1, len(output_logs))
|
||||
output_log = output_logs[0]
|
||||
self.assertEqual(output_log['notification_type'], 'INFO')
|
||||
self.assertEqual(output_log['event_type'], 'task.create')
|
||||
self.assertEqual('INFO', output_log['notification_type'])
|
||||
self.assertEqual('task.create', output_log['event_type'])
|
||||
|
||||
|
||||
class TestTasksControllerPolicies(base.IsolatedUnitTest):
|
||||
|
@ -414,14 +414,14 @@ class TestTasksDeserializer(test_utils.BaseTestCase):
|
|||
'sort_dir': 'desc',
|
||||
'filters': {}}
|
||||
output = self.deserializer.index(request)
|
||||
self.assertEqual(output, expected)
|
||||
self.assertEqual(expected, output)
|
||||
|
||||
def test_index_strip_params_from_filters(self):
|
||||
type = 'import'
|
||||
path = '/tasks?type=%s' % type
|
||||
request = unit_test_utils.get_fake_request(path)
|
||||
output = self.deserializer.index(request)
|
||||
self.assertEqual(output['filters']['type'], type)
|
||||
self.assertEqual(type, output['filters']['type'])
|
||||
|
||||
def test_index_with_many_filter(self):
|
||||
status = 'success'
|
||||
|
@ -430,16 +430,16 @@ class TestTasksDeserializer(test_utils.BaseTestCase):
|
|||
'type': type}
|
||||
request = unit_test_utils.get_fake_request(path)
|
||||
output = self.deserializer.index(request)
|
||||
self.assertEqual(output['filters']['status'], status)
|
||||
self.assertEqual(output['filters']['type'], type)
|
||||
self.assertEqual(status, output['filters']['status'])
|
||||
self.assertEqual(type, output['filters']['type'])
|
||||
|
||||
def test_index_with_filter_and_limit(self):
|
||||
status = 'success'
|
||||
path = '/tasks?status=%s&limit=1' % status
|
||||
request = unit_test_utils.get_fake_request(path)
|
||||
output = self.deserializer.index(request)
|
||||
self.assertEqual(output['filters']['status'], status)
|
||||
self.assertEqual(output['limit'], 1)
|
||||
self.assertEqual(status, output['filters']['status'])
|
||||
self.assertEqual(1, output['limit'])
|
||||
|
||||
def test_index_non_integer_limit(self):
|
||||
request = unit_test_utils.get_fake_request('/tasks?limit=blah')
|
||||
|
@ -477,7 +477,7 @@ class TestTasksDeserializer(test_utils.BaseTestCase):
|
|||
path = '/tasks?marker=%s' % marker
|
||||
request = unit_test_utils.get_fake_request(path)
|
||||
output = self.deserializer.index(request)
|
||||
self.assertEqual(output.get('marker'), marker)
|
||||
self.assertEqual(marker, output.get('marker'))
|
||||
|
||||
def test_index_marker_not_specified(self):
|
||||
request = unit_test_utils.get_fake_request('/tasks')
|
||||
|
@ -497,7 +497,7 @@ class TestTasksDeserializer(test_utils.BaseTestCase):
|
|||
'sort_dir': 'desc',
|
||||
'filters': {}
|
||||
}
|
||||
self.assertEqual(output, expected)
|
||||
self.assertEqual(expected, output)
|
||||
|
||||
def test_index_sort_dir_asc(self):
|
||||
request = unit_test_utils.get_fake_request('/tasks?sort_dir=asc')
|
||||
|
@ -506,7 +506,7 @@ class TestTasksDeserializer(test_utils.BaseTestCase):
|
|||
'sort_key': 'created_at',
|
||||
'sort_dir': 'asc',
|
||||
'filters': {}}
|
||||
self.assertEqual(output, expected)
|
||||
self.assertEqual(expected, output)
|
||||
|
||||
def test_index_sort_dir_bad_value(self):
|
||||
request = unit_test_utils.get_fake_request('/tasks?sort_dir=invalid')
|
||||
|
|
Loading…
Reference in New Issue