diff options
Diffstat (limited to 'tests/test_index.py')
-rw-r--r-- | tests/test_index.py | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/test_index.py b/tests/test_index.py new file mode 100644 index 0000000..52c2717 --- /dev/null +++ b/tests/test_index.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +"""Test index handling.""" + +import os.path + +import apt +import apt_pkg +import unittest + +import aptdaemon.test + + +class IndexRaceTest(unittest.TestCase): + + """If the indexes are deleted or manipulated at the time + apt.Cache.required_download was called we get the following error: + SystemError: I wasn't able to locate file for the XXX package. + This might mean you need to manually fix this package. + + See lp:#659438 + """ + + def setUp(self): + self.chroot = aptdaemon.test.Chroot() + self.chroot.setup() + self.chroot.add_test_repository() + # Check if installing an uninstalled package works + self.cache = apt.Cache(rootdir=self.chroot.path) + self.cache["silly-base"].mark_install() + self.assertEqual(self.cache.required_download, 0) + self.cache.clear() + + def test(self): + lists_path = apt_pkg.config.find_dir("Dir::State::Lists") + for file_name in os.listdir(lists_path): + if file_name.endswith("Packages"): + os.remove(os.path.join(lists_path, file_name)) + self.cache["silly-base"].mark_install() + self.assertRaises(SystemError, + lambda: self.cache.required_download) +# self.cache.required_download + + +if __name__ == "__main__": + unittest.main() + +# vim: ts=4 et sts=4 |