def test_validate_image_status_before_upload_ok_v2_using_uwsgi(self):
mock_conn = mock.Mock()
fake_url = 'http://fake_host/fake_path/fake_image_id'
mock_check_resp_status_and_retry = self.mock_patch_object(
self.glance, 'check_resp_status_and_retry')
mock_head_resp = mock.Mock()
mock_head_resp.status = httplib.OK
mock_head_resp.read.return_value = '{"status": "queued"}'
mock_conn.getresponse.return_value = mock_head_resp
fake_extra_headers = mock.Mock()
fake_patch_path = 'fake_patch_path'
self.glance.validate_image_status_before_upload_v2(
mock_conn, fake_url, fake_extra_headers, fake_patch_path)
self.assertTrue(mock_conn.getresponse.called)
self.assertEqual(
mock_head_resp.read.call_count, 2)
self.assertFalse(mock_check_resp_status_and_retry.called)
mock_conn.request.assert_called_with('GET',
'fake_patch_path',
headers=fake_extra_headers)
评论列表
文章目录