napalm-automation-community / napalm-asa

napalm-asa
Apache License 2.0
17 stars 13 forks source link

With napalm 2.5.0 the tests are failing #30

Closed scarabeusiv closed 3 years ago

scarabeusiv commented 4 years ago
[   10s] =================================== FAILURES ===================================
[   10s] ______________________ TestGetter.test_method_signatures _______________________
[   10s]
[   10s] self = <test_getters.TestGetter object at 0x7f5631babeb0>
[   10s]
[   10s]     def test_method_signatures(self):
[   10s]         """Test that all methods have the same signature."""
[   10s]         errors = {}
[   10s]         cls = self.driver
[   10s]         # Create fictional driver instance (py3 needs bound methods)
[   10s]         tmp_obj = cls(hostname="test", username="admin", password="pwd")
[   10s]         attrs = [m for m, v in inspect.getmembers(tmp_obj)]
[   10s]         for attr in attrs:
[   10s]             func = getattr(tmp_obj, attr)
[   10s]             if attr.startswith("_") or not inspect.ismethod(func):
[   10s]                 continue
[   10s]             try:
[   10s]                 orig = getattr(NetworkDriver, attr)
[   10s]                 orig_spec = argspec(orig)
[   10s]             except AttributeError:
[   10s]                 orig_spec = "Method does not exist in napalm.base"
[   10s]             func_spec = argspec(func)
[   10s]             if orig_spec != func_spec:
[   10s]                 errors[attr] = (orig_spec, func_spec)
[   10s]
[   10s]         EXTRA_METHODS = ["__init__"]
[   10s]         for method in EXTRA_METHODS:
[   10s]             orig_spec = argspec(getattr(NetworkDriver, method))
[   10s]             func_spec = argspec(getattr(cls, method))
[   10s]             if orig_spec != func_spec:
[   10s]                 errors[attr] = (orig_spec, func_spec)
[   10s]
[   10s] >       assert not errors, "Some methods vary. \n{}".format(errors.keys())
[   10s] E       AssertionError: Some methods vary.
[   10s] E       dict_keys(['get_config'])
[   10s]
[   10s] /usr/lib/python3.8/site-packages/napalm/base/test/getters.py:151: AssertionError
[   10s] ____________________ TestGetter.test_get_interfaces[normal] ____________________
[   10s]
[   10s] self = <test_getters.TestGetter object at 0x7f5631b43250>, test_case = 'normal'
[   10s]
[   10s]     @wrap_test_cases
[   10s]     def test_get_interfaces(self, test_case):
[   10s]         """Test get_interfaces."""
[   10s]         get_interfaces = self.device.get_interfaces()
[   10s]         assert len(get_interfaces) > 0
[   10s]
[   10s] >           assert helpers.test_model(models.interface, interface_data)
[   10s]
[   10s] /usr/lib/python3.8/site-packages/napalm/base/test/getters.py:174:
[   10s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[   10s]
[   10s] model = {'description': <class 'str'>, 'is_enabled': <class 'bool'>, 'is_up': <class 'bool'>, 'last_flapped': <class 'float'>, ...}
[   10s] data = {'description': '', 'is_enabled': True, 'is_up': True, 'last_flapped': -1.0, ...}
[   10s]
[   10s]     def test_model(model, data):
[   10s]         """Return if the dictionary `data` complies with the `model`."""
[   10s]         same_keys = set(model.keys()) == set(data.keys())
[   10s]
[   10s]         if not same_keys:
[   10s]             print(
[   10s]                 "model_keys: {}\ndata_keys: {}".format(
[   10s]                     sorted(model.keys()), sorted(data.keys())
[   10s]                 )
[   10s]             )
[   10s]
[   10s]         correct_class = True
[   10s]         for key, instance_class in model.items():
[   10s]             if py23_compat.PY2 and isinstance(data[key], long):  # noqa
[   10s]                 # Properly handle PY2 long
[   10s]                 correct_class = (
[   10s]                     isinstance(data[key], long)  # noqa
[   10s]                     and isinstance(1, instance_class)
[   10s]                     and correct_class
[   10s]                 )
[   10s]             else:
[   10s] >               correct_class = isinstance(data[key], instance_class) and correct_class
[   10s] E               KeyError: 'mtu'
[   10s]
[   10s] /usr/lib/python3.8/site-packages/napalm/base/test/helpers.py:31: KeyError
[   10s] ----------------------------- Captured stdout call -----------------------------
[   10s] model_keys: ['description', 'is_enabled', 'is_up', 'last_flapped', 'mac_address', 'mtu', 'speed']
[   10s] data_keys: ['description', 'is_enabled', 'is_up', 'last_flapped', 'mac_address', 'speed']
[   10s] =============================== warnings summary ===============================
[   10s] napalm_asa/asa.py:66
[   10s]   /home/abuild/rpmbuild/BUILD/napalm-asa-0.1.1/napalm_asa/asa.py:66: SyntaxWarning: "is" with a literal. Did you mean "=="?
[   10s]     if token_request.status_code is 204 and 'X-Auth-Token' in token_request.headers.keys():
[   10s]
[   10s] napalm_asa/asa.py:82
[   10s]   /home/abuild/rpmbuild/BUILD/napalm-asa-0.1.1/napalm_asa/asa.py:82: SyntaxWarning: "is" with a literal. Did you mean "=="?
[   10s]     if token_delete_request.status_code is 204:
MeggyCal commented 4 years ago

To make the package compatible even with napalm 3.0.0 there are two more things that have to be done.

First, napalm has dropped Python2 and with it the class py23_compat. In napalm-procurve there is only py23_compat.text_type used, it is the same as str in Python3 (see [1]). Therefore "sed -i 's/py23_compat.text_type/str/g'" on all affected files should resolve this.

Second, napalm has added a (not mandatory) parameter 'sanitized' to get_config (see [2]) and they are running a test on it. But there are no data for the test in napalm-procurve, so it fails. Sorry, I have no clue how should the data look like.

Could you please take a look? Thanks!

[1] napalm-automation/napalm@9d27a00 [2] napalm-automation/napalm@5003cfc