Merge lp:~allenap/launchpad/support-timeframe-fix-660433 into lp:launchpad

Proposed by Gavin Panella
Status: Merged
Approved by: Gavin Panella
Approved revision: no longer in the source branch.
Merged at revision: 12250
Proposed branch: lp:~allenap/launchpad/support-timeframe-fix-660433
Merge into: lp:launchpad
Prerequisite: lp:~mvo/launchpad/support-timeframe-fix-660433
Diff against target: 171 lines (+38/-40)
1 file modified
lib/lp/soyuz/scripts/tests/test_cron_germinate.py (+38/-40)
To merge this branch: bzr merge lp:~allenap/launchpad/support-timeframe-fix-660433
Reviewer Review Type Date Requested Status
Gavin Panella (community) Approve
Review via email: mp+47004@code.launchpad.net

Commit message

[r=allenap][ui=none][bug=660433] Update support-timeframe info for NEW packages. Thanks to Michael Vogt.

Description of the change

Some clean-ups to prepare mvo's change for landing.

To post a comment you must log in.
Revision history for this message
Gavin Panella (allenap) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/soyuz/scripts/tests/test_cron_germinate.py'
2--- lib/lp/soyuz/scripts/tests/test_cron_germinate.py 2011-01-21 00:04:57 +0000
3+++ lib/lp/soyuz/scripts/tests/test_cron_germinate.py 2011-01-21 00:05:23 +0000
4@@ -10,21 +10,13 @@
5 import gzip
6 import os
7 import subprocess
8-import unittest
9-
10-try:
11- from lp.testing import TestCase
12-except ImportError:
13- # mvo: *cough* poor mans version if no full LP environment is installed
14- class PoorMvosTestCase(unittest.TestCase):
15- def makeTemporaryDirectory(self):
16- import tempfile
17- return tempfile.mkdtemp(prefix="test_cron_germinate_")
18- TestCase = PoorMvosTestCase
19+
20+from lp.testing import TestCase
21+
22
23 class TestCronGerminate(TestCase):
24
25- DISTRO_NAMES = [ "platform", "ubuntu", "kubuntu", "netbook" ]
26+ DISTRO_NAMES = ["platform", "ubuntu", "kubuntu", "netbook"]
27 DISTS = ["hardy", "lucid", "maverick"]
28 DEVELOPMENT_DIST = "natty"
29 COMPONENTS = ["main", "restricted", "universe", "multiverse"]
30@@ -43,18 +35,18 @@
31 self.ubuntu_misc_dir = os.path.join(self.archive_dir, "ubuntu-misc")
32 self.ubuntu_germinate_dir = os.path.join(
33 self.archive_dir, "ubuntu-germinate")
34- # create a mock archive environment for all the distros we
35- # support and also include "updates" and "security"
36+ # Create a mock archive environment for all the distros we support and
37+ # also include "updates" and "security".
38 for dist in self.DISTS + [self.DEVELOPMENT_DIST]:
39 self.populate_mock_archive_environment(
40 self.archive_dir, self.COMPONENTS, self.ARCHES, dist)
41 for component in ["security", "updates"]:
42 self.populate_mock_archive_environment(
43- self.archive_dir, self.COMPONENTS, self.ARCHES,
44+ self.archive_dir, self.COMPONENTS, self.ARCHES,
45 "%s-%s" % (dist, component))
46- # generate test dummies for maintenance-time.py, if this is
47- # set to "None" instead it will use the network to test against
48- # the real data
49+ # Generate test dummies for maintenance-time.py, if this is set to
50+ # "None" instead it will use the network to test against the real
51+ # data.
52 self.germinate_output_dir = self.setup_mock_germinate_output()
53
54 def create_directory_if_missing(self, directory):
55@@ -69,7 +61,8 @@
56
57 def create_gzip_file(self, filepath, content=""):
58 """Create a gziped file in the given path with the given content.
59- If not content is given a empty file is created.
60+
61+ If no content is given a empty file is created.
62 """
63 gz = gzip.GzipFile(filepath, "w")
64 gz.write(content)
65@@ -77,7 +70,8 @@
66
67 def create_file(self, filepath, content=""):
68 """Create a file in the given path with the given content.
69- If not content is given a empty file is created.
70+
71+ If no content is given a empty file is created.
72 """
73 f = open(filepath, "w")
74 f.write(content)
75@@ -90,15 +84,19 @@
76 dirs = []
77 for distro_name in self.DISTRO_NAMES:
78 for distro_series in self.DISTS:
79- dirs.append(os.path.join(germinate_output_dir, "%s.%s" % (distro_name, distro_series)))
80+ dirs.append(
81+ os.path.join(
82+ germinate_output_dir,
83+ "%s.%s" % (distro_name, distro_series)))
84 self.create_directory_list_if_missing(dirs)
85 for dir in dirs:
86 self.create_file(os.path.join(dir, "structure"))
87 return germinate_output_dir
88
89 def setup_mock_archive_environment(self):
90- """Creates a mock archive environment and populate
91- it with the subdirectories that germinate will expect.
92+ """
93+ Creates a mock archive environment and populate it with the
94+ subdirectories that germinate will expect.
95 """
96 archive_dir = os.path.join(
97 self.tmpdir, "germinate-test-data", "ubuntu-archive")
98@@ -114,8 +112,9 @@
99
100 def populate_mock_archive_environment(self, archive_dir, components_list,
101 arches_list, current_devel_distro):
102- """Populates a mock archive environment with empty source packages
103- and empty binary packages.
104+ """
105+ Populates a mock archive environment with empty source packages and
106+ empty binary packages.
107 """
108 for component in components_list:
109 # Create the environment for the source packages.
110@@ -137,11 +136,12 @@
111 self.create_gzip_file(os.path.join(
112 targetdir, "Packages.gz"))
113
114- def create_fake_environment(self, basepath, archive_dir,
115+ def create_fake_environment(self, basepath, archive_dir,
116 germinate_output_dir):
117- """Create a fake process envirionment based on os.environ that
118- sets TEST_ARCHIVEROOT, TEST_LAUNCHPADROOT and modifies PATH
119- to point to the mock lp-bin directory.
120+ """
121+ Create a fake process envirionment based on os.environ that sets
122+ TEST_ARCHIVEROOT, TEST_LAUNCHPADROOT and modifies PATH to point to the
123+ mock lp-bin directory.
124 """
125 fake_environ = copy.copy(os.environ)
126 fake_environ["TEST_ARCHIVEROOT"] = os.path.abspath(
127@@ -167,7 +167,8 @@
128 os.path.join(archive_dir, "ubuntu"))
129 fake_environ["MAINTENANCE_CHECK_ARCHIVE_ROOT"] = archive_root_url
130 # maintenance-check.py expects a format string
131- hints_file_url = germinate_output_dir + "/platform.%s/SUPPORTED_HINTS"
132+ hints_file_url = (
133+ germinate_output_dir + "/platform.%s/SUPPORTED_HINTS")
134 for distro in self.DISTS:
135 open(hints_file_url % distro, "w")
136 fake_environ["MAINTENANCE_CHECK_HINTS_DIR_URL"] = "file://%s" % \
137@@ -179,11 +180,12 @@
138 return fake_environ
139
140 def test_maintenance_update(self):
141- """Test the maintenance-check.py porition of the soyuz cron.germinate
142- shell script by running it inside a fake environment and ensure
143- that it did update the "Support" override information for
144- apt-ftparchive without destroying/modifying the information
145- that the "germinate" script added to it earlier.
146+ """
147+ Test the maintenance-check.py porition of the soyuz cron.germinate
148+ shell script by running it inside a fake environment and ensure that
149+ it did update the "Support" override information for apt-ftparchive
150+ without destroying/modifying the information that the "germinate"
151+ script added to it earlier.
152 """
153 # Write into more-extras.overrides to ensure it is alive after we
154 # mucked around.
155@@ -215,8 +217,7 @@
156 main_override_file = os.path.join(
157 self.ubuntu_misc_dir,
158 "more-extra.override.%s.main" % dist)
159- self.assertIn(canary, open(main_override_file).read(),
160- "canary no longer there for '%s'" % dist)
161+ self.assertIn(canary, open(main_override_file).read())
162
163 # Check here if we got the data from maintenance-check.py that
164 # we expected. This is a kernel name from lucid-updates and it
165@@ -225,6 +226,3 @@
166 lucid_supported_override_file = os.path.join(
167 self.ubuntu_misc_dir, "more-extra.override.lucid.main")
168 self.assertIn(needle, open(lucid_supported_override_file).read())
169-
170-if __name__ == "__main__":
171- unittest.main()