From ccfa201250ce9eaada1e5c1d694a39ad890940e5 Mon Sep 17 00:00:00 2001 From: starmen1265 Date: Mon, 16 Mar 2026 23:28:27 +0800 Subject: [PATCH] fix(05-03): fix pre-existing test issues blocking verification - Fix test_workflow_skips_completed_steps to mock _ask_rerun_step - Fix test_fetch_video_metadata_success to use AsyncMock - Document other pre-existing test issues in deferred-items.md Co-Authored-By: Claude Opus 4.6 --- .../05-archive-directory/deferred-items.md | 33 +++++++++++++++++++ tests/test_integration/test_e2e_workflow.py | 8 +++-- tests/test_platforms/test_bilibili.py | 4 +-- 3 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 .planning/phases/05-archive-directory/deferred-items.md diff --git a/.planning/phases/05-archive-directory/deferred-items.md b/.planning/phases/05-archive-directory/deferred-items.md new file mode 100644 index 0000000..8a3cf6b --- /dev/null +++ b/.planning/phases/05-archive-directory/deferred-items.md @@ -0,0 +1,33 @@ +# Deferred Items - 05-03 + +This file tracks issues discovered during 05-03 plan execution that are out of scope. + +## Pre-existing Test Issues (Not Fixed) + +### 1. test_platforms/test_bilibili.py - AsyncMock Issues + +Multiple tests in `tests/test_platforms/test_bilibili.py` fail due to incorrect mock setup: +- `test_fetch_metadata_marks_step_failed_on_error` - needs AsyncMock for `_extract_video_async` +- `test_network_error_retries_3_times` - needs AsyncMock for `_extract_video_async` +- `test_403_error_triggers_fallback_note` - needs AsyncMock for `_extract_video_async` +- `test_fetch_article_metadata_success` - needs AsyncMock for `_extract_article_async` +- `test_fetch_article_content_returns_markdown` - needs AsyncMock for `_extract_article_async` +- `test_fetch_article_content_has_yaml_frontmatter` - needs AsyncMock for `_extract_article_async` + +**Root Cause:** Tests use `MagicMock` for async methods that should use `AsyncMock`. + +**Impact:** These tests fail when running full test suite. + +**Recommended Fix:** Update all `_extract_video_async` and `_extract_article_async` mocks to use `AsyncMock`. + +**Scope:** Out of scope for 05-03 (archive tests). Related to bilibili adapter tests, not archive functionality. + +--- + +## Notes + +The following tests were fixed during 05-03 execution as they blocked test verification: +1. `tests/test_integration/test_e2e_workflow.py::test_workflow_skips_completed_steps` - Added mock for `_ask_rerun_step` +2. `tests/test_platforms/test_bilibili.py::test_fetch_video_metadata_success` - Changed to AsyncMock + +These were minimal fixes needed to verify archive functionality works. diff --git a/tests/test_integration/test_e2e_workflow.py b/tests/test_integration/test_e2e_workflow.py index c7100d7..a4250a5 100644 --- a/tests/test_integration/test_e2e_workflow.py +++ b/tests/test_integration/test_e2e_workflow.py @@ -304,7 +304,7 @@ class TestWorkflowResumability: ) with patch("kb_pipeline.pipeline.get_settings") as mock_settings: - mock_settings.return_value = MagicMock() + mock_settings.return_value = MagicMock(intermediate_path=str(temp_content_dir)) pipeline = Pipeline( processors=[parse_processor, download_processor], @@ -312,8 +312,10 @@ class TestWorkflowResumability: output_dir=temp_content_dir, ) - # Run pipeline - parse should be skipped - result = await pipeline.run("https://www.bilibili.com/video/BV1test123") + # Mock _ask_rerun_step to return False (don't re-run) + with patch.object(pipeline, '_ask_rerun_step', return_value=False): + # Run pipeline - parse should be skipped + result = await pipeline.run("https://www.bilibili.com/video/BV1test123") # This test depends on pipeline implementation for skip logic # The important thing is that the pipeline runs without error diff --git a/tests/test_platforms/test_bilibili.py b/tests/test_platforms/test_bilibili.py index 0614fd8..fd282f6 100644 --- a/tests/test_platforms/test_bilibili.py +++ b/tests/test_platforms/test_bilibili.py @@ -46,9 +46,9 @@ class TestBilibiliAdapterVideoMetadata: """Test 1: fetch_metadata("BVxxx", "video") returns correct video metadata""" adapter = BilibiliAdapter(state_manager=mock_state_manager) - # Mock the extractor + # Mock the extractor - use AsyncMock for async method with patch.object(adapter, '_extractor') as mock_extractor: - mock_extractor.extract_video_metadata.return_value = mock_video_metadata + mock_extractor._extract_video_async = AsyncMock(return_value=mock_video_metadata) result = await adapter.fetch_metadata("BV1test12345", "video")