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:
Dag Wieers
2017-05-30 19:05:19 +02:00
committed by John R Barker
parent 31c59ad5f9
commit 4efec414e7
110 changed files with 1702 additions and 1547 deletions

View File

@@ -19,8 +19,8 @@
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import os
import json
import os
from ansible.compat.tests import unittest
from ansible.compat.tests.mock import patch
@@ -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 TestEosModule(unittest.TestCase):
def execute_module(self, failed=False, changed=False, commands=None,
sort=True, defaults=False, transport='cli'):
def execute_module(self, failed=False, changed=False, commands=None, sort=True, defaults=False, transport='cli'):
self.load_fixtures(commands, transport=transport)
@@ -110,4 +112,3 @@ class TestEosModule(unittest.TestCase):
def load_fixtures(self, commands=None, transport='cli'):
pass

View File

@@ -25,6 +25,7 @@ from ansible.compat.tests.mock import patch
from ansible.modules.network.eos import eos_command
from .eos_module import TestEosModule, load_fixture, set_module_args
class TestEosCommandModule(TestEosModule):
module = eos_command

View File

@@ -71,7 +71,7 @@ class TestEosConfigModule(TestEosModule):
def test_eos_config_before(self):
args = dict(lines=['hostname switch01', 'ip domain-name eng.ansible.com'],
before=['before command'])
before=['before command'])
set_module_args(args)
@@ -83,7 +83,7 @@ class TestEosConfigModule(TestEosModule):
def test_eos_config_after(self):
args = dict(lines=['hostname switch01', 'ip domain-name eng.ansible.com'],
after=['after command'])
after=['after command'])
set_module_args(args)

View File

@@ -25,6 +25,7 @@ from ansible.compat.tests.mock import patch
from ansible.modules.network.eos import eos_system
from .eos_module import TestEosModule, load_fixture, set_module_args
class TestEosSystemModule(TestEosModule):
module = eos_system
@@ -75,20 +76,20 @@ class TestEosSystemModule(TestEosModule):
'ip domain lookup source-interface Ethernet1']
self.execute_module(changed=True, commands=commands)
#def test_eos_system_name_servers(self):
# name_servers = ['8.8.8.8', '8.8.4.4']
# set_module_args(dict(name_servers=name_servers))
# commands = ['ip name-server 8.8.4.4',
# 'no ip name-server vrf mgmt 8.8.4.4']
# self.execute_module(changed=True, commands=commands)
# def test_eos_system_name_servers(self):
# name_servers = ['8.8.8.8', '8.8.4.4']
# set_module_args(dict(name_servers=name_servers))
# commands = ['ip name-server 8.8.4.4',
# 'no ip name-server vrf mgmt 8.8.4.4']
# self.execute_module(changed=True, commands=commands)
#def rest_eos_system_name_servers_complex(self):
# name_servers = dict(server='8.8.8.8', vrf='test')
# set_module_args(dict(name_servers=name_servers))
# commands = ['ip name-server vrf test 8.8.8.8',
# 'no ip name-server vrf default 8.8.8.8',
# 'no ip name-server vrf mgmt 8.8.4.4']
# self.execute_module(changed=True, commands=commands)
# def rest_eos_system_name_servers_complex(self):
# name_servers = dict(server='8.8.8.8', vrf='test')
# set_module_args(dict(name_servers=name_servers))
# commands = ['ip name-server vrf test 8.8.8.8',
# 'no ip name-server vrf default 8.8.8.8',
# 'no ip name-server vrf mgmt 8.8.4.4']
# self.execute_module(changed=True, commands=commands)
def test_eos_system_state_absent(self):
set_module_args(dict(state='absent'))
@@ -104,4 +105,3 @@ class TestEosSystemModule(TestEosModule):
name_servers = dict(server='8.8.8.8', vrf='missing')
set_module_args(dict(name_servers=name_servers))
result = self.execute_module(failed=True)

View File

@@ -95,5 +95,3 @@ class TestEosUserModule(TestEosModule):
set_module_args(dict(username='ansible', password='test', update_password='always'))
commands = ['username ansible secret test']
self.execute_module(changed=True, commands=commands)