mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 04:40:22 -07:00
test/: PEP8 compliancy (#24803)
* test/: PEP8 compliancy - Make PEP8 compliant * Python3 chokes on casting int to bytes (#24952) But if we tell the formatter that the var is a number, it works
This commit is contained in:
parent
31c59ad5f9
commit
4efec414e7
110 changed files with 1702 additions and 1547 deletions
|
@ -35,6 +35,7 @@ def set_module_args(args):
|
|||
fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures')
|
||||
fixture_data = {}
|
||||
|
||||
|
||||
def load_fixture(name):
|
||||
path = os.path.join(fixture_path, name)
|
||||
|
||||
|
@ -56,13 +57,14 @@ def load_fixture(name):
|
|||
class AnsibleExitJson(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class AnsibleFailJson(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class TestIosxrModule(unittest.TestCase):
|
||||
|
||||
def execute_module(self, failed=False, changed=False, commands=None,
|
||||
sort=True, defaults=False):
|
||||
def execute_module(self, failed=False, changed=False, commands=None, sort=True, defaults=False):
|
||||
|
||||
self.load_fixtures(commands)
|
||||
|
||||
|
@ -110,4 +112,3 @@ class TestIosxrModule(unittest.TestCase):
|
|||
|
||||
def load_fixtures(self, commands=None):
|
||||
pass
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ from ansible.compat.tests.mock import patch
|
|||
from ansible.modules.network.iosxr import iosxr_config
|
||||
from .iosxr_module import TestIosxrModule, load_fixture, set_module_args
|
||||
|
||||
|
||||
class TestIosxrConfigModule(TestIosxrModule):
|
||||
|
||||
module = iosxr_config
|
||||
|
@ -73,19 +74,19 @@ class TestIosxrConfigModule(TestIosxrModule):
|
|||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_iosxr_config_before(self):
|
||||
set_module_args(dict(lines=['hostname foo'], before=['test1','test2']))
|
||||
set_module_args(dict(lines=['hostname foo'], before=['test1', 'test2']))
|
||||
commands = ['test1', 'test2', 'hostname foo']
|
||||
self.execute_module(changed=True, commands=commands, sort=False)
|
||||
|
||||
def test_iosxr_config_after(self):
|
||||
set_module_args(dict(lines=['hostname foo'], after=['test1','test2']))
|
||||
set_module_args(dict(lines=['hostname foo'], after=['test1', 'test2']))
|
||||
commands = ['hostname foo', 'test1', 'test2']
|
||||
self.execute_module(changed=True, commands=commands, sort=False)
|
||||
|
||||
def test_iosxr_config_before_after_no_change(self):
|
||||
set_module_args(dict(lines=['hostname router'],
|
||||
before=['test1', 'test2'],
|
||||
after=['test3','test4']))
|
||||
after=['test3', 'test4']))
|
||||
self.execute_module()
|
||||
|
||||
def test_iosxr_config_config(self):
|
||||
|
|
|
@ -66,8 +66,7 @@ class TestIosxrFacts(TestIosxrModule):
|
|||
self.assertIn('interfaces', ansible_facts['ansible_net_gather_subset'])
|
||||
self.assertEquals('iosxr01', ansible_facts['ansible_net_hostname'])
|
||||
self.assertEquals(['disk0:', 'flash0:'], ansible_facts['ansible_net_filesystems'])
|
||||
self.assertIn('GigabitEthernet0/0/0/0',
|
||||
ansible_facts['ansible_net_interfaces'].keys())
|
||||
self.assertIn('GigabitEthernet0/0/0/0', ansible_facts['ansible_net_interfaces'].keys())
|
||||
self.assertEquals('3095', ansible_facts['ansible_net_memtotal_mb'])
|
||||
self.assertEquals('1499', ansible_facts['ansible_net_memfree_mb'])
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ class TestIosxrSystemModule(TestIosxrModule):
|
|||
|
||||
def test_iosxr_system_domain_search(self):
|
||||
set_module_args(dict(domain_search=['ansible.com', 'redhat.com']))
|
||||
commands=['domain list ansible.com', 'no domain list cisco.com']
|
||||
commands = ['domain list ansible.com', 'no domain list cisco.com']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_iosxr_system_lookup_source(self):
|
||||
|
@ -78,14 +78,18 @@ class TestIosxrSystemModule(TestIosxrModule):
|
|||
|
||||
def test_iosxr_system_state_absent(self):
|
||||
set_module_args(dict(state='absent'))
|
||||
commands = ['no hostname', 'no domain name',
|
||||
'no domain lookup disable',
|
||||
'no domain lookup source-interface MgmtEth0/0/CPU0/0',
|
||||
'no domain list redhat.com', 'no domain list cisco.com',
|
||||
'no domain name-server 8.8.8.8', 'no domain name-server 8.8.4.4']
|
||||
commands = [
|
||||
'no hostname',
|
||||
'no domain name',
|
||||
'no domain lookup disable',
|
||||
'no domain lookup source-interface MgmtEth0/0/CPU0/0',
|
||||
'no domain list redhat.com',
|
||||
'no domain list cisco.com',
|
||||
'no domain name-server 8.8.8.8',
|
||||
'no domain name-server 8.8.4.4'
|
||||
]
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_iosxr_system_no_change(self):
|
||||
set_module_args(dict(hostname='iosxr01', domain_name='eng.ansible.com'))
|
||||
self.execute_module()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue