This test ensures no duplicated device entry exists between an OS and the OS it derives-from/clones. This test is the equivalent of "test_devices_duplication", which is currently part of test-os in libosinfo. Signed-off-by: Fabiano Fidêncio <fidencio@xxxxxxxxxx> --- tests/osinfo.py | 9 +++++++++ tests/test_devices.py | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 tests/test_devices.py diff --git a/tests/osinfo.py b/tests/osinfo.py index a203369..0c58f0a 100644 --- a/tests/osinfo.py +++ b/tests/osinfo.py @@ -45,6 +45,15 @@ class Os(): return None clones = _cache_property(_get_clones) + def _get_devices(self): + devices = [] + devicelist = self._root.find('devices') + if devicelist is not None: + for device in devicelist.findall('device'): + devices.append(device.get('id')) + return devices + devices = _cache_property(_get_devices) + def _get_images(self): images = [] for image in self._root.findall('image'): diff --git a/tests/test_devices.py b/tests/test_devices.py new file mode 100644 index 0000000..c14ae48 --- /dev/null +++ b/tests/test_devices.py @@ -0,0 +1,18 @@ +# This work is licensed under the GNU GPLv2 or later. +# See the COPYING file in the top-level directory. + +import pytest + +from . import util + + +@pytest.mark.parametrize('_os', util.DataFiles.oses(), ids=lambda o: o.shortid) +def test_devices_duplication(_os): + broken = [] + related = util.DataFiles.get_os_related(_os) + for __os in related: + if __os.devices is not None: + for device in __os.devices: + if device in _os.devices: + broken.append(device) + assert broken == [] -- 2.20.1 _______________________________________________ Libosinfo mailing list Libosinfo@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libosinfo