2024-09-28 10:37:19 +00:00
|
|
|
from favro_sync.favro_markdown import CardFileFormatter
|
2024-09-27 14:13:03 +00:00
|
|
|
|
2024-09-28 10:54:34 +00:00
|
|
|
EXAMPLE_TEXT_1 = """
|
2024-09-27 14:41:26 +00:00
|
|
|
---
|
|
|
|
aliases:
|
|
|
|
- Hello World
|
|
|
|
---
|
2024-09-27 14:13:03 +00:00
|
|
|
|
2024-09-27 14:41:26 +00:00
|
|
|
# Hello World
|
2024-09-27 14:13:03 +00:00
|
|
|
|
|
|
|
Test description
|
|
|
|
|
|
|
|
## Other header
|
|
|
|
|
|
|
|
1. Derp
|
|
|
|
2. Derp
|
|
|
|
3. Derp
|
2024-09-28 10:54:34 +00:00
|
|
|
""".strip()
|
2024-09-27 14:13:03 +00:00
|
|
|
|
2024-09-28 11:21:11 +00:00
|
|
|
EXAMPLE_TEXT_2 = """
|
|
|
|
---
|
|
|
|
aliases:
|
|
|
|
- Name of Card
|
|
|
|
tags:
|
|
|
|
- tag1
|
|
|
|
- tag2
|
|
|
|
assignments:
|
|
|
|
- "[[Gunnar Gunnarson]]"
|
|
|
|
- "[[Alice Alicedottor]]"
|
2024-09-28 12:10:13 +00:00
|
|
|
dependencies:
|
|
|
|
- "[[PAR-9999]]"
|
2024-09-28 11:21:11 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
# Name of Card
|
2024-09-28 10:37:19 +00:00
|
|
|
|
2024-09-28 11:21:11 +00:00
|
|
|
Great news everyone! My weird program actually works!
|
|
|
|
""".strip()
|
|
|
|
|
|
|
|
FORMATTER = CardFileFormatter()
|
2024-09-28 10:54:34 +00:00
|
|
|
|
2024-09-28 12:13:51 +00:00
|
|
|
|
2024-09-27 14:13:03 +00:00
|
|
|
def test_parse_and_render():
|
2024-09-28 10:37:19 +00:00
|
|
|
card_contents = FORMATTER.parse_card_contents(EXAMPLE_TEXT_1)
|
2024-09-27 14:41:26 +00:00
|
|
|
|
|
|
|
assert card_contents.name == 'Hello World'
|
|
|
|
assert '---' not in card_contents.description
|
2024-09-28 10:37:19 +00:00
|
|
|
assert FORMATTER.format_card_contents(card_contents) == EXAMPLE_TEXT_1
|
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)
|
|
|
|
print(card_contents)
|
|
|
|
|
2024-09-28 12:10:13 +00:00
|
|
|
assert card_contents.name == 'Name of Card'
|
2024-09-28 11:21:11 +00:00
|
|
|
assert '---' not in card_contents.description
|
|
|
|
assert FORMATTER.format_card_contents(card_contents) == EXAMPLE_TEXT_2
|