]> git.ipfire.org Git - pbs.git/commitdiff
tests: packages: Test accessing filelists
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 18 Oct 2022 13:10:34 +0000 (13:10 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 18 Oct 2022 13:10:34 +0000 (13:10 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
tests/package.py

index bb701397319885161dfc9bdfca93e6713edff9d3..fcd46102388a012d4bbed93c1e2af30ade9c7e89 100755 (executable)
@@ -87,6 +87,32 @@ no notion of what's interesting, but it's real good at that notifying part.""")
                # XXX currently, packages are not deleted
                #self.assertFalse(os.path.exists(package.path))
 
+       async def test_files(self):
+               """
+                       Tests whether the filelist could be loaded correctly
+               """
+               path = self.source_path("tests/data/beep-1.3-2.ip3.x86_64.pfm")
+
+               # Create the package
+               with self.db.transaction():
+                       package = await self._create_package(path)
+
+               # Check if the filelist is of the correct type
+               self.assertIsInstance(package.files, list)
+               for file in package.files:
+                       self.assertIsInstance(file, packages.File)
+
+               # Check if we have the correct paths
+               self.assertIn("/usr/bin/beep", [file.path for file in package.files])
+
+               # Fetch a specific file
+               file = package.get_file("/usr/bin/beep")
+               self.assertIsInstance(file, packages.File)
+
+               # Try to read a file
+               payload = await file.get_payload()
+               self.assertIsInstance(payload, bytes)
+
 
 if __name__ == "__main__":
        unittest.main()