summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2005-05-04 08:36:36 +0000
committerMichael Vogt <michael.vogt@ubuntu.com>2005-05-04 08:36:36 +0000
commit69a3c876af74e2499b5068441b5d89ca53c3583a (patch)
treefad0d73c9c71a606a37fc5c9552aa56df48ab6f2 /tests
parent52ecc81517a1fa9748d04f0c0d05ce8396233b71 (diff)
downloadpython-apt-69a3c876af74e2499b5068441b5d89ca53c3583a.tar.gz
* more tests added
* tests/cache.py: - test that iterates over all the cache and dependencies * tests/pkgrecords.py - test that iterates over all the pkgrecords * python/cache.cc - added a comment * python/pkgrecords.cc - return "True" from pkgRecord.Lookup() (to make it consistent with the PkgSrcRecords object)
Diffstat (limited to 'tests')
-rw-r--r--tests/cache.py50
-rw-r--r--tests/pkgrecords.py34
2 files changed, 84 insertions, 0 deletions
diff --git a/tests/cache.py b/tests/cache.py
new file mode 100644
index 00000000..e0cbb95c
--- /dev/null
+++ b/tests/cache.py
@@ -0,0 +1,50 @@
+#!/usr/bin/env python2.4
+#
+# Test for the PkgSrcRecords code
+# it segfaults for python-apt < 0.5.37
+#
+
+import apt_pkg
+import sys
+
+def main():
+ apt_pkg.init()
+ cache = apt_pkg.GetCache()
+ depcache = apt_pkg.GetDepCache(cache)
+ depcache.Init()
+ i=0
+ all=cache.PackageCount
+ print "Running Cache test on all packages:"
+ # first, get all pkgs
+ for pkg in cache.Packages:
+ i += 1
+ x = pkg.Name
+ # then get each version
+ for ver in pkg.VersionList:
+ # get some version information
+ a = ver.FileList
+ b = ver.VerStr
+ c = ver.Arch
+ d = ver.DependsListStr
+ dl = ver.DependsList
+ # get all dependencies (a dict of string->list,
+ # e.g. "depends:" -> [ver1,ver2,..]
+ for dep in dl.keys():
+ # get the list of each dependency object
+ for depVerList in dl[dep]:
+ for z in depVerList:
+ # get all TargetVersions of
+ # the dependency object
+ for j in z.AllTargets():
+ f = j.FileList
+ g = ver.VerStr
+ h = ver.Arch
+ k = ver.DependsListStr
+ j = ver.DependsList
+ pass
+
+ print "\r%i/%i=%.3f%% " % (i,all,(float(i)/float(all)*100)),
+
+if __name__ == "__main__":
+ main()
+ sys.exit(0)
diff --git a/tests/pkgrecords.py b/tests/pkgrecords.py
new file mode 100644
index 00000000..8bfe4b82
--- /dev/null
+++ b/tests/pkgrecords.py
@@ -0,0 +1,34 @@
+#!/usr/bin/env python2.4
+#
+# Test for the PkgSrcRecords code
+# it segfaults for python-apt < 0.5.37
+#
+
+import apt_pkg
+import sys
+
+def main():
+ apt_pkg.init()
+ cache = apt_pkg.GetCache()
+ depcache = apt_pkg.GetDepCache(cache)
+ depcache.Init()
+ i=0
+ print "Running PkgRecords test on all packages:"
+ for pkg in cache.Packages:
+ i += 1
+ records = apt_pkg.GetPkgRecords(cache)
+ if len(pkg.VersionList) == 0:
+ #print "no available version, cruft"
+ continue
+ version = depcache.GetCandidateVer(pkg)
+ file, index = version.FileList.pop(0)
+ if records.Lookup((file,index)):
+ #print records.FileName
+ x = records.FileName
+ y = records.LongDesc
+ pass
+ print "\r%i/%i=%.3f%% " % (i,cache.PackageCount, (float(i)/float(cache.PackageCount)*100)),
+
+if __name__ == "__main__":
+ main()
+ sys.exit(0)