예제 #1
0
 def test_update_quota_class(self):
     quota_class = utils.create_test_quota_class(context=self.ctx,
                                                 class_name=self.class_name,
                                                 resource=self.resource,
                                                 limit=self.limit)
     dbapi.quota_class_update(
         self.ctx, quota_class.class_name,
         quota_class.resource, 200)
     updated_quota_class = dbapi.quota_class_get(
         self.ctx, quota_class.class_name,
         quota_class.resource)
     self.assertEqual(updated_quota_class.hard_limit, 200)
예제 #2
0
 def test_update_quota_class(self, mock_db_inst, mock_update,
                             mock_write, mock_read):
     mock_db_inst.return_value = etcdapi.get_backend()
     mock_read.side_effect = etcd.EtcdKeyNotFound
     quota_class = utils.create_test_quota_class(context=self.context)
     new_hard_limit = 60
     mock_read.side_effect = lambda *args: utils.FakeEtcdResult(
         quota_class.as_dict())
     dbapi.quota_class_update(self.context, quota_class.class_name,
                              quota_class.resource, new_hard_limit)
     self.assertEqual(new_hard_limit,
                      json.loads(mock_update.call_args_list[0][0][0].
                                 value.decode('utf-8'))['hard_limit'])
예제 #3
0
    def update(self, context=None):
        """Save updates to this QuotaClass.

        Updates will be made column by column based on the result
        of self.what_changed().

        :param context: security context. NOTE: This should only be
                        used internally by the indirection api.
                        Unfortunately, RPC requires context as the first
                        argument, even though we don't use it.
                        A context should be set when instantiating the
                        object, e.g.: QuotaClass(context)
        """
        updates = self.obj_get_changes()
        limit = updates.get('hard_limit')
        dbapi.quota_class_update(context, self.class_name,
                                 self.resource, limit)
예제 #4
0
    def update(self, context=None):
        """Save updates to this QuotaClass.

        Updates will be made column by column based on the result
        of self.what_changed().

        :param context: security context. NOTE: This should only be
                        used internally by the indirection api.
                        Unfortunately, RPC requires context as the first
                        argument, even though we don't use it.
                        A context should be set when instantiating the
                        object, e.g.: QuotaClass(context)
        """
        updates = self.obj_get_changes()
        limit = updates.get('hard_limit')
        dbapi.quota_class_update(context, self.class_name,
                                 self.resource, limit)
        self.obj_reset_changes()