1
0

[frontmatter]: Archived status

This commit is contained in:
Jon Michael Aanes 2024-10-02 10:18:12 +02:00
parent 2734e7ac7a
commit c7ccecf61d
2 changed files with 25 additions and 21 deletions

View File

@ -75,31 +75,31 @@ class CardFileFormatter:
if aliases:
frontmatter_data[FM_KEY_ALIASES] = aliases
del aliases
if card.tags:
if len(card.tags) > 0:
frontmatter_data[FM_KEY_TAGS] = card.tags
if card.url and self.obsidian_mode:
if card.url is not None and self.obsidian_mode:
frontmatter_data[FM_KEY_URL] = card.url
if card.assignments:
if len(card.assignments) > 0:
frontmatter_data[FM_KEY_ASSIGNMENTS] = card.assignments
if self.obsidian_mode:
frontmatter_data[FM_KEY_ASSIGNMENTS] = [
format_obsidian_link(name)
for name in frontmatter_data[FM_KEY_ASSIGNMENTS]
]
if card.card_dependencies:
if len(card.card_dependencies) > 0:
frontmatter_data[FM_KEY_DEPENDENCIES] = card.card_dependencies
if self.obsidian_mode:
frontmatter_data[FM_KEY_DEPENDENCIES] = [
format_obsidian_link(name)
for name in frontmatter_data[FM_KEY_DEPENDENCIES]
]
if card.todo_list_completed:
if card.todo_list_completed is not None:
frontmatter_data[FM_KEY_TODO_LIST_COMPLETED] = card.todo_list_completed
if card.archived:
if card.archived is not None:
frontmatter_data[FM_KEY_ARCHIVED] = card.archived
if card.due_date:
if card.due_date is not None:
frontmatter_data[FM_KEY_DUE_DATE] = card.due_date
if card.start_date:
if card.start_date is not None:
frontmatter_data[FM_KEY_DUE_DATE] = card.start_date
# Card name

View File

@ -1,9 +1,12 @@
import pytest
from favro_sync.favro_markdown import CardFileFormatter
EXAMPLE_TEXT_1 = """
---
aliases:
- Hello World
archived: false
todo-list-completed: false
---
# Hello World
@ -24,6 +27,7 @@ EXAMPLE_TEXT_2 = """
---
aliases:
- Name of Card
archived: true
assignments:
- '[[Gunnar Gunnarson]]'
- '[[Alice Alicedottor]]'
@ -52,30 +56,30 @@ url: https://example.org
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)
def test_parse_and_render():
card_contents = FORMATTER.parse_card_contents(EXAMPLE_TEXT_1)
assert card_contents.name == 'Hello World'
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_1
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)
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