From 8c52ea27ad350e2b15435bf7e302c356db63c7ff Mon Sep 17 00:00:00 2001 From: QiuSW <105186638@qq.com> Date: Fri, 7 Aug 2026 23:58:34 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E8=A6=86=E7=9B=96=20Wiki=20=E9=95=9C?= =?UTF-8?q?=E5=83=8F=E8=84=8F=E6=96=87=E4=BB=B6=E4=BF=9D=E6=8A=A4=20(#1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_wiki_docs.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tests/test_wiki_docs.py b/tests/test_wiki_docs.py index 5fca242..e4685cf 100644 --- a/tests/test_wiki_docs.py +++ b/tests/test_wiki_docs.py @@ -6,7 +6,7 @@ import sys import tempfile import unittest from pathlib import Path -from unittest.mock import patch +from unittest.mock import Mock, patch ROOT = Path(__file__).resolve().parents[1] @@ -22,6 +22,7 @@ from wiki_docs import ( # noqa: E402 load_config, parse_mirror, render_mirror, + sync_all, validate_mappings, ) @@ -99,6 +100,20 @@ class MirrorTests(unittest.TestCase): ) self.assertEqual(dirty_mirror_paths(config), [" M docs/README.md"]) + @patch("wiki_docs.dirty_mirror_paths", return_value=[" M docs/README.md"]) + def test_sync_stops_before_reading_wiki_when_mirror_is_dirty(self, _dirty) -> None: + config = Config( + path=Path("wiki-docs.json"), + gitea_url="http://gitea.example", + owner="o", + repository="r", + mappings=(Mapping("Home", "docs/README.md"),), + ) + client = Mock() + with self.assertRaisesRegex(WikiDocsError, "未提交改动"): + sync_all(config, client) + client.get_page.assert_not_called() + class ArchiveTests(unittest.TestCase): def test_safe_title_handles_windows_characters(self) -> None: