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

[Libosinfo] [osinfo-db PATCH 3/4] tests: Add tree tests



Tree tests, at least for now, consist only in the equivalent of
test-treeuris.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 redhat com>
---
 tests/unit/osinfo.py    | 18 ++++++++++++++++++
 tests/unit/test_tree.py | 20 ++++++++++++++++++++
 2 files changed, 38 insertions(+)
 create mode 100644 tests/unit/test_tree.py

diff --git a/tests/unit/osinfo.py b/tests/unit/osinfo.py
index e54dc3c..1d90c16 100644
--- a/tests/unit/osinfo.py
+++ b/tests/unit/osinfo.py
@@ -16,6 +16,13 @@ class Os():
         return medias
     medias = property(_get_medias)
 
+    def _get_trees(self):
+        trees = []
+        for tree in self._root.findall('tree'):
+            trees.append(Tree(tree))
+        return trees
+    trees = property(_get_trees)
+
     def _get_shortid(self):
         shortid = self._root.find('short-id')
         return shortid.text
@@ -33,6 +40,17 @@ class Media():
     url = property(_get_url)
 
 
+class Tree():
+    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 URL():
     def __init__(self, url):
         self._url = url
diff --git a/tests/unit/test_tree.py b/tests/unit/test_tree.py
new file mode 100644
index 0000000..3802407
--- /dev/null
+++ b/tests/unit/test_tree.py
@@ -0,0 +1,20 @@
+#!/usr/bin/env python3
+
+import os
+import pytest
+from . import util
+
+
+class TestTree():
+    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_tree_url(self, os):
+        for tree in os.trees:
+            if tree.url:
+                assert(tree.url.check())
-- 
2.20.1


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