Performance: Testing authentication flows
MEDIUM IMPACT
This affects the speed and responsiveness of user login and session management, impacting user experience during authentication.
from unittest.mock import patch def test_login(client): with patch('app.auth.verify_user') as mock_verify: mock_verify.return_value = True response = client.post('/login', data={'username': 'user', 'password': 'pass'}) assert response.status_code == 200
def test_login(client): response = client.post('/login', data={'username': 'user', 'password': 'pass'}) assert response.status_code == 200 # Real DB call happens here
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Real DB calls in tests | N/A (server-side) | N/A | N/A | [X] Bad |
| Mocked DB calls in tests | N/A (server-side) | N/A | N/A | [OK] Good |
| Recreate app/client per test | N/A | N/A | N/A | [X] Bad |
| Reuse app/client fixtures | N/A | N/A | N/A | [OK] Good |
| Blocking calls in auth flow | N/A | N/A | N/A | [X] Bad |
| Stub blocking calls in auth | N/A | N/A | N/A | [OK] Good |