1
0
favro-sync/test/test_markdown_parsing.py

88 lines
1.6 KiB
Python
Raw Normal View History

2024-10-02 08:18:12 +00:00
import pytest
2024-10-02 08:32:14 +00:00
from favro_sync.favro_markdown import CardFileFormatter
2024-09-27 14:13:03 +00:00
EXAMPLE_TEXT_1 = """
---
aliases:
2024-09-28 12:27:59 +00:00
- Hello World
2024-10-02 08:18:12 +00:00
archived: false
todo-list-completed: false
---
2024-09-27 14:13:03 +00:00
# Hello World
2024-09-27 14:13:03 +00:00
Test description
## Other header
1. Derp
2. Derp
3. Derp
- [ ] Task 1
- [ ] Task 2
""".strip()
2024-09-27 14:13:03 +00:00
2024-09-28 11:21:11 +00:00
EXAMPLE_TEXT_2 = """
---
aliases:
2024-09-28 12:27:59 +00:00
- Name of Card
2024-10-02 08:18:12 +00:00
archived: true
2024-09-28 11:21:11 +00:00
assignments:
2024-09-28 12:27:59 +00:00
- '[[Gunnar Gunnarson]]'
- '[[Alice Alicedottor]]'
2024-09-28 12:10:13 +00:00
dependencies:
2024-09-28 12:27:59 +00:00
- '[[PAR-9999]]'
tags:
- tag1
- tag2
todo-list-completed: true
2024-09-28 11:21:11 +00:00
---
# Name of Card
2024-09-28 11:21:11 +00:00
Great news everyone! My weird program actually works!
""".strip()
2024-09-28 12:27:59 +00:00
EXAMPLE_TEXT_3 = """
---
aliases:
- 'Card: The Adventure of Card'
2024-09-30 11:57:34 +00:00
url: https://example.org
2024-09-28 12:27:59 +00:00
---
# Card: The Adventure of Card
Description of Card.
""".strip()
2024-10-02 08:18:12 +00:00
EXAMPLES = [EXAMPLE_TEXT_1, EXAMPLE_TEXT_2, EXAMPLE_TEXT_3]
2024-09-28 11:21:11 +00:00
FORMATTER = CardFileFormatter()
2024-10-02 08:32:14 +00:00
2024-10-02 08:18:12 +00:00
@pytest.mark.parametrize('example_text', EXAMPLES)
def test_parse_and_render(example_text: str):
card_contents = FORMATTER.parse_card_contents(example_text)
2024-09-28 12:13:51 +00:00
2024-10-02 08:18:12 +00:00
assert card_contents.name is not None
assert '#' not in card_contents.name
assert '---' not in card_contents.description
assert FORMATTER.format_card_contents(card_contents) == example_text
2024-10-02 08:18:12 +00:00
def test_parse_and_render_1():
card_contents = FORMATTER.parse_card_contents(EXAMPLE_TEXT_1)
assert card_contents.name == 'Hello World'
2024-09-28 11:21:11 +00:00
2024-09-28 12:13:51 +00:00
2024-09-28 11:21:11 +00:00
def test_parse_and_render_2():
card_contents = FORMATTER.parse_card_contents(EXAMPLE_TEXT_2)
2024-09-28 12:10:13 +00:00
assert card_contents.name == 'Name of Card'
2024-09-28 12:27:59 +00:00
2024-10-01 08:29:12 +00:00
2024-09-28 12:27:59 +00:00
def test_parse_and_render_3():
card_contents = FORMATTER.parse_card_contents(EXAMPLE_TEXT_3)
assert card_contents.name == 'Card: The Adventure of Card'