1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
#!/usr/bin/python3
#
# 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 datetime
import os
import unittest
import testcommon
from apt.utils import get_maintenance_end_date, get_release_date_from_release_file
class TestUtils(testcommon.TestCase):
def test_get_release_date_from_release_file(self):
path = os.path.join(os.path.dirname(__file__), "data", "misc", "foo_Release")
t = get_release_date_from_release_file(path)
self.assertEqual(
str(datetime.datetime.fromtimestamp(t, datetime.UTC)),
"2012-04-25 22:49:23+00:00",
)
def test_maintenance_time(self):
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()
|