Skip to content

Commit

Permalink
repozo -B with missing -f should show a clear error
Browse files Browse the repository at this point in the history
Fixes #259.
  • Loading branch information
mgedmin committed Mar 18, 2019
1 parent 334282c commit eac31d9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/ZODB/scripts/repozo.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,8 @@ class Options(object):
if options.withverify is not None:
log('--with-verify option is ignored in backup mode')
options.withverify = None
if not options.file:
usage(1, '--file is required in backup mode')
elif options.mode == RECOVER:
if options.file is not None:
log('--file option is ignored in recover mode')
Expand Down
16 changes: 13 additions & 3 deletions src/ZODB/scripts/tests/test_repozo.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ def test_bad_argument(self):

def test_mode_selection(self):
from ZODB.scripts import repozo
options = repozo.parseargs(['-B', '-r', '/tmp/nosuchdir'])
options = repozo.parseargs([
'-B', '-f', '/tmp/Data.fs', '-r', '/tmp/nosuchdir'])
self.assertEqual(options.mode, repozo.BACKUP)
options = repozo.parseargs(['-R', '-r', '/tmp/nosuchdir'])
self.assertEqual(options.mode, repozo.RECOVER)
Expand All @@ -173,9 +174,11 @@ def test_mode_selection_required(self):

def test_misc_flags(self):
from ZODB.scripts import repozo
options = repozo.parseargs(['-B', '-r', '/tmp/nosuchdir', '-F'])
options = repozo.parseargs([
'-B', '-f', '/tmp/Data.fs', '-r', '/tmp/nosuchdir', '-F'])
self.assertTrue(options.full)
options = repozo.parseargs(['-B', '-r', '/tmp/nosuchdir', '-k'])
options = repozo.parseargs([
'-B', '-f', '/tmp/Data.fs', '-r', '/tmp/nosuchdir', '-k'])
self.assertTrue(options.killold)

def test_repo_is_required(self):
Expand All @@ -186,6 +189,7 @@ def test_repo_is_required(self):
def test_backup_ignored_args(self):
from ZODB.scripts import repozo
options = repozo.parseargs(['-B', '-r', '/tmp/nosuchdir', '-v',
'-f', '/tmp/Data.fs',
'-o', '/tmp/ignored.fs',
'-D', '2011-12-13'])
self.assertEqual(options.date, None)
Expand All @@ -195,6 +199,12 @@ def test_backup_ignored_args(self):
self.assertIn('--output option is ignored in backup mode',
sys.stderr.getvalue())

def test_backup_required_args(self):
from ZODB.scripts import repozo
self.assertRaises(SystemExit, repozo.parseargs,
['-B', '-r', '/tmp/nosuchdir'])
self.assertIn('--file is required', sys.stderr.getvalue())

def test_recover_ignored_args(self):
from ZODB.scripts import repozo
options = repozo.parseargs(['-R', '-r', '/tmp/nosuchdir', '-v',
Expand Down

0 comments on commit eac31d9

Please sign in to comment.