diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 18:07:41 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 18:07:41 +0000 |
commit | 76926159194e180003aa78de97e5f287bf4325a5 (patch) | |
tree | 2cea7245cdc3f66355900c820c145eba90598766 /tests/test_progress.py | |
parent | Initial commit. (diff) | |
download | python-apt-76926159194e180003aa78de97e5f287bf4325a5.tar.xz python-apt-76926159194e180003aa78de97e5f287bf4325a5.zip |
Adding upstream version 2.7.6.upstream/2.7.6
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_progress.py')
-rw-r--r-- | tests/test_progress.py | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/test_progress.py b/tests/test_progress.py new file mode 100644 index 0000000..c823019 --- /dev/null +++ b/tests/test_progress.py @@ -0,0 +1,56 @@ +#!/usr/bin/python3 +# +# Copyright (C) 2010 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. +"""Unit tests for verifying the correctness of apt.progress""" +import os +import unittest + +import apt_pkg +import testcommon + +import apt + + +class TestAcquireProgress(apt.progress.base.AcquireProgress): + def pulse(self, owner): + self.pulsed = True + # there should be a return value here, either (True,False) + # but often this is forgoten (and causes odd error messages) + # so the lib supports it. we test the lack of support value here + + +class TestProgress(testcommon.TestCase): + def setUp(self): + testcommon.TestCase.setUp(self) + basedir = os.path.abspath(os.path.dirname(__file__)) + # setup apt_pkg config + apt_pkg.init() + apt_pkg.config.set("APT::Architecture", "amd64") + apt_pkg.config.set("Dir::Etc", basedir) + # TODO: /dev/null is not a dir, perhaps find something better + apt_pkg.config.set("Dir::Etc::sourceparts", "/dev/null") + # setup lists dir + if not os.path.exists("./tmp/partial"): + os.makedirs("./tmp/partial") + apt_pkg.config.set("Dir::state::lists", "./tmp") + # create artifical line + 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() |