added metadata parsing
This commit is contained in:
parent
8f0e420a8f
commit
729bde2f55
6 changed files with 43 additions and 28 deletions
24
tests/test_metadata.py
Normal file
24
tests/test_metadata.py
Normal file
|
@ -0,0 +1,24 @@
|
|||
from datetime import date
|
||||
from zona.models import Metadata
|
||||
from zona.builder import split_metadata
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def test_split_metadata(tmp_path: Path):
|
||||
content = """---
|
||||
title: Test Post
|
||||
date: 2025-06-03
|
||||
description: This is a test.
|
||||
---
|
||||
|
||||
# Hello World
|
||||
"""
|
||||
test_file = tmp_path / "test.md"
|
||||
test_file.write_text(content)
|
||||
meta, content = split_metadata(test_file)
|
||||
|
||||
assert isinstance(meta, Metadata)
|
||||
assert meta.title == "Test Post"
|
||||
assert meta.description == "This is a test."
|
||||
assert meta.date == date(2025, 6, 3)
|
||||
assert content == "# Hello World"
|
Loading…
Add table
Add a link
Reference in a new issue