Skip to content

Commit

Permalink
Merge pull request #50 from jurraca/add-reproduce-test
Browse files Browse the repository at this point in the history
bug fix: checking reproduce and epoch args logic
  • Loading branch information
fjahr authored Jan 21, 2025
2 parents d6f675c + d6b21b2 commit bf38f02
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
4 changes: 2 additions & 2 deletions kartograf/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ def main(args=None):
parser = create_parser()
args = parser.parse_args(args)

if args.command == "run":
if args.reproduce and not args.epoch:
if args.command == "map":
if not args.reproduce and args.epoch:
parser.error("--reproduce is required when --epoch is set.")
elif not args.epoch and args.reproduce:
parser.error("--epoch is required when --reproduce is set.")
Expand Down
17 changes: 17 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,23 @@ def test_map_command(parser):
assert args.epoch is None
assert args.max_encode == 33521664

def test_reproduce_args_failure(capsys):
'''
Both --reproduce and --epoch must be set if either one is set.
A usage help text is returned with the error.
'''
args = ['map', '-r', '/path']
with pytest.raises(SystemExit):
main(args)
captured = capsys.readouterr()
assert captured.err.startswith("usage:")

args = ['map', '-t', '123456789']
with pytest.raises(SystemExit):
main(args)
captured = capsys.readouterr()
assert captured.err.startswith("usage:")

def test_map_with_options(parser):
args = parser.parse_args(['map', '-c', '-irr', '-rv', '-r', '/path', '-t', '123'])
assert args.cleanup is True
Expand Down

0 comments on commit bf38f02

Please sign in to comment.