summaryrefslogtreecommitdiff
path: root/glance/tests/functional/ft_utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'glance/tests/functional/ft_utils.py')
-rw-r--r--glance/tests/functional/ft_utils.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/glance/tests/functional/ft_utils.py b/glance/tests/functional/ft_utils.py
index ea0791d..edbfe5b 100644
--- a/glance/tests/functional/ft_utils.py
+++ b/glance/tests/functional/ft_utils.py
@@ -13,6 +13,7 @@
13# License for the specific language governing permissions and limitations 13# License for the specific language governing permissions and limitations
14# under the License. 14# under the License.
15 15
16import six
16import time 17import time
17 18
18from oslo_serialization import jsonutils 19from oslo_serialization import jsonutils
@@ -20,6 +21,33 @@ import requests
20from six.moves import http_client as http 21from six.moves import http_client as http
21 22
22 23
24def verify_image_hashes_and_status(
25 test_obj, image_id, checksum=None, os_hash_value=None, status=None,
26 os_hash_algo='sha512'):
27 """Makes image-detail request and checks response.
28
29 :param test_obj: The test object; expected to have _url() and
30 _headers() defined on it
31 :param image_id: Image id to use in the request
32 :param checksum: Expected checksum (default: None)
33 :param os_hash_value: Expected multihash value (default: None)
34 :param status: Expected status (default: None)
35 :param os_hash_algo: Expected value of os_hash_algo; only checked when
36 os_hash_value is not None (default: 'sha512')
37 """
38 path = test_obj._url('/v2/images/%s' % image_id)
39 response = requests.get(path, headers=test_obj._headers())
40 test_obj.assertEqual(http.OK, response.status_code)
41 image = jsonutils.loads(response.text)
42 test_obj.assertEqual(checksum, image['checksum'])
43 if os_hash_value:
44 # make sure we're using the hashing_algorithm we expect
45 test_obj.assertEqual(six.text_type(os_hash_algo),
46 image['os_hash_algo'])
47 test_obj.assertEqual(os_hash_value, image['os_hash_value'])
48 test_obj.assertEqual(status, image['status'])
49
50
23def wait_for_status(request_path, request_headers, status='active', 51def wait_for_status(request_path, request_headers, status='active',
24 max_sec=10, delay_sec=0.2, start_delay_sec=None): 52 max_sec=10, delay_sec=0.2, start_delay_sec=None):
25 """ 53 """