Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eigenric/develop #1

Merged
merged 3 commits into from
May 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions jrnl/journals/Journal.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,15 +300,15 @@ def excluded(tags):
or (
strict
and all(
substring in entry.title.casefold()
substring in entry.title.casefold()
or substring in entry.body.casefold()
for substring in contains_lower
)
)
or (
not strict
not strict
and any(
substring in entry.title.casefold()
substring in entry.title.casefold()
or substring in entry.body.casefold()
for substring in contains_lower
)
Expand Down
30 changes: 30 additions & 0 deletions tests/bdd/features/search.feature
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,36 @@ Feature: Searching in a journal
| basic_folder.yaml |
| basic_dayone.yaml |

Scenario Outline: Multiple -contains returns entries that match any
Given we use the config "<config_file>"
When we run "jrnl -contains emojis -contains lorem --short"
Then we should get no error
And the output should contain "3 entries found"
And the output should be
2020-08-29 11:11 Entry the first.
2020-08-31 14:32 A second entry in what I hope to be a long series.
2020-09-24 09:14 The third entry finally after weeks without writing.

Examples: configs
| config_file |
| basic_onefile.yaml |
| basic_folder.yaml |
| basic_dayone.yaml |

Scenario Outline: Multiple -contains with -and returns only entries that match all
Given we use the config "<config_file>"
When we run "jrnl -contains emojis -contains nulla -and --short"
Then we should get no error
And the output should contain "1 entry found"
And the output should be
2020-09-24 09:14 The third entry finally after weeks without writing.

Examples: configs
| config_file |
| basic_onefile.yaml |
| basic_folder.yaml |
| basic_dayone.yaml |

Scenario Outline: Searching for a string within tag results
Given we use the config "<config_file>"
When we run "jrnl @tagone -contains maybe"
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_parse_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def test_empty():


def test_contains_alone():
assert cli_as_dict("-contains whatever") == expected_args(contains="whatever")
assert cli_as_dict("-contains whatever") == expected_args(contains=["whatever"])


def test_debug_alone():
Expand Down