Make sure we're using the opts dict mocking in parsers_test

The additional call to parser.parse_args(args) negates the first
patch to running self.config_func. We want the opts that we set
up in the above test to patch the setup args when the parse_args
func is called. This updates the mock to work with better with
patch and removes the additional parser.parse_args call.
This commit is contained in:
rallytime 2017-01-20 10:20:51 -07:00
parent 315b2c8712
commit ce6d1b103d

View file

@ -700,15 +700,17 @@ class SaltKeyOptionParserTestCase(LogSettingsParserTests):
log_level = 'info'
args = self.args
# Set log level in config
opts = {self.loglevel_config_setting_name: log_level}
# Set log level in config and set additional mocked opts keys
opts = {self.loglevel_config_setting_name: log_level,
self.logfile_config_setting_name: 'key_logfile',
'log_fmt_logfile': None,
'log_datefmt_logfile': None}
parser = self.parser()
with patch(self.config_func, MagicMock(return_value=opts)):
parser.parse_args(args)
with patch('salt.utils.parsers.is_writeable', MagicMock(return_value=True)):
parser.parse_args(args)
parser.setup_logfile_logger()
with patch('salt.utils.parsers.is_writeable', MagicMock(return_value=True)):
parser.setup_logfile_logger()
# Check config name absence in options
self.assertNotIn(self.loglevel_config_setting_name, parser.options.__dict__)