Skip to content

Commit

Permalink
add test to new cmd line func
Browse files Browse the repository at this point in the history
  • Loading branch information
valeriupredoi committed Nov 27, 2023
1 parent 489475b commit b759b33
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion tests/integration/test_command_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@
analysis_timeseries,
download_from_mass,
bgcval2_make_report,
analysis_compare
analysis_compare,
batch_timeseries
)
from bgcval2.analysis_timeseries import main as analysis_timeseries_main
from bgcval2.download_from_mass import main as download_from_mass_main
# bgcval.py is being retired
# from bgcval2.bgcval import run as bgcval_main
from bgcval2.bgcval2_make_report import main as bgcval2_make_report_main
from bgcval2.analysis_compare import main as analysis_compare_main
from bgcval2.batch_timeseries import main as bgcval2_batch_timeseries


def wrapper(f):
Expand Down Expand Up @@ -142,3 +144,27 @@ def test_bgcval2_make_report_command():
as (stdout, stderr):
bgcval2_make_report_main()
assert err in str(stderr.getvalue())


@patch('bgcval2.batch_timeseries.main', new=wrapper(bgcval2_batch_timeseries))
def test_bgcval2_make_report_command():
"""Test run command."""
with arguments('batch_timeseries', '--help'):
with pytest.raises(SystemExit) as pytest_wrapped_e:
bgcval2_batch_timeseries()
assert pytest_wrapped_e.type == SystemExit
assert pytest_wrapped_e.value.code == 0

err = "the following arguments are required: -y/--compare_yml"
with arguments('bgcval2_batch_timeseries'):
with pytest.raises(SystemExit) as cm, capture_sys_output() \
as (stdout, stderr):
bgcval2_batch_timeseries()
assert err in str(stderr.getvalue())

err = "argument -y/--compare_yml: expected at least one argument"
with arguments('bgcval2_batch_timeseries', '--compare_yml'):
with pytest.raises(SystemExit) as cm, capture_sys_output() \
as (stdout, stderr):
bgcval2_batch_timeseries()
assert err in str(stderr.getvalue())

0 comments on commit b759b33

Please sign in to comment.