forked from jrnl-org/jrnl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tags with only tagsymbols should not be tags
Text made up only of tagsymbols should not be treated as a tag. Closes jrnl-org#1700
- Loading branch information
1 parent
dc12d50
commit d2c842e
Showing
2 changed files
with
46 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import pytest | ||
|
||
from jrnl.journals.Entry import Entry | ||
from jrnl.journals.Journal import Journal | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"text, tag_symbols, expected_tags", | ||
[ | ||
("This has no tag symbols", "", []), | ||
("This has no tags and a single tag symbol", "@", []), | ||
("This has no tags and multiple tag symbols", "@#", []), | ||
("This has a @simple tag", "@", ["@simple"]), | ||
("Tag can contain some punctuation @simple-tag.", "@", ["@simple-tag"]), | ||
("This has a tag at the end of a sentence @simple.", "@", ["@simple"]), | ||
("This has an empty @ tag", "@", []), | ||
("This text has @multiple @tags", "@", ["@multiple", "@tags"]), | ||
("@@@@ This text has no tags", "@", []), | ||
("@@@# This text has no @### tags", "@#", []), | ||
("@@@#tag1 This text has two #@#@tags", "@#", ["@@@#tag1", "#@#@tags"]), | ||
("@prefix#tag1 This text has two #prefix@tag2", "@#", ["@prefix#tag1", "#prefix@tag2"]), | ||
], | ||
) | ||
def test_tag_extraction(text, tag_symbols, expected_tags): | ||
jrnl = Journal() | ||
jrnl.config["tagsymbols"] = tag_symbols | ||
|
||
entry = Entry(jrnl, date=None, text=text) | ||
if entry.tags != expected_tags: | ||
pass | ||
|
||
assert sorted(entry.tags) == sorted(expected_tags) | ||
|
||
|