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:
20
apps/certificates/tests/unit/test_certificates.py
Normal file
20
apps/certificates/tests/unit/test_certificates.py
Normal file
@@ -0,0 +1,20 @@
|
||||
import pytest
|
||||
from django.core.exceptions import ValidationError
|
||||
|
||||
from apps.certificates.models import CertificateTemplate, UserCertificate, _generate_certificate_code
|
||||
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
|
||||
@pytest.mark.parametrize("score", [None, "invalid", -1, 101])
|
||||
def test_invalid_certificate_scores_are_rejected(score):
|
||||
with pytest.raises(ValidationError):
|
||||
CertificateTemplate()._validate_score(score)
|
||||
|
||||
|
||||
def test_valid_scores_and_short_codes():
|
||||
assert CertificateTemplate()._validate_score("75") == 75
|
||||
assert len(_generate_certificate_code()) == 10
|
||||
assert UserCertificate(score=75).score_label == "Perfect"
|
||||
assert UserCertificate(score=200).score_label == "Unknown"
|
||||
Reference in New Issue
Block a user