Commit eac31d9f authored by Marius Gedminas's avatar Marius Gedminas

repozo -B with missing -f should show a clear error

Fixes #259.
parent 334282c3
......@@ -251,6 +251,8 @@ def parseargs(argv):
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')
......
......@@ -150,7 +150,8 @@ class Test_parseargs(unittest.TestCase):
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)
......@@ -173,9 +174,11 @@ class Test_parseargs(unittest.TestCase):
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):
......@@ -186,6 +189,7 @@ class Test_parseargs(unittest.TestCase):
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)
......@@ -195,6 +199,12 @@ class Test_parseargs(unittest.TestCase):
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',
......
Markdown is supported
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