[osinfo-db PATCH 4/4] tests: Add image tests

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Image tests, at least for now, consist only in the equivalent of
test-imageuris.c from libosinfo and behaves in the same way, being
executed only if OSINFO_DB_NETWORK_TESTS is set.

Signed-off-by: Fabiano Fidêncio <fidencio@xxxxxxxxxx>
---
 tests/unit/osinfo.py     | 18 ++++++++++++++++++
 tests/unit/test_image.py | 20 ++++++++++++++++++++
 2 files changed, 38 insertions(+)
 create mode 100644 tests/unit/test_image.py

diff --git a/tests/unit/osinfo.py b/tests/unit/osinfo.py
index 1d90c16..b2d14c9 100644
--- a/tests/unit/osinfo.py
+++ b/tests/unit/osinfo.py
@@ -9,6 +9,13 @@ class Os():
     def __init__(self, root):
         self._root = root
 
+    def _get_images(self):
+        images = []
+        for image in self._root.findall('image'):
+            images.append(Image(image))
+        return images
+    images = property(_get_images)
+
     def _get_medias(self):
         medias = []
         for media in self._root.findall('media'):
@@ -29,6 +36,17 @@ class Os():
     shortid = property(_get_shortid)
 
 
+class Image():
+    def __init__(self, root):
+        self._root = root
+
+    def _get_url(self):
+        url = self._root.find('url')
+        if url is not None:
+            return URL(url.text)
+    url = property(_get_url)
+
+
 class Media():
     def __init__(self, root):
         self._root = root
diff --git a/tests/unit/test_image.py b/tests/unit/test_image.py
new file mode 100644
index 0000000..7524c86
--- /dev/null
+++ b/tests/unit/test_image.py
@@ -0,0 +1,20 @@
+#!/usr/bin/env python3
+
+import os
+import pytest
+from . import util
+
+
+class TestImage():
+    oses = util.oses()
+
+    def os_id(os):
+        return os.shortid
+
+    @pytest.mark.parametrize('os', [*oses], ids=os_id)
+    @pytest.mark.skipif(os.environ.get('OSINFO_DB_NETWORK_TESTS') is None,
+                        reason='Network related tests are not enabled')
+    def test_image_url(self, os):
+        for image in os.images:
+            if image.url:
+                assert(image.url.check())
-- 
2.20.1

_______________________________________________
Libosinfo mailing list
Libosinfo@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libosinfo




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Fedora Users]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux