From: Michael Tremer Date: Tue, 18 Oct 2022 13:10:34 +0000 (+0000) Subject: tests: packages: Test accessing filelists X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0c922a8bd952a6e3e2bc6284bb69a17ebda6d5d6;p=pbs.git tests: packages: Test accessing filelists Signed-off-by: Michael Tremer --- diff --git a/tests/package.py b/tests/package.py index bb701397..fcd46102 100755 --- a/tests/package.py +++ b/tests/package.py @@ -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()