Verified Commit 6099e271 authored by David Runge's avatar David Runge
Browse files

Remove Path checking from operations

repo_management/operations.py:
Remove the explicit Path checks from `dump_db_to_json_files()` as they
are now generically implemented in argparse.ArgParseFactory.

tests/test_operations.py
Remove tests for Path checks in `dump_db_to_json_files()`.
parent 9bb539dd
......@@ -71,15 +71,6 @@ def dump_db_to_json_files(input_path: Path, output_path: Path) -> None:
A directory in which to
"""
if not input_path.exists():
raise RuntimeError(f"The input file does not exist: {input_path}")
if not input_path.is_file():
raise RuntimeError(f"The input file is not a file: {input_path}")
if not output_path.exists():
raise RuntimeError(f"The provided output path does not exist: {output_path}")
if not output_path.is_dir():
raise RuntimeError(f"The provided output path is not a directory: {output_path}")
for name, model in db_file_as_models(db_path=input_path):
with open(join(output_path, f"{name}.json"), "wb") as output_file:
output_file.write(
......
......@@ -4,8 +4,7 @@ import tempfile
from pathlib import Path
from typing import Iterator
from mock import Mock
from pytest import fixture, raises
from pytest import fixture
from repo_management import models, operations
......@@ -37,20 +36,3 @@ def test_dump_db_to_json_files(
create_dir_path: Path,
) -> None:
operations.dump_db_to_json_files(input_path=create_gz_db_file, output_path=create_dir_path)
def test_dump_db_to_json_files_raises() -> None:
input_path = Mock(
exists=Mock(side_effect=[False, True, True, True]),
is_file=Mock(side_effect=[False, True, True]),
)
output_path = Mock(
exists=Mock(side_effect=[False, True]),
is_dir=Mock(side_effect=[False]),
)
counter = 0
while counter < 4:
with raises(RuntimeError):
operations.dump_db_to_json_files(input_path=input_path, output_path=output_path)
counter += 1
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment