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_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
def test_capture_event_works(): c = Client(transport=_TestTransport()) pytest.raises(EventCaptured, lambda: c.capture_event({})) pytest.raises(EventCaptured, lambda: c.capture_event({}))