mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-05-02 23:31:25 -07: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:
parent
db5ec11758
commit
e14e37ee1e
8 changed files with 20 additions and 19 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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 = {
|
||||
|
|
|
@ -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',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue