1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Fix junos unit test failures (#26676)

*  Use lxml api's in unit test to parse xml
*  Remove unwanted import in unit test
*  Add ncclient dependency in unit test requirement
This commit is contained in:
Ganesh Nalawade 2017-07-12 21:06:16 +05:30 committed by Matt Clay
parent db5ec11758
commit e14e37ee1e
8 changed files with 20 additions and 19 deletions

View file

@ -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 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 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 pycrypto >= 2.6 # Need features found in 2.6 and greater
ncclient >= 0.5.2 # Need features added in 0.5.2 and greater

View file

@ -22,3 +22,6 @@ ipaddress
f5-sdk ; python_version >= '2.7' f5-sdk ; python_version >= '2.7'
f5-icontrol-rest ; python_version >= '2.7' f5-icontrol-rest ; python_version >= '2.7'
deepdiff deepdiff
# requirement for modules using Netconf protocol
ncclient

View file

@ -22,7 +22,10 @@ __metaclass__ = type
import os import os
import json 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 import unittest
from ansible.compat.tests.mock import patch from ansible.compat.tests.mock import patch
@ -52,7 +55,7 @@ def load_fixture(name, content='xml'):
pass pass
else: else:
try: try:
data = ET.parse(path).getroot() data = parse(path).getroot()
except: except:
pass pass

View file

@ -19,9 +19,7 @@
from __future__ import (absolute_import, division, print_function) from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
import json from ansible.compat.tests.mock import patch
from ansible.compat.tests.mock import patch, MagicMock
from ansible.modules.network.junos import junos_command from ansible.modules.network.junos import junos_command
from .junos_module import TestJunosModule, load_fixture, set_module_args from .junos_module import TestJunosModule, load_fixture, set_module_args

View file

@ -19,9 +19,7 @@
from __future__ import (absolute_import, division, print_function) from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
import json from ansible.compat.tests.mock import patch
from ansible.compat.tests.mock import patch, MagicMock
from ansible.modules.network.junos import junos_facts from ansible.modules.network.junos import junos_facts
from .junos_module import TestJunosModule, load_fixture, set_module_args from .junos_module import TestJunosModule, load_fixture, set_module_args

View file

@ -19,11 +19,9 @@
from __future__ import (absolute_import, division, print_function) from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
import json from ansible.compat.tests.mock import patch
from ansible.compat.tests.mock import patch, MagicMock
from ansible.modules.network.junos import junos_netconf 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): class TestJunosCommandModule(TestJunosModule):

View file

@ -19,10 +19,8 @@
from __future__ import (absolute_import, division, print_function) from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
import json
from ansible.compat.tests.mock import patch, MagicMock 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() jnpr_mock = MagicMock()
modules = { modules = {

View file

@ -19,13 +19,15 @@
from __future__ import (absolute_import, division, print_function) from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
import json try:
from xml.etree.ElementTree import tostring 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 ansible.modules.network.junos import junos_rpc
from .junos_module import TestJunosModule, load_fixture, set_module_args from .junos_module import TestJunosModule, load_fixture, set_module_args
from ansible.module_utils._text import to_text
RPC_CLI_MAP = { RPC_CLI_MAP = {
'get-software-information': 'show version', 'get-software-information': 'show version',