|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""Unit tests for verifying the correctness of apt.progress""" |
|
import unittest |
|
|
|
import apt |
|
import apt_pkg |
|
import os |
|
|
|
import testcommon |
|
|
|
|
|
class TestAcquireProgress(apt.progress.base.AcquireProgress): |
|
def pulse(self, owner): |
|
self.pulsed = True |
|
|
|
|
|
|
|
|
|
|
|
class TestProgress(testcommon.TestCase): |
|
|
|
def setUp(self): |
|
testcommon.TestCase.setUp(self) |
|
basedir = os.path.abspath(os.path.dirname(__file__)) |
|
|
|
apt_pkg.init() |
|
apt_pkg.config.set("APT::Architecture", "amd64") |
|
apt_pkg.config.set("Dir::Etc", basedir) |
|
|
|
apt_pkg.config.set("Dir::Etc::sourceparts", "/dev/null") |
|
|
|
if not os.path.exists("./tmp/partial"): |
|
os.makedirs("./tmp/partial") |
|
apt_pkg.config.set("Dir::state::lists", "./tmp") |
|
|
|
deb_line = ("deb [allow-insecure=yes] file:%s/data/fake-packages/ /\n" |
|
% basedir) |
|
with open("fetch_sources.list", "w") as fobj: |
|
fobj.write(deb_line) |
|
apt_pkg.config.set("Dir::Etc::sourcelist", "fetch_sources.list") |
|
apt_pkg.config.clear("APT::Update::Post-Invoke") |
|
apt_pkg.config.clear("APT::Update::Post-Invoke-Success") |
|
|
|
def test_acquire_progress(self): |
|
progress = TestAcquireProgress() |
|
cache = apt.Cache() |
|
cache.update(progress) |
|
self.assertTrue(progress.pulsed) |
|
|
|
|
|
if __name__ == "__main__": |
|
unittest.main() |
|
|