diff options
| author | Michael Vogt <michael.vogt@ubuntu.com> | 2011-10-21 09:13:58 +0200 |
|---|---|---|
| committer | Michael Vogt <michael.vogt@ubuntu.com> | 2011-10-21 09:13:58 +0200 |
| commit | 8ca5779cfe930f8a423969f7266949ab2826cede (patch) | |
| tree | 44918730b1f9f5a567ac89f15ab661ae7be1e1a9 /tests | |
| parent | 50756e0efb5081d3379fa874ca41ab57bdf2798d (diff) | |
| parent | 52097d7edaa97379a4a604be4feb24e5e9c3bd73 (diff) | |
| download | python-apt-8ca5779cfe930f8a423969f7266949ab2826cede.tar.gz | |
merged from the debian-sid branch
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_apt_cache.py | 2 | ||||
| -rw-r--r-- | tests/test_progress.py | 2 | ||||
| -rw-r--r-- | tests/test_utils.py | 56 |
3 files changed, 58 insertions, 2 deletions
diff --git a/tests/test_apt_cache.py b/tests/test_apt_cache.py index 9c1f549f..2b742dfa 100644 --- a/tests/test_apt_cache.py +++ b/tests/test_apt_cache.py @@ -133,7 +133,7 @@ class TestAptCache(unittest.TestCase): old_source_list = apt_pkg.config.find("dir::etc::sourcelist") old_source_parts = apt_pkg.config.find("dir::etc::sourceparts") apt_pkg.config.set("dir::etc::sourcelist", base_sources) - apt_pkg.config.set("dir::etc::sourceparts", "xxx") + apt_pkg.config.set("dir::etc::sourceparts", "/tmp") # main sources.list sources_list = base_sources with open(sources_list, "w") as f: diff --git a/tests/test_progress.py b/tests/test_progress.py index 73853dfa..3b6285d6 100644 --- a/tests/test_progress.py +++ b/tests/test_progress.py @@ -27,7 +27,7 @@ class TestProgress(unittest.TestCase): apt_pkg.init() apt_pkg.config.set("APT::Architecture", "amd64") apt_pkg.config.set("Dir::Etc", basedir) - apt_pkg.config.set("Dir::Etc::sourceparts", "/xxx") + apt_pkg.config.set("Dir::Etc::sourceparts", "/tmp") # setup lists dir if not os.path.exists("./tmp/partial"): os.makedirs("./tmp/partial") diff --git a/tests/test_utils.py b/tests/test_utils.py new file mode 100644 index 00000000..23511f32 --- /dev/null +++ b/tests/test_utils.py @@ -0,0 +1,56 @@ +#!/usr/bin/python +# +# Copyright (C) 2010 Michael Vogt <michael.vogt@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 sys +sys.path.insert(0, "..") +import apt_pkg +import apt.utils +import datetime +import unittest + +class TestUtils(unittest.TestCase): + + + def test_maintenance_time(self): + from apt.utils import get_maintenance_end_date + months_of_support = 18 + # test historic releases, jaunty + release_date = datetime.datetime(2009, 4, 23) + (end_year, end_month) = get_maintenance_end_date(release_date, months_of_support) + self.assertEqual(end_year, 2010) + self.assertEqual(end_month, 10) + # test historic releases, karmic + release_date = datetime.datetime(2009, 10, 29) + (end_year, end_month) = get_maintenance_end_date(release_date, months_of_support) + self.assertEqual(end_year, 2011) + self.assertEqual(end_month, 4) + # test maverick + release_date = datetime.datetime(2010, 10, 10) + (end_year, end_month) = get_maintenance_end_date(release_date, months_of_support) + self.assertEqual(end_year, 2012) + self.assertEqual(end_month, 4) + + # test with modulo zero + release_date = datetime.datetime(2010, 6, 10) + (end_year, end_month) = get_maintenance_end_date(release_date, months_of_support) + self.assertEqual(end_year, 2011) + self.assertEqual(end_month, 12) + + # test dapper + months_of_support = 60 + release_date = datetime.datetime(2008, 4, 24) + (end_year, end_month) = get_maintenance_end_date(release_date, months_of_support) + self.assertEqual(end_year, 2013) + self.assertEqual(end_month, 4) + + # what datetime says + #d = datetime.timedelta(18*30) + #print "end date: ", release_date + d + +if __name__ == "__main__": + unittest.main() |
