diff options
author | Lars Wirzenius <liw@liw.fi> | 2019-03-09 09:55:21 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2019-03-09 09:55:21 +0200 |
commit | da23a56ebcc767a76a86ae42a1839221ab126119 (patch) | |
tree | 54c2a9a719f9c98b7af662bc1f8bfef3ae325206 | |
parent | a1613e514ef1c1db4ce03fa72defe065da73a3c3 (diff) | |
download | effi-reg-da23a56ebcc767a76a86ae42a1839221ab126119.tar.gz |
Change: handle faked /status calls without crashing
-rwxr-xr-x | effiapi | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -95,13 +95,19 @@ class FakeHTTPAPI(HTTPAPI): raise NotImplementedError() def GET(self, url, headers=None, body=None): + logging.info( + 'FakeHTTPAPI.GET url=%r headers=%r body=%r', + url, headers, body) + if headers is None: + logging.warning('FakeHTTPAPI.GET: no resource id in headers') return FakeResponse(400, {}, 'Missing headers') - logging.debug('GET headers %r', headers) + rid = headers.get('Muck-Id') - logging.info('GET for %r', rid) if not rid: + logging.warning('FakeHTTPAPI.GET: empty resource id in headers') return FakeResponse(404, {}, 'No such member') + memb = self._memb[rid] headers = { 'Muck-Id': rid, @@ -146,7 +152,9 @@ class MuckAPI: def status(self): url = self.url('/status') r = self._httpapi.GET(url) - return r.json() + if r.ok: + return r.json() + return {'resources': 0} def show(self, rid): url = self.url('/res') |