Remove redis

This commit is contained in:
2026-06-20 04:09:38 -04:00
parent fc394b8555
commit 044ce40e69
9 changed files with 56 additions and 125 deletions
+3 -3
View File
@@ -1,6 +1,6 @@
# Backend API Test Guide
This directory contains the backend API test suite. The tests use pytest, FastAPI's `TestClient`, and an isolated in-memory SQLite database. The goal is to cover the business-critical API behaviour without relying on MySQL, Redis, SMTP, or a running browser.
This directory contains the backend API test suite. The tests use pytest, FastAPI's `TestClient`, and an isolated in-memory SQLite database. The goal is to cover the business-critical API behaviour without relying on MySQL, SMTP, or a running browser.
## How To Run
@@ -190,8 +190,8 @@ Why it matters:
## Current Scope
The suite intentionally focuses on API behaviour and database side effects. It does not deeply test:
- WebSocket connection lifecycle and Redis pub/sub behaviour.
The suite intentionally focuses on API behaviour, local WebSocket broadcast behaviour, and database side effects. It does not deeply test:
- Full browser WebSocket lifecycle.
- Real SMTP delivery.
- Browser UI behaviour.
- Every branch of low-level validators or helper functions.
+38
View File
@@ -1,3 +1,10 @@
import json
import pytest
from app.main import ConnectionManager
def test_root_returns_api_metadata(client):
response = client.get("/")
@@ -12,3 +19,34 @@ def test_health_check_reports_database_connection(client):
assert response.status_code == 200
assert response.json()["status"] == "healthy"
assert response.json()["database"] == "connected"
class FakeWebSocket:
def __init__(self, fail_send=False):
self.accepted = False
self.fail_send = fail_send
self.messages = []
async def accept(self):
self.accepted = True
async def send_text(self, message):
if self.fail_send:
raise RuntimeError("socket closed")
self.messages.append(message)
@pytest.mark.asyncio
async def test_connection_manager_broadcasts_to_active_connections_and_removes_dead_ones():
manager = ConnectionManager()
active_socket = FakeWebSocket()
dead_socket = FakeWebSocket(fail_send=True)
await manager.connect(active_socket)
await manager.connect(dead_socket)
await manager.broadcast({"type": "ppr_updated", "id": 123})
assert active_socket.accepted is True
assert dead_socket.accepted is True
assert json.loads(active_socket.messages[0]) == {"type": "ppr_updated", "id": 123}
assert manager.active_connections == [active_socket]