示例#1
0
    def test_CrashlogViewAction(self):
        storage = mock()
        action = crashlog.View(storage, **{'name': 'AppName', 'timestamp': '10000'})
        when(storage).find(any(str), any(list)).thenReturn([
            '10000:hash1',
            '20000:hash2'
        ])
        when(storage).read(any(str), any(str)).thenReturn('content')
        action.execute().get()

        verify(storage).find('crashlogs', ['AppName'])
        verify(storage).read('crashlogs', '10000:hash1')
示例#2
0
def crashlog_view(info, response):
    try:
        name = info['name']
        timestamp = info['timestamp']
        data = yield crashlog.View(storage, name, timestamp).execute()
        encoded = msgpack.unpackb(data)
    except Exception as err:
        log.error(repr(err))
        response.error(-100, "Unknown error %s" % err)
    else:
        response.write(encoded)
    finally:
        response.close()