chore/ 删除无用文件

This commit is contained in:
Kevin
2026-03-19 14:36:14 +08:00
parent 2f60858c9c
commit c6e07ce5ca
135 changed files with 2111 additions and 4510 deletions

View File

@@ -66,7 +66,9 @@ class ChaptersRouterImagesTest(unittest.TestCase):
)
def test_chapter_to_dict_returns_signed_image_urls_for_response(self, storage_cls):
storage = Mock()
storage.get_download_url.return_value = "https://signed.example.com/memoirs/u1/c1/0-demo.png?sig=123"
storage.get_download_url.return_value = (
"https://signed.example.com/memoirs/u1/c1/0-demo.png?sig=123"
)
storage_cls.from_settings.return_value = storage
img0 = _image_stub(
@@ -79,7 +81,11 @@ class ChaptersRouterImagesTest(unittest.TestCase):
section_id=None,
order_index=0,
)
sec = type("SectionStub", (), {"content": "", "order_index": 0, "image_record": img0, "image_id": None})()
sec = type(
"SectionStub",
(),
{"content": "", "order_index": 0, "image_record": img0, "image_id": None},
)()
chapter = _chapter_stub(images=[img0], sections=[sec])
payload = _chapter_to_dict(chapter)
@@ -101,7 +107,9 @@ class ChaptersRouterImagesTest(unittest.TestCase):
},
clear=False,
)
def test_chapter_to_dict_preserves_completed_asset_when_signing_fails(self, storage_cls):
def test_chapter_to_dict_preserves_completed_asset_when_signing_fails(
self, storage_cls
):
storage = Mock()
storage.get_download_url.side_effect = CosDownloadUrlError(
"cos unavailable", retryable=True, request_id="req-err"
@@ -118,7 +126,11 @@ class ChaptersRouterImagesTest(unittest.TestCase):
section_id=None,
order_index=0,
)
sec = type("SectionStub", (), {"content": "", "order_index": 0, "image_record": img0, "image_id": None})()
sec = type(
"SectionStub",
(),
{"content": "", "order_index": 0, "image_record": img0, "image_id": None},
)()
chapter = _chapter_stub(images=[img0], sections=[sec])
payload = _chapter_to_dict(chapter)
@@ -133,7 +145,9 @@ class ChaptersRouterImagesTest(unittest.TestCase):
def test_chapter_to_dict_drops_malformed_image_assets(self, storage_cls):
storage_cls.from_settings.return_value = Mock()
# 无 sections 时 content/images 来自 _sections_to_content_and_images 得到 []无有效封面images 的 section_id 非空)
img = _image_stub(status="completed", placeholder="", description="", section_id="sec1")
img = _image_stub(
status="completed", placeholder="", description="", section_id="sec1"
)
chapter = _chapter_stub(images=[img], sections=[])
payload = _chapter_to_dict(chapter)
@@ -142,9 +156,13 @@ class ChaptersRouterImagesTest(unittest.TestCase):
@patch("app.features.memoir.router.MemoirImageSettings")
@patch("app.features.memoir.router.TencentCosStorageService")
def test_chapter_to_dict_hides_non_completed_assets_when_feature_disabled(self, storage_cls, memoir_img_settings_cls):
def test_chapter_to_dict_hides_non_completed_assets_when_feature_disabled(
self, storage_cls, memoir_img_settings_cls
):
storage = Mock()
storage.get_download_url.return_value = "https://signed.example.com/0.png?sig=123"
storage.get_download_url.return_value = (
"https://signed.example.com/0.png?sig=123"
)
storage_cls.from_settings.return_value = storage
memoir_img_settings_cls.from_settings.return_value = Mock(enabled=False)
@@ -158,7 +176,16 @@ class ChaptersRouterImagesTest(unittest.TestCase):
order_index=0,
section_id="s1",
)
sec = type("SectionStub", (), {"content": "", "order_index": 0, "image_record": img_completed, "image_id": None})()
sec = type(
"SectionStub",
(),
{
"content": "",
"order_index": 0,
"image_record": img_completed,
"image_id": None,
},
)()
chapter = _chapter_stub(images=[img_completed], sections=[sec])
payload = _chapter_to_dict(chapter)
@@ -168,7 +195,9 @@ class ChaptersRouterImagesTest(unittest.TestCase):
@patch("app.features.memoir.router.TencentCosStorageService")
@patch.dict(os.environ, {"MEMOIR_IMAGE_ENABLED": "true"}, clear=False)
def test_chapter_to_dict_preserves_retryable_flag_for_failed_assets(self, storage_cls):
def test_chapter_to_dict_preserves_retryable_flag_for_failed_assets(
self, storage_cls
):
storage_cls.from_settings.return_value = Mock()
img = _image_stub(
@@ -180,7 +209,11 @@ class ChaptersRouterImagesTest(unittest.TestCase):
retryable=False,
order_index=0,
)
sec = type("SectionStub", (), {"content": "", "order_index": 0, "image_record": img, "image_id": None})()
sec = type(
"SectionStub",
(),
{"content": "", "order_index": 0, "image_record": img, "image_id": None},
)()
chapter = _chapter_stub(images=[img], sections=[sec])
payload = _chapter_to_dict(chapter)