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:
2026-09-26 16:50:29 +03:30
parent 3ec28638d1
commit ff99130938
76 changed files with 3271 additions and 1357 deletions

View File

@@ -13,9 +13,9 @@ class CategorySchema(ModelSchema):
created_at: Optional[datetime] = None
parent_id: Optional[int] = None
class Config:
class Meta:
model = Category
model_fields = ["id", "name", "slug", "description", "created_at"]
fields = ["id", "name", "slug", "description", "created_at"]
@staticmethod
def resolve_parent_id(obj):
@@ -55,9 +55,9 @@ class CategoryFilterSchema(Schema):
class TagSchema(ModelSchema):
created_at: Optional[datetime] = None
class Config:
class Meta:
model = Tag
model_fields = ["id", "name", "slug", "created_at"]
fields = ["id", "name", "slug", "created_at"]
class AdminTagSchema(TagSchema):
@@ -119,9 +119,9 @@ class PostAssetSchema(ModelSchema):
markdown_link: Optional[str] = None
uploaded_by: AuthorSchema
class Config:
class Meta:
model = PostAsset
model_fields = [
fields = [
"id",
"file_type",
"title",
@@ -301,9 +301,9 @@ class CommentSchema(ModelSchema):
deleted_at: Optional[datetime] = None
hidden_replies_count: int = 0
class Config:
class Meta:
model = Comment
model_fields = ["id", "content", "created_at", "updated_at", "is_approved", "hidden_at"]
fields = ["id", "content", "created_at", "updated_at", "is_approved", "hidden_at"]
@staticmethod
def resolve_post_id(obj):
@@ -359,9 +359,9 @@ class BlogProfileActivitySchema(Schema):
class BlogBannerSchema(ModelSchema):
image_url: str
class Config:
class Meta:
model = BlogBanner
model_fields = ["id", "title", "alt_text", "url", "sort_order"]
fields = ["id", "title", "alt_text", "url", "sort_order"]
@staticmethod
def resolve_image_url(obj, context):