From 5dc9b2ee4dde7b6deb477b581759c5f76dcb87b5 Mon Sep 17 00:00:00 2001
From: Jiri Konecny <jkonecny@redhat.com>
Date: Fri, 19 Jun 2020 15:57:57 +0200
Subject: [PATCH] Add tests for verify_valid_installtree function (#1844287)

It's testing if repodata/repomd.xml file exists.

Related: rhbz#1844287
Related: rhbz#1849093
---
 .../module_source_base_test.py                | 23 ++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/tests/nosetests/pyanaconda_tests/module_source_base_test.py b/tests/nosetests/pyanaconda_tests/module_source_base_test.py
index f58e2b1639..3ba40edf4c 100644
--- a/tests/nosetests/pyanaconda_tests/module_source_base_test.py
+++ b/tests/nosetests/pyanaconda_tests/module_source_base_test.py
@@ -16,6 +16,8 @@
 # Red Hat, Inc.
 #
 import unittest
+from pathlib import Path
+from tempfile import TemporaryDirectory
 from unittest.mock import patch
 
 from pyanaconda.core.constants import INSTALL_TREE
@@ -23,7 +25,8 @@
 from pyanaconda.modules.payloads.constants import SourceType
 from pyanaconda.modules.payloads.source.mount_tasks import SetUpMountTask, TearDownMountTask
 from pyanaconda.modules.payloads.source.source_base import MountingSourceMixin
-from pyanaconda.modules.payloads.source.utils import find_and_mount_iso_image
+from pyanaconda.modules.payloads.source.utils import find_and_mount_iso_image, \
+    verify_valid_installtree
 
 mount_location = "/some/dir"
 
@@ -184,3 +187,21 @@ def find_and_mount_iso_image_fail_mount_test(self,
         )
 
         self.assertEqual(iso_name, "")
+
+    def verify_valid_installtree_success_test(self):
+        """Test verify_valid_installtree functionality success."""
+        with TemporaryDirectory() as tmp:
+            repodir_path = Path(tmp, "repodata")
+            repodir_path.mkdir()
+            repomd_path = Path(repodir_path, "repomd.xml")
+            repomd_path.write_text("This is a cool repomd file!")
+
+            self.assertTrue(verify_valid_installtree(tmp))
+
+    def verify_valid_installtree_failed_test(self):
+        """Test verify_valid_installtree functionality failed."""
+        with TemporaryDirectory() as tmp:
+            repodir_path = Path(tmp, "repodata")
+            repodir_path.mkdir()
+
+            self.assertFalse(verify_valid_installtree(tmp))
