Use Enum value instead of String Value

Fixing Gating Issue.

Change-Id: I64a0df9e27e09172119a3a8f5395204b7476f23d
This commit is contained in:
Atul Pandey
2016-10-24 15:34:51 +05:30
parent 86f4f6a979
commit aae3f79fef
9 changed files with 44 additions and 39 deletions

View File

@@ -20,6 +20,7 @@ from wsme import types as wtypes
from watcher.api.controllers.v1 import action as api_action
from watcher.common import utils
from watcher.db import api as db_api
from watcher import objects
from watcher.tests.api import base as api_base
from watcher.tests.api import utils as api_utils
from watcher.tests import base
@@ -444,8 +445,7 @@ class TestPatch(api_base.FunctionalTest):
def test_patch_not_allowed(self, mock_utcnow):
test_time = datetime.datetime(2000, 1, 1, 0, 0)
mock_utcnow.return_value = test_time
new_state = 'SUBMITTED'
new_state = objects.audit.State.SUBMITTED
response = self.get_json('/actions/%s' % self.action.uuid)
self.assertNotEqual(new_state, response['state'])

View File

@@ -693,8 +693,8 @@ class TestAuaditTemplatePolicyEnforcement(api_base.FunctionalTest):
self._common_policy_check(
"audit_template:update", self.patch_json,
'/audit_templates/%s' % audit_template.uuid,
[{'path': '/state', 'value': 'SUBMITTED', 'op': 'replace'}],
expect_errors=True)
[{'path': '/state', 'value': objects.audit.State.SUBMITTED,
'op': 'replace'}], expect_errors=True)
def test_policy_disallow_create(self):
fake_goal1 = obj_utils.get_test_goal(

View File

@@ -265,7 +265,7 @@ class TestPatch(api_base.FunctionalTest):
test_time = datetime.datetime(2000, 1, 1, 0, 0)
mock_utcnow.return_value = test_time
new_state = 'SUBMITTED'
new_state = objects.audit.State.SUBMITTED
response = self.get_json('/audits/%s' % self.audit.uuid)
self.assertNotEqual(new_state, response['state'])
@@ -283,16 +283,16 @@ class TestPatch(api_base.FunctionalTest):
self.assertEqual(test_time, return_updated_at)
def test_replace_non_existent_audit(self):
response = self.patch_json('/audits/%s' % utils.generate_uuid(),
[{'path': '/state', 'value': 'SUBMITTED',
'op': 'replace'}],
expect_errors=True)
response = self.patch_json(
'/audits/%s' % utils.generate_uuid(),
[{'path': '/state', 'value': objects.audit.State.SUBMITTED,
'op': 'replace'}], expect_errors=True)
self.assertEqual(404, response.status_int)
self.assertEqual('application/json', response.content_type)
self.assertTrue(response.json['error_message'])
def test_add_ok(self):
new_state = 'SUCCEEDED'
new_state = objects.audit.State.SUCCEEDED
response = self.patch_json(
'/audits/%s' % self.audit.uuid,
[{'path': '/state', 'value': new_state, 'op': 'add'}])
@@ -667,7 +667,7 @@ class TestDelete(api_base.FunctionalTest):
return_deleted_at = timeutils.strtime(audit['deleted_at'])
self.assertEqual(timeutils.strtime(test_time), return_deleted_at)
self.assertEqual('DELETED', audit['state'])
self.assertEqual(objects.audit.State.DELETED, audit['state'])
def test_delete_audit_not_found(self):
uuid = utils.generate_uuid()
@@ -714,8 +714,8 @@ class TestAuaditPolicyEnforcement(api_base.FunctionalTest):
self._common_policy_check(
"audit:update", self.patch_json,
'/audits/%s' % audit.uuid,
[{'path': '/state', 'value': 'SUBMITTED', 'op': 'replace'}],
expect_errors=True)
[{'path': '/state', 'value': objects.audit.State.SUBMITTED,
'op': 'replace'}], expect_errors=True)
def test_policy_disallow_create(self):
audit_dict = post_get_test_audit(state=objects.audit.State.PENDING)