import pytest from favro_sync.favro_markdown import CardFileFormatter EXAMPLE_TEXT_1 = """ --- aliases: - Hello World archived: false todo-list-completed: false --- # Hello World Test description ## Other header 1. Derp 2. Derp 3. Derp - [ ] Task 1 - [ ] Task 2 """.strip() EXAMPLE_TEXT_2 = """ --- aliases: - Name of Card archived: true 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() EXAMPLES = [EXAMPLE_TEXT_1, EXAMPLE_TEXT_2, EXAMPLE_TEXT_3] FORMATTER = CardFileFormatter() @pytest.mark.parametrize('example_text', EXAMPLES) def test_parse_and_render(example_text: str): card_contents = FORMATTER.parse_card_contents(example_text) 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 def test_parse_and_render_1(): card_contents = FORMATTER.parse_card_contents(EXAMPLE_TEXT_1) assert card_contents.name == 'Hello World' def test_parse_and_render_2(): card_contents = FORMATTER.parse_card_contents(EXAMPLE_TEXT_2) assert card_contents.name == 'Name of Card' def test_parse_and_render_3(): card_contents = FORMATTER.parse_card_contents(EXAMPLE_TEXT_3) assert card_contents.name == 'Card: The Adventure of Card'