Example #1
0
 def test_get_quota_class(self, mock_db_inst,
                          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)
     mock_read.side_effect = lambda *args: utils.FakeEtcdResult(
         quota_class.as_dict())
     res = dbapi.quota_class_get(self.context, quota_class.class_name,
                                 quota_class.resource)
     self.assertEqual(quota_class.hard_limit, res.hard_limit)
Example #2
0
    def get(cls, context, class_name, resource):
        """Find a quota class based on class_name and resource name.

        :param class_name: the name of class.
        :param context: security context.
        :param resource: the name of resource.
        :returns: a :class:`QuotaClass` object.
        """
        db_quota_class = dbapi.quota_class_get(context, class_name, resource)
        quota_class = QuotaClass._from_db_method(cls(context), db_quota_class)
        return quota_class
Example #3
0
 def test_get_quota_class(self):
     quota_class = utils.create_test_quota_class(context=self.ctx,
                                                 class_name=self.class_name,
                                                 resource=self.resource,
                                                 limit=self.limit)
     res = dbapi.quota_class_get(context=self.ctx,
                                 class_name=quota_class.class_name,
                                 resource=quota_class.resource)
     self.assertEqual(quota_class.class_name, res.class_name)
     self.assertEqual(quota_class.resource, res.resource)
     self.assertEqual(quota_class.hard_limit, res.hard_limit)
Example #4
0
    def get(cls, context, class_name, resource):
        """Find a quota class based on class_name and resource name.

        :param class_name: the name of class.
        :param context: security context.
        :param resource: the name of resource.
        :returns: a :class:`QuotaClass` object.
        """
        db_quota_class = dbapi.quota_class_get(context, class_name, resource)
        quota_class = QuotaClass._from_db_method(cls(context), db_quota_class)
        return quota_class
Example #5
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)