diff options
| author | Michael Vogt <michael.vogt@ubuntu.com> | 2012-01-31 14:59:23 +0100 |
|---|---|---|
| committer | Michael Vogt <michael.vogt@ubuntu.com> | 2012-01-31 14:59:23 +0100 |
| commit | 64c1ffa6310efdff6353346fe621aea10e36f2c9 (patch) | |
| tree | 7bf73141f728aa128c9cbe0e682dd1c16f742658 /tests | |
| parent | 44163ca57ac3f6311e05b1521ac03f120e67d520 (diff) | |
| parent | 6f538d96ec35e80e19f1b33cad86b9ae45da54f5 (diff) | |
| download | python-apt-64c1ffa6310efdff6353346fe621aea10e36f2c9.tar.gz | |
merged from lp:~mvo/apt/mvo
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_policy.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/test_policy.py b/tests/test_policy.py new file mode 100644 index 00000000..d77fb27e --- /dev/null +++ b/tests/test_policy.py @@ -0,0 +1,39 @@ +#!/usr/bin/python +# +# Copyright (C) 2012 Michael Vogt <mvo@ubuntu.com> +# +# Copying and distribution of this file, with or without modification, +# are permitted in any medium without royalty provided the copyright +# notice and this notice are preserved. + +import apt +import unittest + +class TestAptPolicy(unittest.TestCase): + + def test_apt_policy_lowlevel(self): + # get a policy + cache = apt.Cache() + policy = cache._depcache.policy + self.assertNotEqual(policy, None) + # basic tests + pkg = cache["apt"] + self.assertEqual(policy.get_priority(pkg._pkg), 0) + # get priority for all pkgfiles + for ver in pkg.versions: + lowlevel_ver = ver._cand + for pkgfile, i in lowlevel_ver.file_list: + #print pkgfile, i, policy.get_priority(pkgfile) + self.assertTrue(policy.get_priority(pkgfile) > 1) + self.assertTrue(policy.get_priority(pkgfile) < 1001) + + def test_apt_policy_highlevel(self): + cache = apt.Cache() + pkg = cache["apt"] + self.assertTrue(pkg.candidate.policy_priority > 1 and + pkg.candidate.policy_priority < 1001) + + + +if __name__ == "__main__": + unittest.main() |
