This fixes a lot of awkwardness that came from having the record() functionality inside of store.py. It is still broken, but is much closer to actually working now. I also sketched some data and io functionality, which has no tests and is not yet working at all.
39 lines
983 B
Python
39 lines
983 B
Python
from click.testing import CliRunner
|
|
from nancy.cli import main
|
|
import pytest
|
|
|
|
import os
|
|
from pathlib import Path
|
|
import tempfile
|
|
from typing import Iterator
|
|
|
|
|
|
@pytest.fixture
|
|
def junk_dir() -> Iterator[Path]:
|
|
"""Create a temp directory with a few files"""
|
|
with tempfile.TemporaryDirectory(prefix="nancy_junkdir") as d:
|
|
root = Path(d)
|
|
open(root / "empty.txt", "w").close() # touch a file
|
|
open(root / "full.txt", "w").write("something") # touch a file
|
|
os.mkdir(root / "d")
|
|
open(root / "foo.txt", "w").write("bar") # touch a file
|
|
yield root
|
|
|
|
|
|
def test_record(junk_dir: Path) -> None:
|
|
runner = CliRunner()
|
|
result = runner.invoke(
|
|
main,
|
|
[
|
|
"record",
|
|
"-s",
|
|
str(junk_dir),
|
|
"-m",
|
|
"This is just a test recording",
|
|
],
|
|
input="y\n",
|
|
)
|
|
print(result.output)
|
|
assert result.exit_code == 0
|
|
assert "ERROR" not in result.output
|