twilio.__version__ is a string and twilio.__version_info__ is a tuple of
strings containing integers [e.g. ('6', '8', '2')]. The
test_twilio_notify unittest fails:
```
ERROR: unit.modules.test_twilio_notify (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: unit.modules.test_twilio_notify
Traceback (most recent call last):
File "/usr/lib/python3.7/unittest/loader.py", line 434, in _find_test_path
module = self._get_module_from_name(name)
File "/usr/lib/python3.7/unittest/loader.py", line 375, in _get_module_from_name
__import__(name)
File "tests/unit/modules/test_twilio_notify.py", line 20, in <module>
import salt.modules.twilio_notify as twilio_notify
File "salt/modules/twilio_notify.py", line 28, in <module>
if twilio.__version__ > 5:
TypeError: '>' not supported between instances of 'str' and 'int'
```
Fix the twilio version check to use __version_info__ and converting its
elements to int.
If the `pyvmomi` library is missing, all tests from the
tests.unit.modules.RemoveCapacityFromDiskgroupTestCase will fail:
```
ERROR: test__get_proxy_target_call
(unit.modules.test_vsphere.RemoveCapacityFromDiskgroupTestCase)
[CPU:0.0%|MEM:35.1%]
----------------------------------------------------------------------
Traceback (most recent call last):
File "salt/utils/vmware.py", line 485, in disconnect
Disconnect(service_instance)
NameError: name 'Disconnect' is not defined
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "salt/modules/vsphere.py", line 381, in _gets_service_instance_via_proxy
salt.utils.vmware.disconnect(local_service_instance)
File "salt/utils/vmware.py", line 486, in disconnect
except vim.fault.NoPermission as exc:
NameError: name 'vim' is not defined
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "salt/utils/vmware.py", line 485, in disconnect
Disconnect(service_instance)
NameError: name 'Disconnect' is not defined
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "tests/unit/modules/test_vsphere.py", line 1568, in test__get_proxy_target_call
capacity_disk_ids=['fake_disk1', 'fake_disk2'])
File "salt/modules/vsphere.py", line 295, in __supports_proxies
return fn(*args, **salt.utils.args.clean_kwargs(**kwargs))
File "salt/modules/vsphere.py", line 386, in _gets_service_instance_via_proxy
salt.utils.vmware.disconnect(local_service_instance)
File "/home/bdrung/projects/salt/debian/salt/utils/vmware.py", line 486, in disconnect
except vim.fault.NoPermission as exc:
NameError: name 'vim' is not defined
```
Signed-off-by: Benjamin Drung <benjamin.drung@cloud.ionos.com>
pepa.key_value_to_tree only checks the name of the key when attempting
to identify the last key in a flattened key. This can lead to strange
behavior when the final key name also occurs earlier in the flatkey.
This change explicitly checks that we are the final key in flatkey
prior to setting value. Test included.
Also see mickep76/pepa#11 and mickep76/pepa#12