Merge "Fix updating Qos policy to be default/not default"

This commit is contained in:
Jenkins 2017-06-02 20:26:19 +00:00 committed by Gerrit Code Review
commit 3326292c33
3 changed files with 5 additions and 3 deletions

View File

@ -186,7 +186,7 @@ class QoSPlugin(qos.QoSPluginBase):
"""
policy_data = policy['policy']
with db_api.context_manager.writer.using(context):
policy_obj = policy_object.QosPolicy(context, id=policy_id)
policy_obj = self._get_policy_obj(context, policy_id)
policy_obj.update_fields(policy_data, reset_changes=True)
policy_obj.update()
self.driver_manager.call(qos_consts.UPDATE_POLICY_PRECOMMIT,

View File

@ -330,7 +330,7 @@ class TestQoSPolicyIsDefault(base.BaseFullStackTestCase):
qos_policy = self._create_qos_policy(project_id, True)
self.assertTrue(qos_policy['is_default'])
qos_policy = self._update_qos_policy(qos_policy['id'], False)
self.assertTrue(qos_policy['policy']['is_default'])
self.assertFalse(qos_policy['policy']['is_default'])
def test_update_default_status_conflict(self):
project_id = uuidutils.generate_uuid()

View File

@ -359,12 +359,14 @@ class TestQosPlugin(base.BaseQosTestCase):
QosMocked.assert_called_once_with(self.ctxt, **policy_details)
@mock.patch.object(policy_object.QosPolicy, "get_object")
@mock.patch(
'neutron.objects.rbac_db.RbacNeutronDbObjectMixin'
'.create_rbac_policy')
@mock.patch.object(policy_object.QosPolicy, 'update')
def test_update_policy(self, mock_qos_policy_update,
mock_create_rbac_policy):
mock_create_rbac_policy, mock_qos_policy_get):
mock_qos_policy_get.return_value = self.policy
mock_manager = mock.Mock()
mock_manager.attach_mock(mock_qos_policy_update, 'update')
mock_manager.attach_mock(self.qos_plugin.driver_manager, 'driver')