summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2012-01-30 15:33:24 +0100
committerMichael Vogt <michael.vogt@ubuntu.com>2012-01-30 15:33:24 +0100
commit00ce4d227aef4ccde15f8cfa5b1a5582195eb639 (patch)
tree3ea926d12f70d67fe36802789c42a42bc3f062f0
parent2021c1b4973c3201b1e4580d00b7351c23a831c4 (diff)
downloadpython-apt-00ce4d227aef4ccde15f8cfa5b1a5582195eb639.tar.gz
GREEN: policy should suppors PkgVerFile now
-rw-r--r--po/python-apt.pot2
-rw-r--r--python/policy.cc3
-rw-r--r--tests/test_policy.py13
3 files changed, 11 insertions, 7 deletions
diff --git a/po/python-apt.pot b/po/python-apt.pot
index a7cf0a8d..b99c36e1 100644
--- a/po/python-apt.pot
+++ b/po/python-apt.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2012-01-30 15:16+0100\n"
+"POT-Creation-Date: 2012-01-30 15:32+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
diff --git a/python/policy.cc b/python/policy.cc
index b11e4dde..b7e648b5 100644
--- a/python/policy.cc
+++ b/python/policy.cc
@@ -46,6 +46,9 @@ PyObject *policy_get_priority(PyObject *self, PyObject *arg) {
if (PyObject_TypeCheck(arg, &PyPackage_Type)) {
pkgCache::PkgIterator pkg = GetCpp<pkgCache::PkgIterator>(arg);
return MkPyNumber(policy->GetPriority(pkg));
+ } else if (PyObject_TypeCheck(arg, &PyPackageFile_Type)) {
+ pkgCache::PkgFileIterator pkgfile = GetCpp<pkgCache::PkgFileIterator>(arg);
+ return MkPyNumber(policy->GetPriority(pkgfile));
} else {
PyErr_SetString(PyExc_TypeError,"Argument must be of Package().");
return 0;
diff --git a/tests/test_policy.py b/tests/test_policy.py
index 2d261f5f..2aab6722 100644
--- a/tests/test_policy.py
+++ b/tests/test_policy.py
@@ -19,12 +19,13 @@ class TestAptPolicy(unittest.TestCase):
# basic tests
pkg = cache["apt"]
self.assertEqual(policy.get_priority(pkg._pkg), 0)
- # get verfile
- ver = pkg.candidate._cand
- verfile_list = ver.file_list
- for verfile in verfile_list:
- print verfile
- self.assertEqual(policy.get_priority(verfile), 500)
+ # get priority for all pkgfiles
+ for ver in pkg.versions:
+ lowlevel_ver = ver._cand
+ for pkgfile, i in lowlevel_ver.file_list:
+ #print verfile, i, policy.get_priority(pkgfile)
+ self.assertTrue(policy.get_priority(pkgfile) > 1)
+ self.assertTrue(policy.get_priority(pkgfile) < 1001)
if __name__ == "__main__":