diff --git a/test/unit/mocked_data/test_get_interfaces/empty_interfaces/_show__config__candidate___candidate___config___show_.xml b/test/unit/mocked_data/test_get_interfaces/empty_interfaces/_show__config__candidate___candidate___config___show_.xml
new file mode 100644
index 0000000..71b83df
--- /dev/null
+++ b/test/unit/mocked_data/test_get_interfaces/empty_interfaces/_show__config__candidate___candidate___config___show_.xml
@@ -0,0 +1,304 @@
+
+
+
+
+ fnRL/G5lXVMug
+
+
+ yes
+
+
+
+
+
+
+ yes
+
+
+ $1$vbxmfoed$3DpWw/eU1C7S5PUOqZnJ2.
+
+
+
+
+
+
+
+
+
+
+
+
+ yes
+ 5
+
+
+ yes
+ 5
+
+
+ yes
+ 5
+
+
+ yes
+ 10
+
+
+ yes
+ 5
+
+
+
+ yes
+
+
+
+ 10
+ 10
+
+ 100
+ 50
+
+
+
+ 10
+ 10
+
+ 100
+ 50
+
+
+
+
+
+ 100
+ yes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 3
+ 5
+ wait-recover
+
+
+
+
+
+
+
+
+ aes-128-cbc
+ 3des
+
+
+ sha1
+
+
+ group2
+
+
+ 8
+
+
+
+
+ aes-128-cbc
+
+
+ sha256
+
+
+ group19
+
+
+ 8
+
+
+
+
+ aes-256-cbc
+
+
+ sha384
+
+
+ group20
+
+
+ 8
+
+
+
+
+
+
+
+ aes-128-cbc
+ 3des
+
+
+ sha1
+
+
+ group2
+
+ 1
+
+
+
+
+
+ aes-128-gcm
+
+
+ none
+
+
+ group19
+
+ 1
+
+
+
+
+
+ aes-256-gcm
+
+
+ none
+
+
+ group20
+
+ 1
+
+
+
+
+
+
+ aes-128-cbc
+
+
+ sha1
+
+
+
+
+
+
+
+
+
+
+ real-time
+
+
+ high
+
+
+ high
+
+
+ medium
+
+
+ medium
+
+
+ low
+
+
+ low
+
+
+ low
+
+
+
+
+
+
+
+
+
+ no
+
+
+ 1.25
+ 0.5
+ 900
+ 300
+ 900
+ yes
+
+
+
+
+
+
+
+
+
+ 10.0.0.90
+ 255.255.255.0
+ updates.paloaltonetworks.com
+
+
+
+
+ wednesday
+ 01:02
+ download-only
+
+
+
+
+ US/Pacific
+
+ yes
+ yes
+
+ test
+ 10.0.0.2
+
+
+ 8.8.8.8
+
+
+
+
+
+ yes
+
+
+ FQDN
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test/unit/mocked_data/test_get_interfaces/empty_interfaces/running_config.xml b/test/unit/mocked_data/test_get_interfaces/empty_interfaces/running_config.xml
new file mode 100644
index 0000000..57b9491
--- /dev/null
+++ b/test/unit/mocked_data/test_get_interfaces/empty_interfaces/running_config.xml
@@ -0,0 +1,302 @@
+
+
+
+
+ fnRL/G5lXVMug
+
+
+ yes
+
+
+
+
+
+
+ yes
+
+
+ $1$vbxmfoed$3DpWw/eU1C7S5PUOqZnJ2.
+
+
+
+
+
+
+
+
+
+
+
+
+ yes
+ 5
+
+
+ yes
+ 5
+
+
+ yes
+ 5
+
+
+ yes
+ 10
+
+
+ yes
+ 5
+
+
+
+ yes
+
+
+
+ 10
+ 10
+
+ 100
+ 50
+
+
+
+ 10
+ 10
+
+ 100
+ 50
+
+
+
+
+
+ 100
+ yes
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 3
+ 5
+ wait-recover
+
+
+
+
+
+
+
+
+ aes-128-cbc
+ 3des
+
+
+ sha1
+
+
+ group2
+
+
+ 8
+
+
+
+
+ aes-128-cbc
+
+
+ sha256
+
+
+ group19
+
+
+ 8
+
+
+
+
+ aes-256-cbc
+
+
+ sha384
+
+
+ group20
+
+
+ 8
+
+
+
+
+
+
+
+ aes-128-cbc
+ 3des
+
+
+ sha1
+
+
+ group2
+
+ 1
+
+
+
+
+
+ aes-128-gcm
+
+
+ none
+
+
+ group19
+
+ 1
+
+
+
+
+
+ aes-256-gcm
+
+
+ none
+
+
+ group20
+
+ 1
+
+
+
+
+
+
+ aes-128-cbc
+
+
+ sha1
+
+
+
+
+
+
+
+
+
+
+ real-time
+
+
+ high
+
+
+ high
+
+
+ medium
+
+
+ medium
+
+
+ low
+
+
+ low
+
+
+ low
+
+
+
+
+
+
+
+
+
+ no
+
+
+ 1.25
+ 0.5
+ 900
+ 300
+ 900
+ yes
+
+
+
+
+
+
+
+
+
+ 10.0.0.90
+ 255.255.255.0
+ updates.paloaltonetworks.com
+
+
+
+
+ wednesday
+ 01:02
+ download-only
+
+
+
+
+ US/Pacific
+
+ yes
+ yes
+
+ PA-VM
+ 10.0.0.2
+
+
+ 8.8.8.8
+
+
+
+
+
+ yes
+
+
+ FQDN
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test/unit/test_getters.py b/test/unit/test_getters.py
index 3c884b6..2e6858c 100644
--- a/test/unit/test_getters.py
+++ b/test/unit/test_getters.py
@@ -1,108 +1,13 @@
"""Tests for getters."""
-import functools
-import json
-from itertools import zip_longest
-from napalm.base.test import conftest
from napalm.base.test import helpers
from napalm.base.test import models
from napalm.base.test.getters import BaseTestGetters
+from napalm.base.test.getters import wrap_test_cases
import pytest
-def list_dicts_diff(prv, nxt):
- """Compare two lists of dicts."""
- result = []
- for prv_element, nxt_element in zip_longest(prv, nxt, fillvalue={}):
- intermediate_result = dict_diff(prv_element, nxt_element)
- if intermediate_result:
- result.append(intermediate_result)
- return result
-
-
-def dict_diff(prv, nxt):
- """Return a dict of keys that differ with another config object."""
- keys = set(list(prv.keys()) + list(nxt.keys()))
- result = {}
-
- for k in keys:
- if isinstance(prv.get(k), dict):
- if isinstance(nxt.get(k), dict):
- "If both are dicts we do a recursive call."
- diff = dict_diff(prv.get(k), nxt.get(k))
- if diff:
- result[k] = diff
- else:
- "If only one is a dict they are clearly different"
- result[k] = {"result": prv.get(k), "expected": nxt.get(k)}
- else:
- "Ellipsis is a wildcard." ""
- if prv.get(k) != nxt.get(k) and nxt.get(k) != "...":
- result[k] = {"result": prv.get(k), "expected": nxt.get(k)}
- return result
-
-
-def wrap_test_cases(func):
- """Wrap test cases."""
- func.__dict__["build_test_cases"] = True
-
- @functools.wraps(func)
- def mock_wrapper(cls, test_case):
- for patched_attr in cls.device.patched_attrs:
- attr = getattr(cls.device, patched_attr)
- attr.current_test = func.__name__
- attr.current_test_case = test_case
-
- try:
- # This is an ugly, ugly, ugly hack because some python objects don't load
- # as expected. For example, dicts where integers are strings
- result = json.loads(json.dumps(func(cls, test_case)))
- except IOError:
- if test_case == "no_test_case_found":
- pytest.fail("No test case for '{}' found".format(func.__name__))
- else:
- raise
- except NotImplementedError:
- pytest.skip("Method not implemented")
- return
-
- # This is an ugly, ugly, ugly hack because some python objects don't load
- # as expected. For example, dicts where integers are strings
-
- try:
- expected_result = attr.expected_result
- except IOError as e:
- raise Exception("{}. Actual result was: {}".format(e, json.dumps(result)))
- if isinstance(result, list):
- diff = list_dicts_diff(result, expected_result)
- else:
- diff = dict_diff(result, expected_result)
- if diff:
- print("Resulting JSON object was: {}".format(json.dumps(result)))
- raise AssertionError("Expected result varies on some keys {}".format(json.dumps(diff)))
-
- for patched_attr in cls.device.patched_attrs:
- attr = getattr(cls.device, patched_attr)
- attr.current_test = "" # Empty them to avoid side effects
- attr.current_test_case = "" # Empty them to avoid side effects
-
- return result
-
- @functools.wraps(func)
- def real_wrapper(cls, test_case):
- try:
- return func(cls, test_case)
- except NotImplementedError:
- pytest.skip("Method not implemented")
- return
-
- if conftest.NAPALM_TEST_MOCK:
- return mock_wrapper
- else:
- return real_wrapper
-
-
@pytest.mark.usefixtures("set_device_parameters")
class TestGetter(BaseTestGetters):
"""Test get_* methods."""