Skip to content

Commit

Permalink
Test vimala.vim() using new vim_proc_mock fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
bbugyi200 committed Mar 8, 2024
1 parent 6c2e399 commit 5f8176f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
2 changes: 0 additions & 2 deletions src/zorg/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ class EditConfig(Config):

# ----- ARGUMENTS
zo_paths: list[Path]
# TODO(bugyi): Rename to dry_run
edit_day_log: bool = True


class TemplateRenderConfig(Config):
Expand Down
4 changes: 2 additions & 2 deletions src/zorg/file_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import datetime as dt
from pathlib import Path
from typing import Sequence
from typing import Iterable, Sequence

from typist import PathLike

Expand All @@ -11,7 +11,7 @@

# TODO(bugyi): See if you can reduce complexity between this and _paths_from_file_group()
def expand_file_group_paths(
zo_paths: Sequence[PathLike],
zo_paths: Iterable[PathLike],
*,
file_group_map: FileGroupMapType,
) -> list[Path]:
Expand Down
5 changes: 2 additions & 3 deletions src/zorg/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ def run_edit(cfg: EditConfig) -> int:
zo_path.write_text(contents)
break

if cfg.edit_day_log:
_start_vim_loop(zo_paths, cfg=cfg)
_start_vim_loop(zo_paths, cfg=cfg)
return 0


Expand Down Expand Up @@ -94,7 +93,7 @@ def _start_vim_loop(zo_paths: Iterable[Path], cfg: EditConfig) -> None:
vimala.vim(
*_add_paths_to_zdir(cfg.zettel_dir, paths),
commands=_process_vim_commands(cfg.zettel_dir, cfg.vim_commands),
)
).unwrap()


def _process_vim_commands(
Expand Down
3 changes: 1 addition & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from . import common as c


pytest_plugins = ["clack.pytest_plugin"]
pytest_plugins = ["clack.pytest_plugin", "vimala.pytest_plugin"]


if TYPE_CHECKING: # fixes pytest warning
Expand All @@ -32,7 +32,6 @@ def main(make_config_file: MakeConfigFile, tmp_path: Path) -> c.MainType:

def inner_main(*args: str, **kwargs: Any) -> int:
kwargs.setdefault("zettel_dir", default_zettel_dir)
kwargs.setdefault("edit_day_log", False)
kwargs.setdefault("template_pattern_map", {".*": "default.zo"})

cfg_kwargs = {
Expand Down
9 changes: 8 additions & 1 deletion tests/test_edit_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
from __future__ import annotations

from pathlib import Path
from unittest.mock import Mock

from syrupy.assertion import SnapshotAssertion as Snapshot

from . import common as c


def test_edit_day_logs(
main: c.MainType, tmp_path: Path, snapshot: Snapshot
main: c.MainType, vim_proc_mock: Mock, tmp_path: Path, snapshot: Snapshot
) -> None:
"""Test that we properly generate test day, habit, and done logs."""
zettel_dir = tmp_path / "org"
Expand Down Expand Up @@ -55,3 +56,9 @@ def test_edit_day_logs(
assert day_log_path.read_text() == snapshot
assert habit_log_path.read_text() == snapshot
assert done_log_path.read_text() == snapshot
vim_proc_mock.assert_called_once_with(
["vim", str(day_log_path), str(habit_log_path), str(done_log_path)],
stdout=None,
stderr=None,
timeout=None,
)

0 comments on commit 5f8176f

Please sign in to comment.