Revision 3a8e56bc

b/docs/quota-api-guide.rst
258 258
``itemNotFound`` (404), the returned cloudFault contains an extra field
259 259
``data`` with additional application-specific information. It contains at
260 260
least the ``provision`` that is to blame and the actual ``name`` of the
261
exception raised. In case of ``NoCapacityError``, ``limit`` and ``usage`` are
262
also included; in case of ``NoQuantityError`` (that is, when attempting to
263
release a value greater than what is registered), the ``available`` quantity
264
is provided.
261
exception raised. In the case of ``overLimit``, ``limit`` and ``usage`` are
262
also included.
265 263

  
266 264
**Example Successful Response**:
267 265

  
b/snf-astakos-app/astakos/quotaholder_app/commission.py
118 118
            provision = cls.provision(holding, quantity, importing=False)
119 119
            raise NoQuantityError(m,
120 120
                                  provision=provision,
121
                                  available=usage_min)
121
                                  limit=0,
122
                                  usage=usage_min)
122 123

  
123 124
        holding.usage_min = new_usage_min
124 125
        holding.save()
b/snf-astakos-app/astakos/quotaholder_app/exception.py
63 63
        QuotaholderError.__init__(self, *args, **kwargs)
64 64

  
65 65

  
66
class NoCapacityError(CommissionException):
66
class OverLimitError(CommissionException):
67 67
    def __init__(self, *args, **kwargs):
68 68
        self.add_data(kwargs, 'usage')
69 69
        self.add_data(kwargs, 'limit')
70 70
        CommissionException.__init__(self, *args, **kwargs)
71 71

  
72 72

  
73
class NoQuantityError(CommissionException):
74
    def __init__(self, *args, **kwargs):
75
        self.add_data(kwargs, 'available')
76
        CommissionException.__init__(self, *args, **kwargs)
73
class NoCapacityError(OverLimitError):
74
    pass
75

  
76

  
77
class NoQuantityError(OverLimitError):
78
    pass
77 79

  
78 80

  
79 81
class NoHoldingError(CommissionException):
b/snf-astakos-app/astakos/quotaholder_app/tests.py
124 124
        self.assertEqual(provision['source'], source)
125 125
        self.assertEqual(provision['resource'], resource1)
126 126
        self.assertEqual(provision['quantity'], -1)
127
        self.assertEqual(e.data['available'], 0)
127
        self.assertEqual(e.data['usage'], 0)
128
        self.assertEqual(e.data['limit'], 0)
128 129

  
129 130
        with self.assertRaises(NoHoldingError) as cm:
130 131
            self.issue_commission([((holder, source, resource1), 1),

Also available in: Unified diff