Skip to content

Commit

Permalink
fixing no time bounds from command line
Browse files Browse the repository at this point in the history
  • Loading branch information
rizac committed Jul 11, 2023
1 parent d4ff564 commit 6146079
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
14 changes: 9 additions & 5 deletions mecompute/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,15 @@ def cli(d_config, start, end, time_window, force_overwrite, p_config, h_template
process -s 2016-01-02 -t 2 OUT_DIR
"""
start, end = _get_timebounds(start, end, time_window)
dest_dir = output_dir.replace("%S%", start).replace("%E%", end)
ret = process(d_config, start, end, dest_dir,
force_overwrite=force_overwrite, p_config=p_config,
html_template=h_template)
if start is None and end is None and time_window is None:
print('No time bounds specified. Please provide -s, -e or -t', file=sys.stderr)
ret = False
else:
start, end = _get_timebounds(start, end, time_window)
dest_dir = output_dir.replace("%S%", start).replace("%E%", end)
ret = process(d_config, start, end, dest_dir,
force_overwrite=force_overwrite, p_config=p_config,
html_template=h_template)
if ret:
sys.exit(0)
sys.exit(1)
Expand Down
13 changes: 13 additions & 0 deletions test/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,19 @@ def test_proc_ess_params(mock_process, capsys):
timedelta(days=days)


@patch('mecompute.run.process')
def test_proc_no_time_bounds(mock_process, capsys):
runner = CliRunner()
now = datetime.utcnow().replace(microsecond=0,hour=0, minute=0, second=0)
days = 365
result = runner.invoke(cli, ['-f',
'-d', TEST_DOWNLOAD_CONFIG_PATH,
TEST_TMP_ROOT_DIR])
assert not mock_process.called
assert 'no time bounds specified' in result.output.lower()
assert result.exit_code != 0


@pytest.mark.parametrize('params', [
['-s', '2022-05-20T09:00:00', '-e', '2022-05-20T13:00:00'], # process all db events
])
Expand Down

0 comments on commit 6146079

Please sign in to comment.