test(02-02): add failing tests for PlatformAdapter base class
- Add test for abstract class instantiation prevention - Add test for incomplete implementation detection - Add test for complete implementation instantiation - Add test for async method signatures - Add shared fixtures for platform tests Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,134 @@
|
||||
"""Shared fixtures for platform adapter tests"""
|
||||
|
||||
import pytest
|
||||
from pathlib import Path
|
||||
import tempfile
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from kb_pipeline.state import WorkflowStateManager
|
||||
from kb_pipeline.schemas import WorkflowState
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def tmp_content_dir():
|
||||
"""Create a temporary directory for content files"""
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
yield Path(tmpdir)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def state_manager(tmp_content_dir):
|
||||
"""Create a WorkflowStateManager with a temporary directory"""
|
||||
return WorkflowStateManager(tmp_content_dir)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_state_manager():
|
||||
"""Create a mock WorkflowStateManager for testing"""
|
||||
return MagicMock(spec=WorkflowStateManager)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_video_metadata():
|
||||
"""Mock video metadata response from BilibiliExtractor"""
|
||||
return {
|
||||
'metadata': {
|
||||
'title': 'Test Video Title',
|
||||
'author': 'Test Author',
|
||||
'bvid': 'BV1test12345',
|
||||
'aid': 12345678,
|
||||
'mid': 9876543,
|
||||
'pubtime': '2024-01-15 10:30:00',
|
||||
'duration': '10:25',
|
||||
'url': 'https://www.bilibili.com/video/BV1test12345',
|
||||
'tags': 'test, video, bilibili',
|
||||
},
|
||||
'stats': {
|
||||
'view': 100000,
|
||||
'danmaku': 500,
|
||||
'reply': 200,
|
||||
'favorite': 1000,
|
||||
'coin': 800,
|
||||
'share': 300,
|
||||
'like': 5000,
|
||||
},
|
||||
'subtitle': '',
|
||||
'description': 'This is a test video description.'
|
||||
}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_article_metadata():
|
||||
"""Mock article metadata response from BilibiliExtractor"""
|
||||
return {
|
||||
'cvid': 'cv12345678',
|
||||
'title': 'Test Article Title',
|
||||
'author': 'Test Author',
|
||||
'mid': '9876543',
|
||||
'publish_time': '2024-01-15 10:30:00',
|
||||
'view_count': 50000,
|
||||
'like_count': 2000,
|
||||
'coin_count': 500,
|
||||
'share_count': 100,
|
||||
'reply_count': 150,
|
||||
'url': 'https://www.bilibili.com/read/cv12345678',
|
||||
'summary': 'This is a test article summary.',
|
||||
'word_count': 3000,
|
||||
}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_article_content():
|
||||
"""Mock article content HTML/Markdown"""
|
||||
return """# Test Article Title
|
||||
|
||||
This is the first paragraph of the test article.
|
||||
|
||||
## Section 1
|
||||
|
||||
Content for section 1.
|
||||
|
||||
## Section 2
|
||||
|
||||
Content for section 2.
|
||||
"""
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_zhihu_extractor():
|
||||
"""Mock ZhihuPlaywrightExtractor for testing."""
|
||||
from unittest.mock import MagicMock
|
||||
extractor = MagicMock()
|
||||
extractor.extract = MagicMock()
|
||||
return extractor
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_zhihu_answer_result():
|
||||
"""Sample Zhihu answer extraction result."""
|
||||
return {
|
||||
"type": "answer",
|
||||
"title": "Test Question Title",
|
||||
"author": "Test Author",
|
||||
"content": "This is the answer content.",
|
||||
"content_markdown": "# Answer\n\nThis is the answer content.",
|
||||
"publish_time": "2024-01-15T10:30:00",
|
||||
"url": "https://www.zhihu.com/question/123456/answer/789012",
|
||||
"question_id": "123456",
|
||||
"answer_id": "789012",
|
||||
}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_zhihu_zhuanlan_result():
|
||||
"""Sample Zhihu zhuanlan extraction result."""
|
||||
return {
|
||||
"type": "zhuanlan",
|
||||
"title": "Test Article Title",
|
||||
"author": "Test Author",
|
||||
"content": "This is the article content.",
|
||||
"content_markdown": "# Article\n\nThis is the article content.",
|
||||
"publish_time": "2024-01-15T10:30:00",
|
||||
"url": "https://zhuanlan.zhihu.com/p/123456",
|
||||
"article_id": "123456",
|
||||
}
|
||||
Reference in New Issue
Block a user