def test_complex_limits_without_data_category(httpserver, capsys, caplog, response_code): client = Client( dict(dsn="http://foobar@{}/123".format( httpserver.url[len("http://"):]))) httpserver.serve_content( "hm", response_code, headers={"X-Sentry-Rate-Limit": "4711::organization"}, ) client.capture_event({"type": "transaction"}) client.flush() assert len(httpserver.requests) == 1 del httpserver.requests[:] assert set(client.transport._disabled_until) == set([None]) client.transport.capture_event({"type": "transaction"}) client.transport.capture_event({"type": "transaction"}) client.capture_event({"type": "event"}) client.flush() assert len(httpserver.requests) == 0
def test_transport_infinite_loop(httpserver, request): httpserver.serve_content("ok", 200) client = Client( "http://foobar@{}/123".format(httpserver.url[len("http://") :]), debug=True, # Make sure we cannot create events from our own logging integrations=[LoggingIntegration(event_level=logging.DEBUG)], ) with Hub(client): capture_message("hi") client.flush() assert len(httpserver.requests) == 1
def test_simple_rate_limits(httpserver, capsys, caplog): client = Client(dsn="http://foobar@{}/123".format(httpserver.url[len("http://") :])) httpserver.serve_content("no", 429, headers={"Retry-After": "4"}) client.capture_event({"type": "transaction"}) client.flush() assert len(httpserver.requests) == 1 del httpserver.requests[:] assert set(client.transport._disabled_until) == set([None]) client.capture_event({"type": "transaction"}) client.capture_event({"type": "event"}) client.flush() assert not httpserver.requests