From 17a246490d69015d110109c3c0b73914c6e45b32 Mon Sep 17 00:00:00 2001 From: arsam Date: Fri, 18 Sep 2026 23:06:49 +0330 Subject: [PATCH] Import tests: tests/test_rate_limit Import the existing local project snapshot. This commit organizes existing files; it does not represent newly developed functionality. --- tests/test_rate_limit.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 tests/test_rate_limit.py diff --git a/tests/test_rate_limit.py b/tests/test_rate_limit.py new file mode 100644 index 0000000..21e1352 --- /dev/null +++ b/tests/test_rate_limit.py @@ -0,0 +1,34 @@ +from fastapi import FastAPI +from fastapi.testclient import TestClient + + +def test_rate_limit_rejects_after_limit(): + from axon.middleware.rate_limit import RateLimitMiddleware + + app = FastAPI() + + @app.get("/data") + async def data(): + return {"ok": True} + + app.add_middleware(RateLimitMiddleware, limit_per_minute=1) + client = TestClient(app) + + assert client.get("/data").status_code == 200 + assert client.get("/data").status_code == 429 + + +def test_rate_limit_exempts_health(): + from axon.middleware.rate_limit import RateLimitMiddleware + + app = FastAPI() + + @app.get("/health") + async def health(): + return {"ok": True} + + app.add_middleware(RateLimitMiddleware, limit_per_minute=1) + client = TestClient(app) + + assert client.get("/health").status_code == 200 + assert client.get("/health").status_code == 200