From 69a3c876af74e2499b5068441b5d89ca53c3583a Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 4 May 2005 08:36:36 +0000 Subject: * 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) --- tests/cache.py | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ tests/pkgrecords.py | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 tests/cache.py create mode 100644 tests/pkgrecords.py (limited to 'tests') 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) -- cgit v1.2.3