summary refs log tree commit diff stats
path: root/tests/functional/qemu_test/asset.py
diff options
context:
space:
mode:
authorDaniel P. Berrangé <berrange@redhat.com>2024-12-17 15:59:51 +0000
committerThomas Huth <thuth@redhat.com>2024-12-17 19:39:53 +0100
commit6ff217c2d1c231f727c1be356da4a71cdfdd7ec5 (patch)
treefeee23350925bb345d731a385634d9631d771198 /tests/functional/qemu_test/asset.py
parentc5be9dd32f35d049983cc42c3835cc3d8167f13f (diff)
downloadfocaccia-qemu-6ff217c2d1c231f727c1be356da4a71cdfdd7ec5.tar.gz
focaccia-qemu-6ff217c2d1c231f727c1be356da4a71cdfdd7ec5.zip
tests/functional: skip tests if assets are not available
If downloading of assets has been disabled, then skip running a
test if the assets it has registered are not already downloaded.

Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20241217155953.3950506-31-berrange@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Diffstat (limited to 'tests/functional/qemu_test/asset.py')
-rw-r--r--tests/functional/qemu_test/asset.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/tests/functional/qemu_test/asset.py b/tests/functional/qemu_test/asset.py
index c5d3e73c4b..39832b2587 100644
--- a/tests/functional/qemu_test/asset.py
+++ b/tests/functional/qemu_test/asset.py
@@ -65,6 +65,12 @@ class Asset:
     def valid(self):
         return self.cache_file.exists() and self._check(self.cache_file)
 
+    def fetchable(self):
+        return not os.environ.get("QEMU_TEST_NO_DOWNLOAD", False)
+
+    def available(self):
+        return self.valid() or self.fetchable()
+
     def _wait_for_other_download(self, tmp_cache_file):
         # Another thread already seems to download the asset, so wait until
         # it is done, while also checking the size to see whether it is stuck
@@ -103,7 +109,7 @@ class Asset:
                            self.cache_file, self.url)
             return str(self.cache_file)
 
-        if os.environ.get("QEMU_TEST_NO_DOWNLOAD", False):
+        if not self.fetchable():
             raise Exception("Asset cache is invalid and downloads disabled")
 
         self.log.info("Downloading %s to %s...", self.url, self.cache_file)