1
0
favro-sync/test/test_markdown_parsing.py

82 lines
1.5 KiB
Python

from favro_sync.favro_markdown import CardFileFormatter
EXAMPLE_TEXT_1 = """
---
aliases:
- Hello World
---
# Hello World
Test description
## Other header
1. Derp
2. Derp
3. Derp
- [ ] Task 1
- [ ] Task 2
""".strip()
EXAMPLE_TEXT_2 = """
---
aliases:
- Name of Card
assignments:
- '[[Gunnar Gunnarson]]'
- '[[Alice Alicedottor]]'
dependencies:
- '[[PAR-9999]]'
tags:
- tag1
- tag2
todo-list-completed: true
---
# Name of Card
Great news everyone! My weird program actually works!
""".strip()
EXAMPLE_TEXT_3 = """
---
aliases:
- 'Card: The Adventure of Card'
url: https://example.org
---
# Card: The Adventure of Card
Description of Card.
""".strip()
FORMATTER = CardFileFormatter()
def test_parse_and_render():
card_contents = FORMATTER.parse_card_contents(EXAMPLE_TEXT_1)
assert card_contents.name == 'Hello World'
assert '---' not in card_contents.description
assert FORMATTER.format_card_contents(card_contents) == EXAMPLE_TEXT_1
def test_parse_and_render_2():
card_contents = FORMATTER.parse_card_contents(EXAMPLE_TEXT_2)
print(card_contents)
assert card_contents.name == 'Name of Card'
assert '---' not in card_contents.description
assert FORMATTER.format_card_contents(card_contents) == EXAMPLE_TEXT_2
def test_parse_and_render_3():
card_contents = FORMATTER.parse_card_contents(EXAMPLE_TEXT_3)
print(card_contents)
assert card_contents.name == 'Card: The Adventure of Card'
assert '---' not in card_contents.description
assert FORMATTER.format_card_contents(card_contents) == EXAMPLE_TEXT_3