Example #1
0
def test_errors_exception_sentry(client_sentry: Client, caplog, mocker):
    m = mocker.patch('foxglove.middleware.capture_event')
    r = client_sentry.get('/error/', params={'error': 'RuntimeError'})
    assert r.status_code == 500, r.text
    assert len(caplog.records) == 1, caplog.text
    msg = '"GET /error/?error=RuntimeError", RuntimeError(\'raised RuntimeError\')'
    assert msg in caplog.text

    m.assert_called_once()
    assert m.call_args.args[0]['message'] == msg
    assert m.call_args.args[0]['fingerprint'] == ('/error/', 'GET', "RuntimeError('raised RuntimeError')")
    assert m.call_args.args[1] is not None
Example #2
0
def test_errors_exception(client: Client, caplog):
    r = client.get('/error/', params={'error': 'RuntimeError'})
    assert r.status_code == 500, r.text
    assert len(caplog.records) == 1, caplog.text
    assert '"GET /error/?error=RuntimeError", RuntimeError(' in caplog.text
    assert caplog.records[0].request['url'] == 'http://testserver/error/?error=RuntimeError'