Initial productized Importarr service
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
from importarr.config import Settings
|
||||
from importarr.state import State
|
||||
|
||||
|
||||
def test_path_must_be_under_root(tmp_path):
|
||||
settings = Settings(download_root=tmp_path / "manual")
|
||||
try:
|
||||
settings.resolve_under_download_root("/etc")
|
||||
except ValueError:
|
||||
pass
|
||||
else:
|
||||
raise AssertionError("expected ValueError")
|
||||
|
||||
|
||||
def test_manual_batch_completes_when_empty(tmp_path, monkeypatch):
|
||||
monkeypatch.setenv("IMPORTARR_STATE_PATH", str(tmp_path / "initial.db"))
|
||||
import importarr.main as main
|
||||
download = tmp_path / "downloads"
|
||||
movies = tmp_path / "movies"
|
||||
tv = tmp_path / "tv"
|
||||
batch = download / "Release"
|
||||
batch.mkdir(parents=True)
|
||||
(batch / "Movie.mkv").write_bytes(b"movie")
|
||||
monkeypatch.setattr(main, "settings", Settings(download_root=download, movies_root=movies, tv_root=tv, state_path=tmp_path / "state.db"))
|
||||
monkeypatch.setattr(main, "state", State(tmp_path / "state.db"))
|
||||
main.state.add_manual_batch(batch)
|
||||
assert main._import_manual_batches(main.Importer(movies, tv)) == 1
|
||||
rows = main.state.list_manual_batches()
|
||||
assert rows[0]["status"] == "completed"
|
||||
assert (movies / "Movie.mkv").exists()
|
||||
Reference in New Issue
Block a user