test(microformats): Add v1.3.0 validation tests for tags and h-feed

Phase 4: Validation per microformats-tags-design.md

Added test fixtures:
- published_note_with_tags: Creates note with test tags for p-category validation
- published_note_with_media: Creates note with media for u-photo placement testing

Added v1.3.0 microformats2 validation tests:
- test_hfeed_has_required_properties: Validates name, author, url per spec
- test_hfeed_author_is_valid_hcard: Validates h-card structure
- test_hentry_has_pcategory_for_tags: Validates p-category markup
- test_uphoto_outside_econtent: Validates u-photo placement per draft spec

Test results:
- All 18 microformats tests pass
- All 116 related tests pass (microformats, notes, micropub)
- Confirms Phases 1-3 implementation correctness

Updated BACKLOG.md with tag-filtered feeds feature (medium priority)

Implementation report: docs/design/v1.3.0/2025-12-10-phase4-implementation.md

Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-12-10 11:51:39 -07:00
parent 372064b116
commit 3d80e1af51
4 changed files with 327 additions and 0 deletions

View File

@@ -64,3 +64,41 @@ def sample_note(app):
published=True,
)
return note
@pytest.fixture
def published_note_with_tags(app):
"""Create a published note with tags for microformats testing (v1.3.0)"""
from starpunk.notes import create_note
with app.app_context():
note = create_note(
content="Test note with tags for microformats validation",
published=True,
tags=["Python", "IndieWeb", "Testing"]
)
return note
@pytest.fixture
def published_note_with_media(app):
"""Create a published note with media for u-photo testing (v1.3.0)"""
from starpunk.notes import create_note
from starpunk.media import save_media, attach_media_to_note
from PIL import Image
import io
with app.app_context():
note = create_note(content="Test note with media", published=True)
# Create minimal valid JPEG for testing
img = Image.new('RGB', (100, 100), color='red')
img_bytes = io.BytesIO()
img.save(img_bytes, format='JPEG')
img_bytes.seek(0)
# Save media and attach to note
media_info = save_media(img_bytes.getvalue(), 'test.jpg')
attach_media_to_note(note.id, [media_info['id']], ['Test image'])
return note