Пример #1
0
def test_init_creates_config_file(app_without_root: RootlessApp) -> None:
    """init must create .slipbox/config.cfg."""
    app = app_without_root
    commands.init(app)
    assert app.root is not None

    hidden = app.root / ".slipbox"
    assert hidden.is_dir()
    assert hidden.joinpath("config.cfg").is_file()
Пример #2
0
def test_init_quiet(
    app_without_root: App,
    capsys: pytest.CaptureFixture[str],
) -> None:
    """init must not print anything in quiet mode."""
    app = app_without_root
    app.args["quiet"] = True
    commands.init(app)
    stdout, stderr = capsys.readouterr()
    assert not stdout
    assert not stderr
Пример #3
0
def test_init_patterns(app_without_root: RootlessApp) -> None:
    """.slipbox/config.cfg must contain some glob patterns."""
    app = app_without_root
    commands.init(app)
    assert app.root is not None
    hidden = app.root / ".slipbox"

    parser = ConfigParser()
    parser.read(hidden / "config.cfg")

    assert parser.getboolean("note-patterns", "*.md")
    assert parser.getboolean("note-patterns", "*.rst")
Пример #4
0
def app(app_without_root: App) -> t.Iterable[App]:
    """App object with root."""
    app = app_without_root
    app.args = {"quiet": True}
    init(app)
    yield app
Пример #5
0
def test_init_root(app_without_root: RootlessApp) -> None:
    """init must set app.root."""
    app = app_without_root
    assert app.root is None
    commands.init(app)
    assert app.root is not None