Tests: Fix backup validation with hash randomization

The exact error generated here can vary depending on
Python version, jsonschema version, and hash randomization.

Ensure that a useful message and HTTP 400 is still
generated.

Change-Id: Ibc6c20e6ffce58c6bbef3155f73e54909d76e132
This commit is contained in:
Eric Harney 2018-02-20 12:14:45 -05:00
parent 9eeda1db92
commit 5abef92e08
1 changed files with 6 additions and 9 deletions

View File

@ -1446,7 +1446,7 @@ class BackupsAPITestCase(test.TestCase):
req = webob.Request.blank('/v2/%s/backups/%s/restore' % (
fake.PROJECT_ID, backup.id))
body = {"": {}}
body = {"restore": {'': ''}}
req.method = 'POST'
req.headers['Content-Type'] = 'application/json'
req.headers['Accept'] = 'application/json'
@ -1459,14 +1459,11 @@ class BackupsAPITestCase(test.TestCase):
self.assertEqual(http_client.BAD_REQUEST, res.status_int)
self.assertEqual(http_client.BAD_REQUEST,
res_dict['badRequest']['code'])
if six.PY3:
self.assertEqual("Additional properties are not allowed "
"('' was unexpected)",
res_dict['badRequest']['message'])
else:
self.assertEqual("Additional properties are not allowed "
"(u'' was unexpected)",
res_dict['badRequest']['message'])
self.assertIn("Additional properties are not allowed ",
res_dict['badRequest']['message'])
self.assertIn("'' was unexpected)",
res_dict['badRequest']['message'])
@mock.patch('cinder.db.service_get_all')
@mock.patch('cinder.volume.api.API.create')