Files
vault-para/tests/conftest.py
windyboy f99056a099 feat(tagging-system): Add comprehensive tagging system implementation
- Add tagging system Python package with modular architecture (config, core, impl)
- Create core interfaces for file discovery, content analysis, and tag generation
- Implement content analyzer with language detection and topic extraction
- Implement file discovery engine with directory scanning and filtering
- Implement tag generator with hierarchical tag creation and consolidation
- Add configuration management with example config and validation
- Create comprehensive design and requirements documentation in .kiro/specs
- Add pytest test suite with unit tests for models, interfaces, and config
- Add setup.py, requirements.txt, and pytest.ini for package management
- Add README.md with project overview and usage instructions
- Update workspace.json with new project structure
- Add Excalidraw diagram for system architecture visualization
- Establish foundation for automated vault tagging and metadata management
2025-12-31 08:37:16 +08:00

124 lines
3.6 KiB
Python

"""Pytest configuration and fixtures."""
import pytest
from pathlib import Path
from datetime import datetime
from typing import List
from hypothesis import settings, Verbosity
from tagging_system.core.models import (
FileInfo,
ContentAnalysis,
TagStructure,
FrontmatterData,
ContentType,
LanguageInfo
)
from tagging_system.config import TaggingConfig
# Configure hypothesis for property-based testing
settings.register_profile("default", max_examples=100, verbosity=Verbosity.normal)
settings.register_profile("ci", max_examples=1000, verbosity=Verbosity.verbose)
settings.load_profile("default")
@pytest.fixture
def sample_file_info() -> FileInfo:
"""Create a sample FileInfo for testing."""
return FileInfo(
path="100-project/AI/test.md",
name="test.md",
directory="100-project/AI",
extension=".md",
size=1024,
created=datetime(2024, 1, 1, 12, 0, 0),
modified=datetime(2024, 1, 2, 12, 0, 0),
content="# Test File\n\nThis is a test file about AI and machine learning."
)
@pytest.fixture
def sample_content_analysis() -> ContentAnalysis:
"""Create a sample ContentAnalysis for testing."""
return ContentAnalysis(
language=LanguageInfo.ENGLISH,
content_type=ContentType.NOTE,
topics=["ai", "machine-learning", "technology"],
mentions={
'tools': ['python', 'tensorflow'],
'technologies': ['ai', 'ml'],
'people': [],
'organizations': ['openai']
},
sentiment="neutral",
complexity="intermediate"
)
@pytest.fixture
def sample_tag_structure() -> TagStructure:
"""Create a sample TagStructure for testing."""
return TagStructure(
primary=["project"],
hierarchical=["tech/ai", "tech/ml"],
content=["python", "tensorflow"],
meta=["lang/en", "type/note"],
custom=["custom-tag"]
)
@pytest.fixture
def sample_frontmatter_data() -> FrontmatterData:
"""Create a sample FrontmatterData for testing."""
return FrontmatterData(
title="Test File",
tags=["project", "tech/ai", "python"],
created="2024-01-01",
updated="2024-01-02",
type="note",
lang="en",
aliases=["test"],
description="A test file for AI projects"
)
@pytest.fixture
def default_config() -> TaggingConfig:
"""Create a default TaggingConfig for testing."""
return TaggingConfig()
@pytest.fixture
def temp_vault_structure(tmp_path: Path) -> Path:
"""Create a temporary vault structure for testing."""
vault_root = tmp_path / "test_vault"
# Create directory structure
directories = [
"100-project/AI",
"100-project/Infrastructure",
"200-area/Productivity",
"200-area/Health",
"300-resources/Development",
"400-archive",
"Clippings",
"ReadItLater Inbox"
]
for directory in directories:
(vault_root / directory).mkdir(parents=True, exist_ok=True)
# Create sample files
sample_files = [
("100-project/AI/llm-notes.md", "# LLM Notes\n\nNotes about large language models."),
("200-area/Productivity/gtd.md", "# Getting Things Done\n\nProductivity methodology."),
("300-resources/Development/python.md", "# Python Resources\n\nPython development resources."),
("Clippings/article.md", "# Interesting Article\n\nClipped from web.")
]
for file_path, content in sample_files:
file_full_path = vault_root / file_path
file_full_path.write_text(content, encoding='utf-8')
return vault_root