|
|
|
|
|
"""Regression test for LP: #981896, LP: #659438""" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
__author__ = "Sebastian Heinlein <[email protected]>" |
|
|
|
import os |
|
import shutil |
|
import tempfile |
|
import unittest |
|
|
|
import apt_pkg |
|
import apt |
|
|
|
import testcommon |
|
|
|
|
|
class RegressionTestCase(testcommon.TestCase): |
|
|
|
"""Test suite for LP: #981896, LP: #659438 |
|
'Cannot locate a file for package X' |
|
""" |
|
|
|
def setUp(self): |
|
testcommon.TestCase.setUp(self) |
|
apt_pkg.config.clear("APT::Update::Post-Invoke") |
|
apt_pkg.config.clear("APT::Update::Post-Invoke-Success") |
|
self.chroot_path = chroot_path = tempfile.mkdtemp() |
|
|
|
self.cache = apt.cache.Cache(rootdir=chroot_path) |
|
with open(apt_pkg.config.find_file("Dir::State::status"), |
|
"a") as status: |
|
status.write("""Package: abrowser |
|
Status: install reinstreq half-installed |
|
Priority: optional |
|
Section: admin |
|
Version: 3.6.9+build1+nobinonly-0ubuntu1 |
|
Architecture: all""") |
|
sources_list_path = apt_pkg.config.find_file("Dir::Etc::sourcelist") |
|
repo_path = os.path.abspath("./data/test-repo") |
|
with open(sources_list_path, "w") as sources_list: |
|
sources_list.write("deb [allow-insecure=yes] copy:%s /\n" |
|
% repo_path) |
|
|
|
self.cache.update(sources_list=sources_list_path) |
|
self.cache.open() |
|
|
|
def tearDown(self): |
|
|
|
|
|
apt.cache.Cache(rootdir="/") |
|
shutil.rmtree(self.chroot_path) |
|
|
|
def test_survive_reqreinst(self): |
|
"""Test that we survive a package in require reinstallation state""" |
|
|
|
self.assertEqual(self.cache.required_download, 82324) |
|
|
|
|
|
if __name__ == "__main__": |
|
unittest.main() |
|
|
|
|
|
|