Merge "Test code tidy up"
This commit is contained in:
@@ -360,7 +360,7 @@ class TestPatch(api_base.FunctionalTest):
|
||||
test_time = datetime.datetime(2000, 1, 1, 0, 0)
|
||||
mock_utcnow.return_value = test_time
|
||||
|
||||
new_state = 'DELETED'
|
||||
new_state = objects.action_plan.State.DELETED
|
||||
response = self.get_json(
|
||||
'/action_plans/%s' % self.action_plan.uuid)
|
||||
self.assertNotEqual(new_state, response['state'])
|
||||
@@ -591,7 +591,9 @@ class TestActionPlanPolicyEnforcement(api_base.FunctionalTest):
|
||||
self._common_policy_check(
|
||||
"action_plan:update", self.patch_json,
|
||||
'/action_plans/%s' % action_plan.uuid,
|
||||
[{'path': '/state', 'value': 'DELETED', 'op': 'replace'}],
|
||||
[{'path': '/state',
|
||||
'value': objects.action_plan.State.DELETED,
|
||||
'op': 'replace'}],
|
||||
expect_errors=True)
|
||||
|
||||
def test_policy_disallow_delete(self):
|
||||
|
||||
@@ -636,35 +636,6 @@ class TestPost(api_base.FunctionalTest):
|
||||
return audit_template
|
||||
|
||||
|
||||
# class TestDelete(api_base.FunctionalTest):
|
||||
|
||||
# def setUp(self):
|
||||
# super(TestDelete, self).setUp()
|
||||
# self.audit = obj_utils.create_test_audit(self.context)
|
||||
# p = mock.patch.object(db_api.Connection, 'destroy_audit')
|
||||
# self.mock_audit_delete = p.start()
|
||||
# self.mock_audit_delete.side_effect = self._simulate_rpc_audit_delete
|
||||
# self.addCleanup(p.stop)
|
||||
|
||||
# def _simulate_rpc_audit_delete(self, audit_uuid):
|
||||
# audit = objects.Audit.get_by_uuid(self.context, audit_uuid)
|
||||
# audit.destroy()
|
||||
|
||||
# def test_delete_audit(self):
|
||||
# self.delete('/audits/%s' % self.audit.uuid)
|
||||
# response = self.get_json('/audits/%s' % self.audit.uuid,
|
||||
# expect_errors=True)
|
||||
# self.assertEqual(404, response.status_int)
|
||||
# self.assertEqual('application/json', response.content_type)
|
||||
# self.assertTrue(response.json['error_message'])
|
||||
|
||||
# def test_delete_audit_not_found(self):
|
||||
# uuid = utils.generate_uuid()
|
||||
# response = self.delete('/audits/%s' % uuid, expect_errors=True)
|
||||
# self.assertEqual(404, response.status_int)
|
||||
# self.assertEqual('application/json', response.content_type)
|
||||
# self.assertTrue(response.json['error_message'])
|
||||
|
||||
class TestDelete(api_base.FunctionalTest):
|
||||
|
||||
def setUp(self):
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
|
||||
import mock
|
||||
from watcher.common import exception
|
||||
# from watcher.common import utils as w_utils
|
||||
from watcher import objects
|
||||
from watcher.objects import action as actionobject
|
||||
from watcher.tests.db import base
|
||||
from watcher.tests.db import utils
|
||||
|
||||
@@ -91,12 +91,12 @@ class TestActionObject(base.DbTestCase):
|
||||
with mock.patch.object(self.dbapi, 'update_action',
|
||||
autospec=True) as mock_update_action:
|
||||
action = objects.Action.get_by_uuid(self.context, uuid)
|
||||
action.state = 'SUCCEEDED'
|
||||
action.state = actionobject.State.SUCCEEDED
|
||||
action.save()
|
||||
|
||||
mock_get_action.assert_called_once_with(self.context, uuid)
|
||||
mock_update_action.assert_called_once_with(
|
||||
uuid, {'state': 'SUCCEEDED'})
|
||||
uuid, {'state': actionobject.State.SUCCEEDED})
|
||||
self.assertEqual(self.context, action._context)
|
||||
|
||||
def test_refresh(self):
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
|
||||
import mock
|
||||
from watcher.common import exception
|
||||
# from watcher.common import utils as w_utils
|
||||
from watcher import objects
|
||||
from watcher.objects import action_plan as apobjects
|
||||
from watcher.tests.db import base
|
||||
from watcher.tests.db import utils
|
||||
|
||||
@@ -145,13 +145,13 @@ class TestActionPlanObject(base.DbTestCase):
|
||||
autospec=True) as mock_update_action_plan:
|
||||
action_plan = objects.ActionPlan.get_by_uuid(
|
||||
self.context, uuid)
|
||||
action_plan.state = 'SUCCEEDED'
|
||||
action_plan.state = apobjects.State.SUCCEEDED
|
||||
action_plan.save()
|
||||
|
||||
mock_get_action_plan.assert_called_once_with(
|
||||
self.context, uuid)
|
||||
mock_update_action_plan.assert_called_once_with(
|
||||
uuid, {'state': 'SUCCEEDED'})
|
||||
uuid, {'state': apobjects.State.SUCCEEDED})
|
||||
self.assertEqual(self.context, action_plan._context)
|
||||
|
||||
def test_refresh(self):
|
||||
|
||||
Reference in New Issue
Block a user