Verified Commit 8836d5c3 authored by David Runge's avatar David Runge 🐿
Browse files

Add CLI entrypoint for db2json

Add `db2json()` which may serve as an entrypoint for a db2json script,
as it makes use of the argument parser defined in
`argparse.ArgParseFactory.db2json()` and calls
`operations.dump_db_to_json_files()` using the provided inputs.

Add a unittest for `db2json()`, which patches all called methods.
The methods are tested extensively elsewhere. However, the function
should see proper integration testing via this endpoint in the future.
parent 6099e271
from repo_management import argparse, operations
def db2json() -> None:
"""The entry point for the db2json script
The method calls operations.dump_db_to_json_files() which creates JSON files for each member of a provided
repository database file.
args = argparse.ArgParseFactory.db2json().parse_args()
from argparse import Namespace
from mock import Mock, patch
from repo_management import cli
def test_db2json(argparsefactory_mock: Mock, dump_db_to_json_files_mock: Mock) -> None:
namespace = Namespace(db_file="db_file", output_dir="output_dir")
argparsefactory_mock.db2json.return_value = Mock(parse_args=Mock(return_value=namespace))
dump_db_to_json_files_mock.assert_called_once_with(input_path=namespace.db_file, output_path=namespace.output_dir)
Supports Markdown
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