From 81c1ceecbedea80ac2b9ef59d700f2fbeeadec25 Mon Sep 17 00:00:00 2001 From: phernandez Date: Thu, 9 Jan 2025 15:22:41 -0600 Subject: [PATCH] fix file_scanner tests --- src/basic_memory/markdown/note_writer.py | 44 ------------ tests/markdown/test_note_writer.py | 88 ------------------------ 2 files changed, 132 deletions(-) delete mode 100644 src/basic_memory/markdown/note_writer.py delete mode 100644 tests/markdown/test_note_writer.py diff --git a/src/basic_memory/markdown/note_writer.py b/src/basic_memory/markdown/note_writer.py deleted file mode 100644 index 47184bba..00000000 --- a/src/basic_memory/markdown/note_writer.py +++ /dev/null @@ -1,44 +0,0 @@ -"""Writer for note entity markdown files.""" - -from typing import Optional -from basic_memory.models import Entity as EntityModel - - -class NoteWriter: - """Formats notes into markdown files with frontmatter.""" - - async def format_frontmatter(self, entity: EntityModel) -> dict: - """Generate frontmatter for note. - - Args: - entity: The note entity to format frontmatter for - - Returns: - Dictionary of frontmatter fields - """ - frontmatter = { - "id": entity.path_id, - "type": entity.entity_type, - "created": entity.created_at.isoformat(), - "modified": entity.updated_at.isoformat() - } - # Add any entity_metadata that isn't None - if entity.entity_metadata: - frontmatter.update(entity.entity_metadata) - return frontmatter - - async def format_content( - self, - entity: EntityModel, - content: str, - ) -> str: - """Format note content as markdown. - - Args: - entity: The note entity - content: Raw content to format - - Returns: - Formatted markdown content - """ - return content.strip() # Just return the trimmed content \ No newline at end of file diff --git a/tests/markdown/test_note_writer.py b/tests/markdown/test_note_writer.py deleted file mode 100644 index 9e5b2c71..00000000 --- a/tests/markdown/test_note_writer.py +++ /dev/null @@ -1,88 +0,0 @@ -"""Tests for NoteWriter.""" - -from datetime import datetime, UTC - -import pytest - -from basic_memory.markdown.note_writer import NoteWriter -from basic_memory.models import Entity - - -@pytest.fixture -def note_writer() -> NoteWriter: - return NoteWriter() - - -@pytest.fixture -def sample_note() -> Entity: - """Create a sample note entity for testing.""" - return Entity( - id=1, - name="test_note", - entity_type="note", - path_id="notes/test_note", - file_path="notes/test_note.md", - created_at=datetime(2025, 1, 1, tzinfo=UTC), - updated_at=datetime(2025, 1, 2, tzinfo=UTC), - ) - - -@pytest.mark.asyncio -async def test_format_frontmatter_basic(note_writer: NoteWriter, sample_note: Entity): - """Test basic frontmatter formatting.""" - frontmatter = await note_writer.format_frontmatter(sample_note) - - assert frontmatter["id"] == "notes/test_note" - assert frontmatter["type"] == "note" - assert frontmatter["created"] == "2025-01-01T00:00:00+00:00" - assert frontmatter["modified"] == "2025-01-02T00:00:00+00:00" - - -@pytest.mark.asyncio -async def test_format_frontmatter_with_metadata(note_writer: NoteWriter, sample_note: Entity): - """Test frontmatter includes entity metadata.""" - sample_note.entity_metadata = {"category": "research", "tags": ["python", "testing"]} - - frontmatter = await note_writer.format_frontmatter(sample_note) - - assert frontmatter["category"] == "research" - assert frontmatter["tags"] == ["python", "testing"] - assert frontmatter["id"] == "notes/test_note" - - -@pytest.mark.asyncio -async def test_format_content_basic(note_writer: NoteWriter, sample_note: Entity): - """Test basic content formatting.""" - content = "# Test Note\n\nThis is a test note." - result = await note_writer.format_content(sample_note, content) - - assert result == content - - -@pytest.mark.asyncio -async def test_format_content_strips_whitespace(note_writer: NoteWriter, sample_note: Entity): - """Test content formatting strips extra whitespace.""" - content = "\n\n# Test Note\n\nThis is a test note.\n\n" - result = await note_writer.format_content(sample_note, content) - - assert result == "# Test Note\n\nThis is a test note." - - -@pytest.mark.asyncio -async def test_format_content_preserves_markdown(note_writer: NoteWriter, sample_note: Entity): - """Test content formatting preserves markdown formatting.""" - content = """# Test Note - -This note has: -- Bullet points -- *Italic text* -- **Bold text** -- `code blocks` - -```python -def test(): - pass -```""" - - result = await note_writer.format_content(sample_note, content) - assert result == content