fix: 完善个人中心卡片管理
This commit is contained in:
@@ -2,6 +2,8 @@ from __future__ import annotations
|
||||
|
||||
from datetime import UTC, datetime
|
||||
|
||||
import pytest
|
||||
from fastapi import HTTPException
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.orm import Session
|
||||
from sqlalchemy.pool import StaticPool
|
||||
@@ -63,3 +65,14 @@ def test_generate_help_card_from_topic_summary_and_mark_copied():
|
||||
|
||||
assert copied.copied == 1
|
||||
assert copied.copied_at is not None
|
||||
|
||||
other_user = User(id=2, phone="13800000002", name="其他学员", daily_chat_limit=100, daily_chat_used=0)
|
||||
db.add(other_user)
|
||||
db.commit()
|
||||
with pytest.raises(HTTPException) as error:
|
||||
HelpCardService.delete(db, user=other_user, card_id=card.id)
|
||||
assert error.value.status_code == 404
|
||||
assert db.get(TeacherHelpCard, card.id) is not None
|
||||
|
||||
HelpCardService.delete(db, user=user, card_id=card.id)
|
||||
assert db.get(TeacherHelpCard, card.id) is None
|
||||
|
||||
@@ -2,6 +2,8 @@ from __future__ import annotations
|
||||
|
||||
from datetime import UTC, datetime
|
||||
|
||||
import pytest
|
||||
from fastapi import HTTPException
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.orm import Session
|
||||
from sqlalchemy.pool import StaticPool
|
||||
@@ -65,3 +67,14 @@ def test_generate_share_draft_from_topic_summary_and_mark_copied():
|
||||
|
||||
assert copied.copied == 1
|
||||
assert copied.copied_at is not None
|
||||
|
||||
other_user = User(id=2, phone="13800000002", name="其他学员", daily_chat_limit=100, daily_chat_used=0)
|
||||
db.add(other_user)
|
||||
db.commit()
|
||||
with pytest.raises(HTTPException) as error:
|
||||
ShareDraftService.delete(db, user=other_user, draft_id=draft.id)
|
||||
assert error.value.status_code == 404
|
||||
assert db.get(ShareDraft, draft.id) is not None
|
||||
|
||||
ShareDraftService.delete(db, user=user, draft_id=draft.id)
|
||||
assert db.get(ShareDraft, draft.id) is None
|
||||
|
||||
Reference in New Issue
Block a user