fix: allow adding inline tags with same key different values (#17)

This commit is contained in:
Nathaniel Landau
2023-02-05 13:07:48 -05:00
committed by GitHub
parent 401d830942
commit 446374b335
5 changed files with 92 additions and 36 deletions

View File

@@ -46,7 +46,6 @@ horizontal: rule
"""
INLINE_CONTENT = """\
repeated_key:: repeated_key_value1
#inline_tag_top1,#inline_tag_top2
**bold_key1**:: bold_key1_value
**bold_key2:: bold_key2_value**
@@ -280,9 +279,6 @@ def test_inline_metadata_add() -> None:
"tag_key": ["tag_key_value"],
}
with pytest.raises(ValueError):
assert inline.add("added_key1", "added_value_2") is True
assert inline.dict == {
"added_key": [],
"added_key1": ["added_value"],
@@ -309,6 +305,8 @@ def test_inline_metadata_add() -> None:
"repeated_key": ["repeated_key_value1", "repeated_key_value2"],
"tag_key": ["tag_key_value"],
}
assert inline.add("repeated_key", "repeated_key_value1") is False
assert inline.add("repeated_key", "new_value") is True
def test_inline_metadata_contains() -> None:

View File

@@ -99,6 +99,21 @@ def test_add_metadata_inline(short_note) -> None:
)
assert "new_key2:: new_value1" in note.file_content
assert (
note.add_metadata(
MetadataType.INLINE, key="new_key2", value="new_value2", location=InsertLocation.BOTTOM
)
is True
)
assert "new_key2:: new_value2" in note.file_content
assert (
note.add_metadata(
MetadataType.INLINE, key="new_key2", value="new_value2", location=InsertLocation.BOTTOM
)
is False
)
def test_add_metadata_frontmatter(sample_note) -> None:
"""Test adding metadata."""