test: migrate backend suites to pytest with module coverage gate
Split backend tests into unit and integration suites, add isolated fixtures and coverage enforcement, and update CI and test documentation. Cover current authentication, content, notification, payment, media, and admin flows; fix behaviors revealed by the new tests. Validate both suites and the per-module gate against local PostgreSQL.
This commit is contained in:
22
apps/notifications/tests/unit/test_stream_token.py
Normal file
22
apps/notifications/tests/unit/test_stream_token.py
Normal file
@@ -0,0 +1,22 @@
|
||||
import pytest
|
||||
from django.core import signing
|
||||
|
||||
from apps.notifications.api.views import _format_sse_event, _issue_stream_token_for_user, _safe_int, _validate_stream_token
|
||||
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
|
||||
def test_stream_token_round_trip_and_invalid_token():
|
||||
token = _issue_stream_token_for_user("42")
|
||||
assert _validate_stream_token(token) == "42"
|
||||
with pytest.raises(signing.BadSignature):
|
||||
_validate_stream_token("wrong")
|
||||
with pytest.raises(signing.BadSignature):
|
||||
_validate_stream_token(None)
|
||||
|
||||
|
||||
def test_sse_formatter_and_safe_integer_limits():
|
||||
assert _safe_int("-5", 10) == 0
|
||||
assert _safe_int("oops", 10) == 10
|
||||
assert 'event: connected\ndata: {"ready": true}\n\n' == _format_sse_event("connected", {"ready": True})
|
||||
Reference in New Issue
Block a user