]> git.ipfire.org Git - people/ms/pakfire.git/blob - tests/python/package.py
packages: Export build architectures in Python
[people/ms/pakfire.git] / tests / python / package.py
1 #!/usr/bin/python3
2
3 import os
4 import pakfire
5 import unittest
6
7 class Test(unittest.TestCase):
8 """
9 This tests the Package class
10 """
11 def setUp(self):
12 path = os.environ.get("TEST_STUB_ROOT")
13 if not path:
14 raise RuntimeError("TEST_STUB_ROOT is not defined")
15
16 self.pakfire = pakfire.Pakfire(path)
17
18 def test_open(self):
19 path = os.path.join(
20 os.environ["TEST_DATA_DIR"],
21 "beep-1.3-2.ip3.x86_64.pfm",
22 )
23
24 # Open the archive
25 a = self.pakfire.open(path)
26
27 # Fetch the package
28 p = a.get_package()
29
30 # Check metadata
31 self.assertEqual(p.name, "beep")
32 self.assertEqual(p.evr, "1.3-2.ipfire3")
33 self.assertEqual(p.arch, "x86_64")
34
35 self.assertEqual(p.summary, "Beep the PC speaker any number of ways.")
36 self.assertEqual(p.description,
37 "Beep allows the user to control the PC speaker with precision, "
38 "allowing different sounds to indicate different events. While "
39 "it can be run quite happily on the commandline, it's intended "
40 "place of residence is within shell/perl scripts, notifying the "
41 "user when something interesting occurs. Of course, it has no "
42 "notion of what's interesting, but it's real good at that "
43 "notifying part.")
44 self.assertEqual(p.url, "http://www.johnath.com/beep/")
45 self.assertEqual(p.license, "GPLv2+")
46 self.assertEqual(p.vendor, "IPFire Project")
47 self.assertEqual(p.distribution, "ipfire3")
48 self.assertEqual(p.groups, "Applications/System")
49
50 self.assertEqual(p.uuid, "a20dddff-d8e8-4544-aaee-8bab618b0b3f")
51 self.assertIsNone(p.packager)
52
53 self.assertEqual(p.filename, "beep-1.3-2.ip3.x86_64.pfm")
54 self.assertEqual(p.downloadsize, 11271)
55 self.assertEqual(p.installsize, 40980)
56
57 self.assertEqual(p.buildhost, "michael.sof.ipfire.org")
58 self.assertEqual(p.buildtime, 1677608628)
59
60 # Dependencies
61 self.assertEqual(p.requires, [
62 "pakfire(Digest-SHA3-512)",
63 "pakfire(Digest-BLAKE2b512)",
64 "/lib64/ld-linux-x86-64.so.2",
65 "libc.so.6()(64bit)",
66 "libc.so.6(GLIBC_2.2.5)(64bit)",
67 "libc.so.6(GLIBC_2.3.4)(64bit)",
68 "libc.so.6(GLIBC_2.34)(64bit)",
69 "libc.so.6(GLIBC_2.4)(64bit)",
70 "libc.so.6(GLIBC_2.7)(64bit)",
71 "pakfire(Compress-Zstandard)",
72 "pakfire(PackageFormat-6)",
73 ])
74 self.assertEqual(p.provides, ["beep = 1.3-2.ipfire3"])
75 self.assertEqual(p.obsoletes, [])
76 self.assertEqual(p.conflicts, [])
77 self.assertEqual(p.suggests, [])
78 self.assertEqual(p.recommends, [])
79
80 # Source
81 self.assertEqual(p.source_package, "beep-1.3-2.ipfire3.src")
82 self.assertEqual(p.source_name, "beep")
83 self.assertEqual(p.source_arch, "src")
84 self.assertEqual(p.source_evr, "1.3-2.ipfire3")
85
86 self.assertEqual(p.build_arches, [])
87
88 # Digest
89 algo, digest = p.digest
90
91 self.assertEqual(algo, "sha2-512")
92 self.assertEqual(digest, b"BP+\xb256\xc3\x12w\xf0l\xc2\xd7\x87j\xe3\xf0\x84\x85v\xc56B|\x8e\x99\x95\xf1 Z\xbf\xe7U\xa0C\xc8\xf1hklg{\x89\xa5\x98\x9e\nG\xdb!\ng\xbe\xa0\xcdt6\x04\x00\xeby\xd18\x91")
93
94
95 if __name__ == "__main__":
96 unittest.main()