Clean up flake8 errors for eos unit tests (#65753)

These were found while migrating our content to eos collections.

Signed-off-by: Paul Belanger <pabelanger@redhat.com>
This commit is contained in:
Paul Belanger 2019-12-12 07:44:13 -05:00 committed by GitHub
parent 90072d1baa
commit 80333f9c4b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 25 deletions

View file

@ -70,7 +70,7 @@ class TestEosConfigModule(TestEosModule):
args = dict(lines=lines) args = dict(lines=lines)
set_module_args(args) set_module_args(args)
self.conn.get_diff = MagicMock(return_value=self.cliconf_obj.get_diff(config, config)) self.conn.get_diff = MagicMock(return_value=self.cliconf_obj.get_diff(config, config))
result = self.execute_module() self.execute_module()
def test_eos_config_src(self): def test_eos_config_src(self):
src = load_fixture('eos_config_candidate.cfg') src = load_fixture('eos_config_candidate.cfg')
@ -134,27 +134,27 @@ class TestEosConfigModule(TestEosModule):
def test_eos_config_src_and_lines_fails(self): def test_eos_config_src_and_lines_fails(self):
args = dict(src='foo', lines='foo') args = dict(src='foo', lines='foo')
set_module_args(args) set_module_args(args)
result = self.execute_module(failed=True) self.execute_module(failed=True)
def test_eos_config_match_exact_requires_lines(self): def test_eos_config_match_exact_requires_lines(self):
args = dict(match='exact') args = dict(match='exact')
set_module_args(args) set_module_args(args)
result = self.execute_module(failed=True) self.execute_module(failed=True)
def test_eos_config_match_strict_requires_lines(self): def test_eos_config_match_strict_requires_lines(self):
args = dict(match='strict') args = dict(match='strict')
set_module_args(args) set_module_args(args)
result = self.execute_module(failed=True) self.execute_module(failed=True)
def test_eos_config_replace_block_requires_lines(self): def test_eos_config_replace_block_requires_lines(self):
args = dict(replace='block') args = dict(replace='block')
set_module_args(args) set_module_args(args)
result = self.execute_module(failed=True) self.execute_module(failed=True)
def test_eos_config_replace_config_requires_src(self): def test_eos_config_replace_config_requires_src(self):
args = dict(replace='config') args = dict(replace='config')
set_module_args(args) set_module_args(args)
result = self.execute_module(failed=True) self.execute_module(failed=True)
def test_eos_config_backup_returns__backup__(self): def test_eos_config_backup_returns__backup__(self):
args = dict(backup=True) args = dict(backup=True)
@ -171,14 +171,14 @@ class TestEosConfigModule(TestEosModule):
args = dict(save_when='modified') args = dict(save_when='modified')
set_module_args(args) set_module_args(args)
result = self.execute_module() self.execute_module()
run_commands.return_value = [load_fixture('eos_config_config.cfg'), run_commands.return_value = [load_fixture('eos_config_config.cfg'),
load_fixture('eos_config_config_updated.cfg')] load_fixture('eos_config_config_updated.cfg')]
args = dict(save_when='modified') args = dict(save_when='modified')
set_module_args(args) set_module_args(args)
result = self.execute_module(changed=True) self.execute_module(changed=True)
mock_run_commands.stop() mock_run_commands.stop()

View file

@ -160,9 +160,3 @@ class TestEosEapiModule(TestEosModule):
set_module_args(dict(state='stopped', timeout=1)) set_module_args(dict(state='stopped', timeout=1))
result = self.start_configured(failed=True) result = self.start_configured(failed=True)
'timeout expired before eapi running state changed' in result['msg'] 'timeout expired before eapi running state changed' in result['msg']
def test_eos_eapi_state_failed(self):
self.mock_verify_state.stop()
set_module_args(dict(state='stopped', timeout=1))
result = self.start_configured(failed=True)
'timeout expired before eapi running state changed' in result['msg']

View file

@ -19,9 +19,8 @@
from __future__ import (absolute_import, division, print_function) from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
from units.compat.mock import patch, MagicMock from units.compat.mock import patch
from ansible.modules.network.eos import eos_logging from ansible.modules.network.eos import eos_logging
from ansible.plugins.cliconf.eos import Cliconf
from units.modules.utils import set_module_args from units.modules.utils import set_module_args
from .eos_module import TestEosModule, load_fixture from .eos_module import TestEosModule, load_fixture
@ -72,31 +71,29 @@ class TestEosLoggingModule(TestEosModule):
def test_eos_buffer_size(self): def test_eos_buffer_size(self):
set_module_args(dict(dest='buffered', size=5000)) set_module_args(dict(dest='buffered', size=5000))
commands = ['logging buffered 5000'] commands = ['logging buffered 5000']
result = self.execute_module(changed=True, commands=commands) self.execute_module(changed=True, commands=commands)
def test_eos_buffer_size_idempotent(self): def test_eos_buffer_size_idempotent(self):
set_module_args(dict(dest='buffered', size=50000, level='informational')) set_module_args(dict(dest='buffered', size=50000, level='informational'))
result = self.execute_module(changed=False, commands=[]) self.execute_module(changed=False, commands=[])
def test_eos_facilty(self): def test_eos_facilty(self):
set_module_args(dict(facility='local2')) set_module_args(dict(facility='local2'))
commands = ['logging facility local2'] commands = ['logging facility local2']
result = self.execute_module(changed=True, commands=commands) self.execute_module(changed=True, commands=commands)
# when dest is not passed, 'None' is set to dest
# self.assertEqual(sorted(result['commands'])[1], commands[0])
def test_eos_facility_idempotent(self): def test_eos_facility_idempotent(self):
set_module_args(dict(facility='local7')) set_module_args(dict(facility='local7'))
result = self.execute_module(changed=False, commands=[]) self.execute_module(changed=False, commands=[])
def test_eos_level(self): def test_eos_level(self):
set_module_args(dict(dest='console', level='critical')) set_module_args(dict(dest='console', level='critical'))
commands = ['logging console critical'] commands = ['logging console critical']
result = self.execute_module(changed=True, commands=commands) self.execute_module(changed=True, commands=commands)
def test_eos_level_idempotent(self): def test_eos_level_idempotent(self):
set_module_args(dict(dest='console', level='warnings')) set_module_args(dict(dest='console', level='warnings'))
result = self.execute_module(changed=False, commands=[]) self.execute_module(changed=False, commands=[])
def test_eos_logging_state_absent(self): def test_eos_logging_state_absent(self):
set_module_args(dict(dest='host', name='175.16.0.10', state='absent')) set_module_args(dict(dest='host', name='175.16.0.10', state='absent'))

View file

@ -107,4 +107,4 @@ class TestEosSystemModule(TestEosModule):
def test_eos_system_missing_vrf(self): def test_eos_system_missing_vrf(self):
name_servers = dict(server='8.8.8.8', vrf='missing') name_servers = dict(server='8.8.8.8', vrf='missing')
set_module_args(dict(name_servers=name_servers)) set_module_args(dict(name_servers=name_servers))
result = self.execute_module(failed=True) self.execute_module(failed=True)