Revision ab85ce39
b/lib/rapi/baserlib.py | ||
---|---|---|
274 | 274 |
POST_ACCESS = [rapi.RAPI_ACCESS_WRITE] |
275 | 275 |
DELETE_ACCESS = [rapi.RAPI_ACCESS_WRITE] |
276 | 276 |
|
277 |
def __init__(self, items, queryargs, req): |
|
277 |
def __init__(self, items, queryargs, req, _client_cls=luxi.Client):
|
|
278 | 278 |
"""Generic resource constructor. |
279 | 279 |
|
280 | 280 |
@param items: a list with variables encoded in the URL |
281 | 281 |
@param queryargs: a dictionary with additional options from URL |
282 |
@param req: Request context |
|
283 |
@param _client_cls: L{luxi} client class (unittests only) |
|
282 | 284 |
|
283 | 285 |
""" |
284 | 286 |
self.items = items |
285 | 287 |
self.queryargs = queryargs |
286 | 288 |
self._req = req |
289 |
self._client_cls = _client_cls |
|
287 | 290 |
|
288 | 291 |
def _GetRequestBody(self): |
289 | 292 |
"""Returns the body data. |
... | ... | |
366 | 369 |
""" |
367 | 370 |
# Could be a function, pylint: disable=R0201 |
368 | 371 |
try: |
369 |
return luxi.Client()
|
|
372 |
return self._client_cls()
|
|
370 | 373 |
except luxi.NoMasterError, err: |
371 | 374 |
raise http.HttpBadGateway("Can't connect to master daemon: %s" % err) |
372 | 375 |
except luxi.PermissionError: |
Also available in: Unified diff