Merge lp:~pwlars/qa-iso-static-validation-test/pep8 into lp:qa-iso-static-validation-test
- pep8
- Merge into trunk
Proposed by
Paul Larson
Status: | Merged |
---|---|
Merged at revision: | 15 |
Proposed branch: | lp:~pwlars/qa-iso-static-validation-test/pep8 |
Merge into: | lp:qa-iso-static-validation-test |
Diff against target: |
330 lines (+71/-67) 1 file modified
iso_static_validation.py (+71/-67) |
To merge this branch: | bzr merge lp:~pwlars/qa-iso-static-validation-test/pep8 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Para Siva | Approve | ||
Review via email: mp+124925@code.launchpad.net |
Commit message
Description of the change
No other changes or cleanups in this branch, just enough to make it pass
pep8 compliance.
To post a comment you must log in.
Revision history for this message
Para Siva (psivaa) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'iso_static_validation.py' |
2 | --- iso_static_validation.py 2012-08-30 08:57:30 +0000 |
3 | +++ iso_static_validation.py 2012-09-18 13:39:20 +0000 |
4 | @@ -28,20 +28,19 @@ |
5 | import subprocess |
6 | import hashlib |
7 | import unittest |
8 | -import time |
9 | -import datetime |
10 | import re |
11 | import tempfile |
12 | import shutil |
13 | |
14 | # Defaults |
15 | -#DEFAULT_ISOROOT = os.path.expanduser('/var/lib/ubuntu-server-iso-testing/isos/ubuntu/') |
16 | +#DEFAULT_ISOROOT = os.path.expanduser( |
17 | +# '/var/lib/ubuntu-server-iso-testing/isos/ubuntu/') |
18 | DEFAULT_URL = 'http://cdimage.ubuntu.com/' |
19 | |
20 | #constants |
21 | -ONE_MB_BLOCK=2**20 |
22 | -PRECISE_SIZE_LIMIT_MB=737148928 |
23 | -QUANTAL_SIZE_LIMIT_MB=838860800 |
24 | +ONE_MB_BLOCK = 2 ** 20 |
25 | +PRECISE_SIZE_LIMIT_MB = 737148928 |
26 | +QUANTAL_SIZE_LIMIT_MB = 838860800 |
27 | |
28 | #Read the iso name and initialise global variables |
29 | parser = argparse.ArgumentParser() |
30 | @@ -49,10 +48,11 @@ |
31 | parser.add_argument('--name') |
32 | args = parser.parse_args() |
33 | |
34 | -logging.basicConfig(level = logging.INFO) |
35 | +logging.basicConfig(level=logging.INFO) |
36 | |
37 | if args.name == None or '.iso' not in args.name or args.isoroot == None: |
38 | - print 'The usage:', sys.argv[0], '--name release-variant-arch.iso --isoroot ~/iso_location' |
39 | + print('The usage:', sys.argv[0], |
40 | + '--name release-variant-arch.iso --isoroot ~/iso_location') |
41 | sys.exit(1) |
42 | else: |
43 | st_name = args.name.rstrip('.iso') |
44 | @@ -68,6 +68,7 @@ |
45 | else: |
46 | ubiquity_image = False |
47 | |
48 | + |
49 | class TestValidateISO(unittest.TestCase): |
50 | @classmethod |
51 | def setUpClass(cls): |
52 | @@ -76,7 +77,7 @@ |
53 | except OSError: |
54 | logging.error("Creating temp dirrectory failed") |
55 | unittest.fail("Setup error") |
56 | - |
57 | + |
58 | def setUp(self): |
59 | self.iso_name = args.name |
60 | self.block_size = ONE_MB_BLOCK |
61 | @@ -84,7 +85,7 @@ |
62 | self.st_release = st_release |
63 | self.st_variant = st_variant |
64 | self.st_arch = st_arch |
65 | - |
66 | + |
67 | if self.st_release != 'precise': |
68 | self.url = DEFAULT_URL |
69 | else: |
70 | @@ -100,7 +101,7 @@ |
71 | if self.st_release == 'precise': |
72 | self.url = os.path.join(DEFAULT_URL, 'ubuntu-server', |
73 | 'precise', 'daily') |
74 | - else: # current dev release |
75 | + else: # current dev release |
76 | self.url = os.path.join(DEFAULT_URL, 'ubuntu-server', 'daily') |
77 | else: |
78 | self.fail("Image name be in the form of release-variant-arch.iso") |
79 | @@ -134,10 +135,10 @@ |
80 | sha256 = hashlib.sha256() |
81 | with open(self.iso_location) as f: |
82 | while True: |
83 | - data = f.read(self.block_size) |
84 | - if not data: |
85 | - break |
86 | - sha256.update(data) |
87 | + data = f.read(self.block_size) |
88 | + if not data: |
89 | + break |
90 | + sha256.update(data) |
91 | sha256 = sha256.hexdigest() |
92 | logging.debug("Expected Checksum: '%s'", iso_sha256) |
93 | logging.debug("Local File Checksum: '%s'", sha256) |
94 | @@ -146,13 +147,13 @@ |
95 | # Test if the list file in the repository matches the content of the iso |
96 | def test_files_list(self): |
97 | if self.st_variant == 'server': |
98 | - list_url = os.path.join(self.url, 'current', |
99 | + list_url = os.path.join(self.url, 'current', |
100 | self.st_release + '-' + 'server' + '-' + |
101 | self.st_arch + '.list') |
102 | else: |
103 | - list_url = os.path.join(self.url, 'current', |
104 | + list_url = os.path.join(self.url, 'current', |
105 | self.st_release + '-' + |
106 | - self.st_variant + '-' + |
107 | + self.st_variant + '-' + |
108 | self.st_arch + '.list') |
109 | |
110 | try: |
111 | @@ -164,9 +165,9 @@ |
112 | |
113 | logging.debug('Extracting list file info from ISO') |
114 | cmd = ["bsdtar", "-tf", self.iso_location] |
115 | - output = subprocess.Popen(cmd, stdout = subprocess.PIPE, |
116 | - stderr = subprocess.PIPE) |
117 | - (stdout, stderr) = output.communicate () |
118 | + output = subprocess.Popen(cmd, stdout=subprocess.PIPE, |
119 | + stderr=subprocess.PIPE) |
120 | + (stdout, stderr) = output.communicate() |
121 | logging.debug('Checking for error in extracting the file list') |
122 | self.assertEqual(stderr, '') |
123 | |
124 | @@ -175,12 +176,12 @@ |
125 | self.assertIn(list_entry[1:].rstrip(), stdout) |
126 | |
127 | # Test if the manfest is the same as that is given in the server |
128 | - @unittest.skipUnless(ubiquity_image, |
129 | + @unittest.skipUnless(ubiquity_image, |
130 | "manifest only for ubiquity based images") |
131 | def test_manifest(self): |
132 | - manifest_url = os.path.join(self.url, 'current', |
133 | + manifest_url = os.path.join(self.url, 'current', |
134 | self.st_release + '-' + |
135 | - self.st_variant + '-' + |
136 | + self.st_variant + '-' + |
137 | self.st_arch + '.manifest') |
138 | try: |
139 | manifest = urllib2.urlopen(manifest_url) |
140 | @@ -192,9 +193,9 @@ |
141 | logging.debug('Extracting manifest from the iso') |
142 | cmd = ["bsdtar", "-xf", self.iso_location, "-C", self.temp_dir, |
143 | "casper/filesystem.manifest"] |
144 | - output = subprocess.Popen(cmd, stdout = subprocess.PIPE, |
145 | - stderr = subprocess.PIPE) |
146 | - (stdout, stderr) = output.communicate () |
147 | + output = subprocess.Popen(cmd, stdout=subprocess.PIPE, |
148 | + stderr=subprocess.PIPE) |
149 | + (stdout, stderr) = output.communicate() |
150 | logging.debug('Check for error in extracting manifest info from iso') |
151 | self.assertEqual(stderr, '') |
152 | |
153 | @@ -212,9 +213,9 @@ |
154 | logging.debug('Extract distro information of the image from the iso') |
155 | cmd = ["bsdtar", "-xf", self.iso_location, "-C", |
156 | self.temp_dir, "./.disk/info"] |
157 | - output = subprocess.Popen(cmd, stdout = subprocess.PIPE, |
158 | - stderr = subprocess.PIPE) |
159 | - (stdout, stderr) = output.communicate () |
160 | + output = subprocess.Popen(cmd, stdout=subprocess.PIPE, |
161 | + stderr=subprocess.PIPE) |
162 | + (stdout, stderr) = output.communicate() |
163 | logging.debug('Checking for error in extracting distro info from iso') |
164 | self.assertEqual(stderr, '') |
165 | |
166 | @@ -240,36 +241,36 @@ |
167 | self.assertIn(id_server, build_info_line) |
168 | |
169 | # Test if wubi is present for desktop or dvd and it is a valid PE |
170 | - @unittest.skipUnless(st_variant =='desktop' and |
171 | + @unittest.skipUnless(st_variant == 'desktop' and |
172 | st_arch != 'powerpc', "Skipping non ubiquity images") |
173 | def test_wubi(self): |
174 | logging.debug('Extracting wubi from the desktop images') |
175 | - cmd = ["bsdtar", "-xf", self.iso_location, "-C", |
176 | + cmd = ["bsdtar", "-xf", self.iso_location, "-C", |
177 | self.temp_dir, "./wubi.exe"] |
178 | - output = subprocess.Popen(cmd, stdout = subprocess.PIPE, |
179 | - stderr = subprocess.PIPE) |
180 | - (stdout, stderr) = output.communicate () |
181 | + output = subprocess.Popen(cmd, stdout=subprocess.PIPE, |
182 | + stderr=subprocess.PIPE) |
183 | + (stdout, stderr) = output.communicate() |
184 | logging.debug('Check for error in extracting wubi.exe from the iso') |
185 | self.assertEqual(stderr, '') |
186 | |
187 | wubi_path = os.path.join(self.temp_dir, './wubi.exe') |
188 | |
189 | cmd = ["file", wubi_path] |
190 | - output = subprocess.Popen(cmd, stdout = subprocess.PIPE, |
191 | - stderr = subprocess.PIPE) |
192 | - (stdout, stderr) = output.communicate () |
193 | + output = subprocess.Popen(cmd, stdout=subprocess.PIPE, |
194 | + stderr=subprocess.PIPE) |
195 | + (stdout, stderr) = output.communicate() |
196 | logging.debug('Check that wubi has a valid PE header') |
197 | self.assertEqual(stderr, '') |
198 | self.assertIn(" PE32 executable (GUI)", stdout) |
199 | |
200 | # Test if the relevant files are present in the iso for desktop iso |
201 | - @unittest.skipUnless(st_variant == 'desktop' and |
202 | + @unittest.skipUnless(st_variant == 'desktop' and |
203 | st_arch != 'powerpc', "Skipping for non desktop iso") |
204 | def test_files_ubiquity(self): |
205 | cmd = ["bsdtar", "-tf", self.iso_location] |
206 | - output = subprocess.Popen(cmd, stdout = subprocess.PIPE, |
207 | - stderr = subprocess.PIPE) |
208 | - (stdout, stderr) = output.communicate () |
209 | + output = subprocess.Popen(cmd, stdout=subprocess.PIPE, |
210 | + stderr=subprocess.PIPE) |
211 | + (stdout, stderr) = output.communicate() |
212 | logging.debug('Check for error in extracting file list from the iso') |
213 | self.assertEqual(stderr, '') |
214 | files_list = open("data/file_list_ubiquity") |
215 | @@ -282,9 +283,9 @@ |
216 | "This file list test is only specific for dvd") |
217 | def test_files_ubiquity_dvd(self): |
218 | cmd = ["bsdtar", "-tf", self.iso_location] |
219 | - output = subprocess.Popen(cmd, stdout = subprocess.PIPE, |
220 | - stderr = subprocess.PIPE) |
221 | - (stdout, stderr) = output.communicate () |
222 | + output = subprocess.Popen(cmd, stdout=subprocess.PIPE, |
223 | + stderr=subprocess.PIPE) |
224 | + (stdout, stderr) = output.communicate() |
225 | logging.debug('Check for error in extracting file list from the iso') |
226 | self.assertEqual(stderr, '') |
227 | files_list = open("data/file_list_ubiquity_dvd") |
228 | @@ -300,15 +301,15 @@ |
229 | @unittest.skipIf(ubiquity_image, "Skipping for ubiquity images") |
230 | def test_files_di(self): |
231 | cmd = ["bsdtar", "-tf", self.iso_location] |
232 | - output = subprocess.Popen(cmd, stdout = subprocess.PIPE, |
233 | - stderr = subprocess.PIPE) |
234 | - (stdout, stderr) = output.communicate () |
235 | + output = subprocess.Popen(cmd, stdout=subprocess.PIPE, |
236 | + stderr=subprocess.PIPE) |
237 | + (stdout, stderr) = output.communicate() |
238 | logging.debug('Check for error in extracting file list from the iso') |
239 | self.assertEqual(stderr, '') |
240 | |
241 | if self.st_arch == 'powerpc' or self.st_arch == 'amd64+mac': |
242 | files_list = open("data/file_list_di_powerpc") |
243 | - else: #i386 or amd64 |
244 | + else: # i386 or amd64 |
245 | files_list = open("data/file_list_di") |
246 | |
247 | for list_server in files_list: |
248 | @@ -321,42 +322,43 @@ |
249 | def test_vmlinuz(self): |
250 | cmd = ["bsdtar", "-xf", self.iso_location, "-C", |
251 | self.temp_dir, "casper/vmlinuz"] |
252 | - output = subprocess.Popen(cmd, stdout = subprocess.PIPE, |
253 | - stderr = subprocess.PIPE) |
254 | - (stdout, stderr) = output.communicate () |
255 | + output = subprocess.Popen(cmd, stdout=subprocess.PIPE, |
256 | + stderr=subprocess.PIPE) |
257 | + (stdout, stderr) = output.communicate() |
258 | logging.debug('Asserting that vmlinuz is present in the iso') |
259 | self.assertEqual(stderr, '') |
260 | |
261 | vmlinuz_path = os.path.join(self.temp_dir, 'casper/vmlinuz') |
262 | |
263 | cmd = ["file", vmlinuz_path] |
264 | - output = subprocess.Popen(cmd, stdout = subprocess.PIPE, |
265 | - stderr = subprocess.PIPE) |
266 | - (stdout, stderr) = output.communicate () |
267 | + output = subprocess.Popen(cmd, stdout=subprocess.PIPE, |
268 | + stderr=subprocess.PIPE) |
269 | + (stdout, stderr) = output.communicate() |
270 | logging.debug('Check if vmlinuz present in the iso is a Linux kernel') |
271 | self.assertEqual(stderr, '') |
272 | self.assertIn("Linux kernel", stdout) |
273 | |
274 | - # Test if filesystem.squashfs is present and |
275 | + # Test if filesystem.squashfs is present and |
276 | # if that is a squash fs for ubiquity based images |
277 | @unittest.skipUnless(ubiquity_image, "Skipping for non ubiquity images") |
278 | def test_filesystem_squashfs(self): |
279 | logging.debug('Extracting the filesystem.squashfs') |
280 | - cmd = ["bsdtar", "-xf" , self.iso_location, "-C", |
281 | + cmd = ["bsdtar", "-xf", self.iso_location, "-C", |
282 | self.temp_dir, "casper/filesystem.squashfs"] |
283 | - output = subprocess.Popen(cmd, stdout = subprocess.PIPE, |
284 | - stderr = subprocess.PIPE) |
285 | - (stdout, stderr) = output.communicate () |
286 | + output = subprocess.Popen(cmd, stdout=subprocess.PIPE, |
287 | + stderr=subprocess.PIPE) |
288 | + (stdout, stderr) = output.communicate() |
289 | logging.debug('Check for error in extracting filesystem.squashfs') |
290 | self.assertEqual(stderr, '') |
291 | |
292 | - squashfs_path = os.path.join(self.temp_dir, 'casper/filesystem.squashfs') |
293 | + squashfs_path = os.path.join(self.temp_dir, |
294 | + 'casper/filesystem.squashfs') |
295 | |
296 | logging.debug('Checking the file is an actual .squashfs') |
297 | cmd = ["file", squashfs_path] |
298 | - output = subprocess.Popen(cmd, stdout = subprocess.PIPE, |
299 | - stderr = subprocess.PIPE) |
300 | - (stdout, stderr) = output.communicate () |
301 | + output = subprocess.Popen(cmd, stdout=subprocess.PIPE, |
302 | + stderr=subprocess.PIPE) |
303 | + (stdout, stderr) = output.communicate() |
304 | logging.debug('Check if signature contains \"Squashfs filesystem\"') |
305 | self.assertEqual(stderr, '') |
306 | self.assertIn("Squashfs filesystem", stdout) |
307 | @@ -369,7 +371,7 @@ |
308 | #self.assertEqual(stderr, '') |
309 | #self.assertIn("created 1 directories", stdout) |
310 | |
311 | - # Test if the report.html exists for the d-i based images |
312 | + # Test if the report.html exists for the d-i based images |
313 | # and that it does not have any conflicting packages |
314 | @unittest.skipIf(ubiquity_image, "Skipping for ubiquity based images") |
315 | def test_report_html(self): |
316 | @@ -392,10 +394,12 @@ |
317 | |
318 | if(self.st_release == 'precise'): |
319 | # check if the size of the image fits a 703MB cd for precise |
320 | - self.assertTrue(statinfo.st_size < PRECISE_SIZE_LIMIT_MB, "Size: %s" % (statinfo.st_size)) |
321 | + self.assertTrue(statinfo.st_size < PRECISE_SIZE_LIMIT_MB, |
322 | + "Size: %s" % (statinfo.st_size)) |
323 | else: |
324 | # check if the size of the image fits a 800MB cd for quantal |
325 | - self.assertTrue(statinfo.st_size < QUANTAL_SIZE_LIMIT_MB, "Size: %s" % (statinfo.st_size)) |
326 | + self.assertTrue(statinfo.st_size < QUANTAL_SIZE_LIMIT_MB, |
327 | + "Size: %s" % (statinfo.st_size)) |
328 | |
329 | # clean up |
330 | @classmethod |