Remove using of UUID field in POST methods of Watcher API

This patch set removes the possibility of using UUID field
in POST methods of Watcher API.

Closes-Bug: #1572625

Change-Id: I88a8aa5346e937e3e9409b55da3316cbe1ed832a
This commit is contained in:
Alexander Chadin
2016-04-21 18:57:42 +03:00
parent 87087e9add
commit aaaf3f1c84
8 changed files with 43 additions and 36 deletions

View File

@@ -392,6 +392,7 @@ class TestPost(api_base.FunctionalTest):
audit_template_dict = api_utils.audit_template_post_data()
test_time = datetime.datetime(2000, 1, 1, 0, 0)
mock_utcnow.return_value = test_time
del audit_template_dict['uuid']
response = self.post_json('/audit_templates', audit_template_dict)
self.assertEqual('application/json', response.content_type)
@@ -399,10 +400,9 @@ class TestPost(api_base.FunctionalTest):
# Check location header
self.assertIsNotNone(response.location)
expected_location = \
'/v1/audit_templates/%s' % audit_template_dict['uuid']
'/v1/audit_templates/%s' % response.json['uuid']
self.assertEqual(urlparse.urlparse(response.location).path,
expected_location)
self.assertEqual(audit_template_dict['uuid'], response.json['uuid'])
self.assertNotIn('updated_at', response.json.keys)
self.assertNotIn('deleted_at', response.json.keys)
return_created_at = timeutils.parse_isotime(
@@ -417,6 +417,7 @@ class TestPost(api_base.FunctionalTest):
) as cn_mock:
audit_template_dict = api_utils.audit_template_post_data(
goal='DUMMY')
del audit_template_dict['uuid']
response = self.post_json('/audit_templates', audit_template_dict)
self.assertEqual(audit_template_dict['goal'],
response.json['goal'])
@@ -447,6 +448,20 @@ class TestPost(api_base.FunctionalTest):
self.assertEqual(400, response.status_int)
assert not cn_mock.called
def test_create_audit_template_with_uuid(self):
with mock.patch.object(
self.dbapi,
'create_audit_template',
wraps=self.dbapi.create_audit_template
) as cn_mock:
audit_template_dict = api_utils.audit_template_post_data()
response = self.post_json('/audit_templates', audit_template_dict,
expect_errors=True)
self.assertEqual('application/json', response.content_type)
self.assertEqual(400, response.status_int)
assert not cn_mock.called
class TestDelete(api_base.FunctionalTest):