diff --git a/test/runner/requirements/constraints.txt b/test/runner/requirements/constraints.txt index 0c750b98481..efc14195372 100644 --- a/test/runner/requirements/constraints.txt +++ b/test/runner/requirements/constraints.txt @@ -5,3 +5,4 @@ sphinx < 1.6 ; python_version < '2.7' # sphinx 1.6 and later require python 2.7 yamllint != 1.8.0 ; python_version < '2.7' # yamllint 1.8.0 requires python 2.7+ while earlier/later versions do not isort < 4.2.8 # 4.2.8 changes import sort order requirements which breaks previously passing pylint tests pycrypto >= 2.6 # Need features found in 2.6 and greater +ncclient >= 0.5.2 # Need features added in 0.5.2 and greater diff --git a/test/runner/requirements/units.txt b/test/runner/requirements/units.txt index a064c2d271e..cd330dec9f4 100644 --- a/test/runner/requirements/units.txt +++ b/test/runner/requirements/units.txt @@ -22,3 +22,6 @@ ipaddress f5-sdk ; python_version >= '2.7' f5-icontrol-rest ; python_version >= '2.7' deepdiff + +# requirement for modules using Netconf protocol +ncclient diff --git a/test/units/modules/network/junos/junos_module.py b/test/units/modules/network/junos/junos_module.py index 65c72ccb359..30fb4c7fe0a 100644 --- a/test/units/modules/network/junos/junos_module.py +++ b/test/units/modules/network/junos/junos_module.py @@ -22,7 +22,10 @@ __metaclass__ = type import os import json -import xml.etree.ElementTree as ET +try: + from lxml.etree import parse +except ImportError: + from xml.etree.ElementTree import parse from ansible.compat.tests import unittest from ansible.compat.tests.mock import patch @@ -52,7 +55,7 @@ def load_fixture(name, content='xml'): pass else: try: - data = ET.parse(path).getroot() + data = parse(path).getroot() except: pass diff --git a/test/units/modules/network/junos/test_junos_command.py b/test/units/modules/network/junos/test_junos_command.py index 51e07b34098..a647d669b06 100644 --- a/test/units/modules/network/junos/test_junos_command.py +++ b/test/units/modules/network/junos/test_junos_command.py @@ -19,9 +19,7 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type -import json - -from ansible.compat.tests.mock import patch, MagicMock +from ansible.compat.tests.mock import patch from ansible.modules.network.junos import junos_command from .junos_module import TestJunosModule, load_fixture, set_module_args diff --git a/test/units/modules/network/junos/test_junos_facts.py b/test/units/modules/network/junos/test_junos_facts.py index e0cac9bc977..4a424bbb02f 100644 --- a/test/units/modules/network/junos/test_junos_facts.py +++ b/test/units/modules/network/junos/test_junos_facts.py @@ -19,9 +19,7 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type -import json - -from ansible.compat.tests.mock import patch, MagicMock +from ansible.compat.tests.mock import patch from ansible.modules.network.junos import junos_facts from .junos_module import TestJunosModule, load_fixture, set_module_args diff --git a/test/units/modules/network/junos/test_junos_netconf.py b/test/units/modules/network/junos/test_junos_netconf.py index 4e627490ff5..1bf7947f007 100644 --- a/test/units/modules/network/junos/test_junos_netconf.py +++ b/test/units/modules/network/junos/test_junos_netconf.py @@ -19,11 +19,9 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type -import json - -from ansible.compat.tests.mock import patch, MagicMock +from ansible.compat.tests.mock import patch from ansible.modules.network.junos import junos_netconf -from .junos_module import TestJunosModule, load_fixture, set_module_args +from .junos_module import TestJunosModule, set_module_args class TestJunosCommandModule(TestJunosModule): diff --git a/test/units/modules/network/junos/test_junos_package.py b/test/units/modules/network/junos/test_junos_package.py index c513fdb1f64..8bfc0ab197e 100644 --- a/test/units/modules/network/junos/test_junos_package.py +++ b/test/units/modules/network/junos/test_junos_package.py @@ -19,10 +19,8 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type -import json - from ansible.compat.tests.mock import patch, MagicMock -from .junos_module import TestJunosModule, load_fixture, set_module_args +from .junos_module import TestJunosModule, set_module_args jnpr_mock = MagicMock() modules = { diff --git a/test/units/modules/network/junos/test_junos_rpc.py b/test/units/modules/network/junos/test_junos_rpc.py index 6650bab2244..5cd431e5e29 100644 --- a/test/units/modules/network/junos/test_junos_rpc.py +++ b/test/units/modules/network/junos/test_junos_rpc.py @@ -19,13 +19,15 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type -import json -from xml.etree.ElementTree import tostring +try: + from lxml.etree import tostring +except ImportError: + from xml.etree.ElementTree import tostring -from ansible.compat.tests.mock import patch, MagicMock +from ansible.compat.tests.mock import patch from ansible.modules.network.junos import junos_rpc from .junos_module import TestJunosModule, load_fixture, set_module_args -from ansible.module_utils._text import to_text + RPC_CLI_MAP = { 'get-software-information': 'show version',