fix: remove unnecessary question when viewing diffs

This commit is contained in:
Nathaniel Landau
2023-02-05 10:28:53 -05:00
parent 7eb8ff5fa8
commit 401d830942
2 changed files with 3 additions and 13 deletions

View File

@@ -517,13 +517,7 @@ class Application:
alerts.info("No changes to review.")
return
print(f"\nFound {len(changed_notes)} changed notes in the vault.\n")
answer = self.questions.ask_confirm(
question="View diffs of individual files?", default=False
)
if not answer: # pragma: no cover
return
alerts.info(f"Found {len(changed_notes)} changed notes in the vault")
choices: list[dict[str, Any] | questionary.Separator] = [questionary.Separator()]
for n, note in enumerate(changed_notes, start=1):
_selection = {
@@ -538,7 +532,7 @@ class Application:
while True:
note_to_review = self.questions.ask_selection(
choices=choices,
question="Select a new to view the diff",
question="Select an updated note to view the diff",
)
if note_to_review is None or note_to_review == "return":
break

View File

@@ -530,10 +530,6 @@ def test_review_changes(test_application, mocker, capsys) -> None:
"obsidian_metadata.models.application.Questions.ask_application_main",
side_effect=["rename_metadata", "review_changes", KeyError],
)
mocker.patch(
"obsidian_metadata.models.application.Questions.ask_confirm",
return_value=True,
)
mocker.patch(
"obsidian_metadata.models.application.Questions.ask_existing_key",
return_value="tags",
@@ -549,7 +545,7 @@ def test_review_changes(test_application, mocker, capsys) -> None:
with pytest.raises(KeyError):
app.application_main()
captured = capsys.readouterr()
assert captured.out == Regex(r".*Found.*\d+.*changed notes in the vault.*", re.DOTALL)
assert captured.out == Regex(r".*Found.*\d+.*changed notes in the vault", re.DOTALL)
assert "- tags:" in captured.out
assert "+ new_tags:" in captured.out