]> git.ipfire.org Git - pakfire.git/commitdiff
tests: python: Open an archive in stub mode
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 6 Feb 2025 11:39:46 +0000 (11:39 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 6 Feb 2025 11:39:46 +0000 (11:39 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
tests/python/archive.py
tests/python/tests.py

index fff1b2a6905dcfcb2516f99269e563ab95d54163..bde758569f03053ba19cc042a088af2471097b93 100644 (file)
@@ -1226,6 +1226,7 @@ dist_check_SCRIPTS = \
        tests/python/archive.py \
        tests/python/ctx.py \
        tests/python/keys.py \
+       tests/python/main.py \
        tests/python/package.py \
        tests/python/version_compare.py
 
index 64229a0b78044dce2b37bcdf650e47269c1e70c2..7bdaa6c3743add839a9d58fcc46685aed7c4f2c7 100755 (executable)
@@ -150,6 +150,18 @@ class ArchiveTest(tests.TestCase):
 
                # The rest will be tested in packages.py
 
+       def test_open_stub(self):
+               # Launch Pakfire in stub mode
+               p = self.setup_pakfire(stub=True)
+
+               # Make path
+               path = self.path("beep-1.3-2.ip3.x86_64.pfm")
+
+               # Open the archive
+               archive = self.pakfire.open(path)
+
+               # Fetch the filelist
+               self.assertIsInstance(archive.filelist, list)
 
 if __name__ == "__main__":
        tests.main()
index 73b2b32469df171be6c2e2d8a2ca3009a33fbb27..5482cce95771cbed201f731c134b43e23005acd2 100644 (file)
@@ -48,7 +48,7 @@ class TestCase(unittest.TestCase):
                # Return a new context
                return pakfire.Ctx(path=path, **kwargs)
 
-       def setup_pakfire(self, ctx=None, path=None, config=None, **kwargs):
+       def setup_pakfire(self, ctx=None, path=None, config=None, stub=False, **kwargs):
                """
                        Sets up a new Pakfire environment
                """
@@ -62,10 +62,14 @@ class TestCase(unittest.TestCase):
                if path is None:
                        path = os.environ.get("TEST_STUB_ROOT")
 
+               # If we are in stub mode, we need to reset the path
+               if stub:
+                       path = None
+
                with open(config, "r") as f:
                        config = f.read()
 
-               return pakfire.Pakfire(ctx=ctx, path=path, config=config, **kwargs)
+               return pakfire.Pakfire(ctx=ctx, path=path, config=config, stub=stub, **kwargs)
 
        def path(self, *args, **kwargs):
                """