Commit d39787aa authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

[trac610] added tests for --csv-file-dir

For testing purpose I also renamed to
I needed to replace dash with underscore to use it in an import statement,
and _main seemed to better explain what it is than _source, so I also
renamed that part.
parent 86d0ba90
...@@ -723,7 +723,7 @@ AC_OUTPUT([doc/version.ent ...@@ -723,7 +723,7 @@ AC_OUTPUT([doc/version.ent
src/bin/bind10/tests/ src/bin/bind10/tests/
src/bin/bind10/ src/bin/bind10/
src/bin/bindctl/ src/bin/bindctl/
src/bin/bindctl/ src/bin/bindctl/
src/bin/bindctl/tests/bindctl_test src/bin/bindctl/tests/bindctl_test
src/bin/loadzone/ src/bin/loadzone/
src/bin/loadzone/tests/correct/ src/bin/loadzone/tests/correct/
...@@ -19,8 +19,8 @@ bindctl.1: bindctl.xml ...@@ -19,8 +19,8 @@ bindctl.1: bindctl.xml
endif endif
bindctl: bindctl:
$(SED) -e "s|@@PYTHONPATH@@|@pyexecdir@|" \ $(SED) -e "s|@@PYTHONPATH@@|@pyexecdir@|" \
-e "s|@@SYSCONFDIR@@|@sysconfdir@|" \ -e "s|@@SYSCONFDIR@@|@sysconfdir@|" \
-e "s|@@LIBEXECDIR@@|$(pkglibexecdir)|" >$@ -e "s|@@LIBEXECDIR@@|$(pkglibexecdir)|" >$@
chmod a+x $@ chmod a+x $@
...@@ -19,8 +19,10 @@ import ...@@ -19,8 +19,10 @@ import
import os import os
import pwd import pwd
import getpass import getpass
from optparse import OptionParser
from isc.config.config_data import ConfigData, MultiConfigData from isc.config.config_data import ConfigData, MultiConfigData
from isc.config.module_spec import ModuleSpec from isc.config.module_spec import ModuleSpec
from bindctl.bindctl_source import set_bindctl_options
from bindctl import cmdparse from bindctl import cmdparse
from bindctl import bindcmd from bindctl import bindcmd
from bindctl.moduleinfo import * from bindctl.moduleinfo import *
...@@ -368,6 +370,40 @@ class TestBindCmdInterpreter(unittest.TestCase): ...@@ -368,6 +370,40 @@ class TestBindCmdInterpreter(unittest.TestCase):
self.assertEqual([], users) self.assertEqual([], users)
os.remove(csvfilename) os.remove(csvfilename)
class TestCommandLineOptions(unittest.TestCase):
class FakeParserError(Exception):
"""An exception thrown from FakeOptionParser on parser error.
class FakeOptionParser(OptionParser):
"""This fake class emulates the OptionParser class with customized
error handling for the convenient of tests.
def __init__(self):
def error(self, msg):
raise TestCommandLineOptions.FakeParserError
def setUp(self):
self.parser = self.FakeOptionParser()
def test_csv_file_dir(self):
# by default the option is "undefined"
(options, _) = self.parser.parse_args([])
self.assertEqual(None, options.csv_file_dir)
# specify the option, valid case.
(options, _) = self.parser.parse_args(['--csv-file-dir', 'some_dir'])
self.assertEqual('some_dir', options.csv_file_dir)
# missing option arg; should trigger parser error.
self.assertRaises(self.FakeParserError, self.parser.parse_args,
if __name__== "__main__": if __name__== "__main__":
unittest.main() unittest.main()
Supports Markdown
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