Merge lp:~allanlesage/helipad/test-fixes into lp:helipad/ci
- test-fixes
- Merge into ci
Proposed by
Chris Johnston
Status: | Merged |
---|---|
Merged at revision: | 29 |
Proposed branch: | lp:~allanlesage/helipad/test-fixes |
Merge into: | lp:helipad/ci |
Diff against target: |
568 lines (+157/-233) 9 files modified
tests/__init__.py (+5/-0) tests/extractor/__init__.py (+8/-0) tests/integration/__init__.py (+8/-0) tests/test_jenkins_pull_ci.py (+1/-1) tests/unit/__init__.py (+22/-0) tests/unit/test_ci_project_import.py (+8/-47) tests/unit/test_jenkins_build_import.py (+99/-103) tests/unit/test_jenkins_utilities.py (+0/-74) tests/unit/test_launchpad_project_import.py (+6/-8) |
To merge this branch: | bzr merge lp:~allanlesage/helipad/test-fixes |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
helipad-team | Pending | ||
Review via email:
|
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Chris Johnston (cjohnston) wrote : | # |
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Allan LeSage (allanlesage) wrote : | # |
Chris would you tell me how you're running your tests? I just want to be sure that I have the same env set up.
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Chris Johnston (cjohnston) wrote : | # |
Production like env. Using postgres.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'tests/__init__.py' |
2 | --- tests/__init__.py 2013-07-16 17:11:09 +0000 |
3 | +++ tests/__init__.py 2013-07-26 16:05:52 +0000 |
4 | @@ -12,3 +12,8 @@ |
5 | |
6 | # You should have received a copy of the GNU Affero General Public License |
7 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
8 | + |
9 | +#from test_jenkins_pull_ci import * |
10 | +#from extractor import * |
11 | +#from integration import * |
12 | +from unit import * |
13 | |
14 | === modified file 'tests/extractor/__init__.py' |
15 | --- tests/extractor/__init__.py 2013-07-16 17:11:09 +0000 |
16 | +++ tests/extractor/__init__.py 2013-07-26 16:05:52 +0000 |
17 | @@ -12,3 +12,11 @@ |
18 | |
19 | # You should have received a copy of the GNU Affero General Public License |
20 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
21 | + |
22 | +from test_jenkins_build import * |
23 | +from test_jenkins_job import * |
24 | +from test_jenkins_test_report import * |
25 | +from test_extractor import * |
26 | +from test_jenkins_coverage import * |
27 | +from test_jenkins_run import * |
28 | +from test_jenkins_test_report import * |
29 | |
30 | === modified file 'tests/integration/__init__.py' |
31 | --- tests/integration/__init__.py 2013-07-16 17:11:09 +0000 |
32 | +++ tests/integration/__init__.py 2013-07-26 16:05:52 +0000 |
33 | @@ -12,3 +12,11 @@ |
34 | |
35 | # You should have received a copy of the GNU Affero General Public License |
36 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
37 | + |
38 | +from test_django_jenkins_build import * |
39 | +from test_jenkins_build import * |
40 | +from test_jenkins_job import * |
41 | +from test_view_build import * |
42 | +from test_view_daily_release_overview import * |
43 | +from test_view_index import * |
44 | +from test_view_stack import * |
45 | |
46 | === modified file 'tests/test_jenkins_pull_ci.py' |
47 | --- tests/test_jenkins_pull_ci.py 2013-07-19 16:19:58 +0000 |
48 | +++ tests/test_jenkins_pull_ci.py 2013-07-26 16:05:52 +0000 |
49 | @@ -146,7 +146,7 @@ |
50 | 'name': 'fake_stack_name', |
51 | 'series': 'fake series', |
52 | 'ppa': 'fake_ppa', |
53 | - 'server': 'http://10.97.0.1:8080', |
54 | + 'server': 'http://10.97.2.10:8080', |
55 | 'job': 'cu2d-fake_stack_name-fake_release'} |
56 | with patch('ci.management.commands.jenkins_pull_ci.create_cu2d_stack_from_config') \ |
57 | as create_cu2d_stack_from_config: |
58 | |
59 | === modified file 'tests/unit/__init__.py' |
60 | --- tests/unit/__init__.py 2013-07-16 17:11:09 +0000 |
61 | +++ tests/unit/__init__.py 2013-07-26 16:05:52 +0000 |
62 | @@ -12,3 +12,25 @@ |
63 | |
64 | # You should have received a copy of the GNU Affero General Public License |
65 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
66 | + |
67 | +from test_build import * |
68 | +from test_ci_project_import import * |
69 | +from test_ci_project import * |
70 | +from test_cu2d_stack_import import * |
71 | +from test_cu2d_stack import * |
72 | +from test_heuristics import * |
73 | +from test_jenkins_build_import import * |
74 | +from test_jenkins_build import * |
75 | +from test_jenkins_coverage_report_import import * |
76 | +from test_jenkins_coverage_report import * |
77 | +from test_jenkins_flavor import * |
78 | +from test_jenkins_job_import import * |
79 | +from test_jenkins_job import * |
80 | +from test_jenkins_result import * |
81 | +from test_jenkins_run_import import * |
82 | +from test_jenkins_run import * |
83 | +from test_jenkins_test_report_import import * |
84 | +from test_launchpad_project_import import * |
85 | +from test_launchpad_project import * |
86 | +from test_release import * |
87 | +from test_series import * |
88 | |
89 | === modified file 'tests/unit/test_ci_project_import.py' |
90 | --- tests/unit/test_ci_project_import.py 2013-07-16 17:29:47 +0000 |
91 | +++ tests/unit/test_ci_project_import.py 2013-07-26 16:05:52 +0000 |
92 | @@ -32,57 +32,18 @@ |
93 | self.logger_patch.stop() |
94 | |
95 | |
96 | -class TestCreateFromName(CiProjectManagerTestCase): |
97 | - |
98 | - def test_vanilla(self): |
99 | - dummy_ci_project_name = 'fake-ci-project' |
100 | - launchpad_project_get = MagicMock() |
101 | - with patch('ci.models.LaunchpadProject.objects.get', |
102 | - launchpad_project_get), \ |
103 | - patch('ci.models.CiProject.objects.create') as ci_project_create: |
104 | - result = util_ci_project.create_ci_project_from_name( |
105 | - name=dummy_ci_project_name) |
106 | - ci_project_create.assert_called_with( |
107 | - name=dummy_ci_project_name) |
108 | - launchpad_project_get.assert_called_with( |
109 | - name=dummy_ci_project_name) |
110 | - # TODO come back and assert on ci_project_launchpad_project_add |
111 | - |
112 | - def test_launchpad_project_doesnt_exist(self): |
113 | - dummy_ci_project_name = 'fake-ci-project' |
114 | - ci_project_create = MagicMock() |
115 | - launchpad_project_get = MagicMock( |
116 | - side_effect=LaunchpadProject.DoesNotExist) |
117 | - with patch('ci.models.LaunchpadProject.objects.get', |
118 | - launchpad_project_get), \ |
119 | - patch('ci.models.CiProject.objects.create', |
120 | - ci_project_create), \ |
121 | - patch('ci.util.ci_project.create_launchpad_project_from_name'): |
122 | - result = util_ci_project.create_ci_project_from_name( |
123 | - name=dummy_ci_project_name) |
124 | - ci_project_create.assert_called_with( |
125 | - name=dummy_ci_project_name) |
126 | - launchpad_project_get.assert_called_with( |
127 | - name=dummy_ci_project_name) |
128 | - # TODO come back and assert on ci_project_launchpad_project_add |
129 | - |
130 | - |
131 | - |
132 | -class TestCreateFromConfig(CiProjectManagerTestCase): |
133 | - |
134 | - def test_vanilla(self): |
135 | +class TestCreate(CiProjectManagerTestCase): |
136 | + |
137 | + def test_vanilla(self): |
138 | + ci_project_get_or_create = MagicMock( |
139 | + return_value=(MagicMock(), False)) |
140 | with patch('ci.models.Cu2dStack.objects.get'), \ |
141 | patch('ci.models.Release.objects.get'), \ |
142 | - patch('ci.util.ci_project.create_ci_project_from_name') as \ |
143 | - create_ci_project_from_name, \ |
144 | patch('ci.util.ci_project.create_jenkins_job_from_name') as \ |
145 | jenkins_job_create_from_name, \ |
146 | - patch('ci.models.CiProject.objects.get') as \ |
147 | - ci_project_get: |
148 | - create_ci_project_from_name.return_value = MagicMock( |
149 | - stack="fake_stack", |
150 | - release="fake_release") |
151 | - result = util_ci_project.create_ci_project_from_config( |
152 | + patch('ci.models.CiProject.objects.get_or_create', |
153 | + ci_project_get_or_create): |
154 | + result = util_ci_project.create_ci_project( |
155 | {'name': 'fake_name', |
156 | 'stack': 'fake_stack', |
157 | 'release': 'fake_release', |
158 | |
159 | === modified file 'tests/unit/test_jenkins_build_import.py' |
160 | --- tests/unit/test_jenkins_build_import.py 2013-07-16 17:29:47 +0000 |
161 | +++ tests/unit/test_jenkins_build_import.py 2013-07-26 16:05:52 +0000 |
162 | @@ -16,7 +16,6 @@ |
163 | from mock import MagicMock, patch |
164 | from django.test import TestCase |
165 | from django.db import IntegrityError |
166 | -from unittest import skip |
167 | from ci.models import JenkinsJob, JenkinsBuild |
168 | import ci.util.extractor as extractor |
169 | import ci.util.jenkins_build as util_jenkins_build |
170 | @@ -76,19 +75,29 @@ |
171 | |
172 | def test_vanilla(self): |
173 | get_text_from_url = MagicMock(side_effect=EnvironmentError) |
174 | - get_json_from_url = MagicMock(side_effect=EnvironmentError) |
175 | - jenkins_result_get_or_create = MagicMock(return_value=('fake_success_result', False)) |
176 | - with patch('ci.util.extractor.JenkinsBuild') as extractor_jenkins_build, \ |
177 | - patch('ci.util.extractor.get_downstream_builds_from_build'), \ |
178 | - patch('ci.util.extractor.get_text_from_url', get_text_from_url), \ |
179 | - patch('ci.util.extractor.get_json_from_url', get_text_from_url), \ |
180 | - patch('ci.models.JenkinsResult.objects.get_or_create', |
181 | - jenkins_result_get_or_create): |
182 | + jenkins_result_get_or_create = MagicMock( |
183 | + return_value=('fake_success_result', False), |
184 | + ) |
185 | + with patch( |
186 | + 'ci.util.extractor.JenkinsBuild', |
187 | + ) as extractor_jenkins_build, patch( |
188 | + 'ci.util.extractor.get_downstream_builds_from_build', |
189 | + ), patch( |
190 | + 'ci.util.extractor.get_text_from_url', |
191 | + get_text_from_url, |
192 | + ), patch( |
193 | + 'ci.util.extractor.get_json_from_url', |
194 | + get_text_from_url, |
195 | + ), patch( |
196 | + 'ci.models.JenkinsResult.objects.get_or_create', |
197 | + jenkins_result_get_or_create, |
198 | + ): |
199 | extractor_jenkins_build.return_value.number = 42 |
200 | extractor_jenkins_build.return_value.timestamp = 'fake_timestamp' |
201 | - result = util_jenkins_build.create_jenkins_build_from_url( |
202 | + util_jenkins_build.create_jenkins_build_from_url( |
203 | self.dummy_url, |
204 | - self.dummy_jenkins_job) |
205 | + self.dummy_jenkins_job, |
206 | + ) |
207 | self.jenkins_build_objects_create.assert_called_with( |
208 | jenkins_job=self.dummy_jenkins_job, |
209 | url=self.dummy_url, |
210 | @@ -98,7 +107,7 @@ |
211 | |
212 | def test_url_is_blacklisted(self): |
213 | url = "http://10.97.2.10:8080/job/share-app-raring-armhf-ci/17/" |
214 | - blacklist_jobs = ['raring',] |
215 | + blacklist_jobs = ['raring', ] |
216 | with patch('ci.util.jenkins_build.BLACKLIST_JOBS', blacklist_jobs): |
217 | result = util_jenkins_build.create_jenkins_build_from_url( |
218 | url, self.dummy_jenkins_job) |
219 | @@ -107,7 +116,10 @@ |
220 | def test_extractor_build_barfs_on_us_properly(self): |
221 | url = "http://10.97.2.10:8080/job/share-app-raring-armhf-ci/17/" |
222 | extractor_jenkins_build_mock = MagicMock(side_effect=Exception) |
223 | - with patch('ci.util.extractor.JenkinsBuild', extractor_jenkins_build_mock): |
224 | + with patch( |
225 | + 'ci.util.extractor.JenkinsBuild', |
226 | + extractor_jenkins_build_mock, |
227 | + ): |
228 | extractor_jenkins_build_mock.return_value.result = None |
229 | result = util_jenkins_build.create_jenkins_build_from_url( |
230 | url, self.dummy_jenkins_job) |
231 | @@ -117,20 +129,35 @@ |
232 | """This probably means the build is running.""" |
233 | |
234 | url = "http://10.97.2.10:8080/job/share-app-raring-armhf-ci/17/" |
235 | - with patch('ci.util.extractor.JenkinsBuild') as extractor_jenkins_build_mock: |
236 | + with patch( |
237 | + 'ci.util.extractor.JenkinsBuild', |
238 | + ) as extractor_jenkins_build_mock: |
239 | extractor_jenkins_build_mock.return_value.result = None |
240 | result = util_jenkins_build.create_jenkins_build_from_url( |
241 | - url, self.dummy_jenkins_job) |
242 | + url, self.dummy_jenkins_job, |
243 | + ) |
244 | self.assertIsNone(result) |
245 | |
246 | def test_build_duplicate_integrity_error(self): |
247 | util_jenkins_build.create = MagicMock(side_effect=IntegrityError) |
248 | get_coverage_report = MagicMock(side_effect=EnvironmentError) |
249 | - jenkins_result_get_or_create = MagicMock(return_value=('fake_success_result', False)) |
250 | - with patch('ci.util.extractor.JenkinsBuild') as extractor_jenkins_build, \ |
251 | - patch('ci.util.extractor.get_downstream_builds_from_build_url'), \ |
252 | - patch('ci.util.extractor.get_coverage_report', get_coverage_report), \ |
253 | - patch('ci.models.JenkinsResult.objects.get_or_create', jenkins_result_get_or_create): |
254 | + jenkins_result_get_or_create = MagicMock( |
255 | + return_value=( |
256 | + 'fake_success_result', |
257 | + False, |
258 | + ), |
259 | + ) |
260 | + with patch( |
261 | + 'ci.util.extractor.JenkinsBuild', |
262 | + ) as extractor_jenkins_build, patch( |
263 | + 'ci.util.extractor.get_downstream_builds_from_build_url', |
264 | + ), patch( |
265 | + 'ci.util.extractor.get_coverage_report', |
266 | + get_coverage_report, |
267 | + ), patch( |
268 | + 'ci.models.JenkinsResult.objects.get_or_create', |
269 | + jenkins_result_get_or_create, |
270 | + ): |
271 | extractor_jenkins_build.return_value.number = 42 |
272 | extractor_jenkins_build.return_value.timestamp = 'fake_timestamp' |
273 | result = util_jenkins_build.create_jenkins_build_from_url( |
274 | @@ -146,22 +173,34 @@ |
275 | def test_extractor_build_result_is_none(self): |
276 | """Weird but extractor returns None for result b/c no builds at all.""" |
277 | |
278 | - self.jenkins_build_objects_create = MagicMock(side_effect=IntegrityError) |
279 | + self.jenkins_build_objects_create = MagicMock( |
280 | + side_effect=IntegrityError, |
281 | + ) |
282 | jenkins_result_get_or_create = MagicMock(side_effect=IntegrityError) |
283 | - with patch('ci.util.extractor.JenkinsBuild') as extractor_jenkins_build, \ |
284 | - patch('ci.models.JenkinsResult.objects.get_or_create', jenkins_result_get_or_create): |
285 | + with patch( |
286 | + 'ci.util.extractor.JenkinsBuild', |
287 | + ) as extractor_jenkins_build, patch( |
288 | + 'ci.models.JenkinsResult.objects.get_or_create', |
289 | + jenkins_result_get_or_create, |
290 | + ): |
291 | result = util_jenkins_build.create_jenkins_build_from_url( |
292 | - self.dummy_url, self.dummy_jenkins_job) |
293 | + self.dummy_url, |
294 | + self.dummy_jenkins_job, |
295 | + ) |
296 | self.assertIsNone(result) |
297 | |
298 | |
299 | class TestCreateDownstreamBuilds(JenkinsBuildManagerTestCase): |
300 | |
301 | - @skip |
302 | def test_vanilla(self): |
303 | - get_downstream_builds_from_build = MagicMock(return_value=[extractor.BuildUrl( |
304 | - url='http://s-jenkins:8080/job/mir-raring-i386-autolanding/3', |
305 | - number=3)]) |
306 | + get_downstream_builds_from_build = MagicMock( |
307 | + return_value=[ |
308 | + extractor.BuildUrl( |
309 | + url='http://jenkins/job/mir-raring-i386-autolanding/3', |
310 | + number=3, |
311 | + ), |
312 | + ], |
313 | + ) |
314 | extractor_build = MagicMock() |
315 | extractor_build.job_name = 'mir-raring-i386-autolanding' |
316 | extractor_build.number = 3 |
317 | @@ -170,25 +209,41 @@ |
318 | jenkins_build_get = MagicMock(return_value="fake_downstream_build") |
319 | ci_jenkins_build = MagicMock() |
320 | ci_extractor_build = MagicMock() |
321 | - with patch('ci.util.extractor.get_downstream_builds_from_build', get_downstream_builds_from_build), \ |
322 | - patch('ci.util.extractor.JenkinsBuild', jenkins_build_mock), \ |
323 | - patch('ci.models.JenkinsJob.objects.get', jenkins_job_get), \ |
324 | - patch('ci.models.JenkinsBuild.objects.get', jenkins_build_get), \ |
325 | - patch.object(ci_jenkins_build, 'save') as ci_jenkins_build_save, \ |
326 | - patch.object(ci_jenkins_build, 'downstream_builds') as ci_jenkins_build_downstream_builds: |
327 | + with patch( |
328 | + 'ci.util.extractor.get_downstream_builds_from_build', |
329 | + get_downstream_builds_from_build, |
330 | + ), patch('ci.util.extractor.JenkinsBuild', jenkins_build_mock), patch( |
331 | + 'ci.models.JenkinsJob.objects.get', |
332 | + jenkins_job_get, |
333 | + ), patch( |
334 | + 'ci.models.JenkinsBuild.objects.get', |
335 | + jenkins_build_get, |
336 | + ), patch.object( |
337 | + ci_jenkins_build, |
338 | + 'save', |
339 | + ) as ci_jenkins_build_save, patch.object( |
340 | + ci_jenkins_build, |
341 | + 'downstream_builds', |
342 | + ) as ci_jenkins_build_downstream_builds: |
343 | ci_jenkins_build_downstream_builds.add = MagicMock() |
344 | - result = self.jenkins_build_manager._create_downstream_builds( |
345 | - ci_jenkins_build, ci_extractor_build) |
346 | + util_jenkins_build.create_downstream_builds( |
347 | + ci_jenkins_build, |
348 | + ci_extractor_build, |
349 | + ) |
350 | ci_jenkins_build_downstream_builds.add.assert_called_with( |
351 | - "fake_downstream_build") |
352 | + "fake_downstream_build", |
353 | + ) |
354 | ci_jenkins_build_save.assert_called() |
355 | |
356 | - |
357 | - @skip |
358 | def test_jenkins_job_create(self): |
359 | - get_downstream_builds_from_build = MagicMock(return_value=[extractor.BuildUrl( |
360 | - url='http://s-jenkins:8080/job/mir-raring-i386-autolanding/3', |
361 | - number=3)]) |
362 | + get_downstream_builds_from_build = MagicMock( |
363 | + return_value=[ |
364 | + extractor.BuildUrl( |
365 | + url='http://s-jenkins:8080/job/mir-raring-i386-autolanding/3', |
366 | + number=3, |
367 | + ), |
368 | + ], |
369 | + ) |
370 | extractor_build = MagicMock() |
371 | extractor_build.job_name = 'mir-raring-i386-autolanding' |
372 | extractor_build.number = 3 |
373 | @@ -204,71 +259,12 @@ |
374 | patch('ci.models.JenkinsBuild.objects.get', jenkins_build_get), \ |
375 | patch.object(ci_jenkins_build, 'save') as ci_jenkins_build_save, \ |
376 | patch.object(ci_jenkins_build, 'downstream_builds') as ci_jenkins_build_downstream_builds, \ |
377 | - patch('ci.util.jenkins.create_jenkins_job_from_name') as jenkins_job_create_from_name: |
378 | + patch('ci.util.jenkins_job.create_jenkins_job_from_name') as jenkins_job_create_from_name: |
379 | ci_jenkins_build_downstream_builds.add = MagicMock() |
380 | - result = self.jenkins_build_manager._create_downstream_builds( |
381 | + result = util_jenkins_build.create_downstream_builds( |
382 | ci_jenkins_build, ci_extractor_build) |
383 | jenkins_job_create_from_name.assert_called_with( |
384 | 'http://s-jenkins:8080', name='mir-raring-i386-autolanding') |
385 | ci_jenkins_build_downstream_builds.add.assert_called_with( |
386 | "fake_downstream_build") |
387 | ci_jenkins_build_save.assert_called() |
388 | - |
389 | - |
390 | - @skip |
391 | - def test_jenkins_build_create(self): |
392 | - get_downstream_builds_from_build = MagicMock(return_value=[extractor.BuildUrl( |
393 | - url='http://s-jenkins:8080/job/mir-raring-i386-autolanding/3', |
394 | - number=3)]) |
395 | - extractor_build = MagicMock() |
396 | - extractor_build.job_name = 'mir-raring-i386-autolanding' |
397 | - extractor_build.number = 3 |
398 | - jenkins_build_mock = MagicMock(return_value=extractor_build) |
399 | - jenkins_job_get = MagicMock(return_value=self.dummy_jenkins_job) |
400 | - jenkins_build_get = MagicMock(side_effect=JenkinsBuild.DoesNotExist) |
401 | - jenkins_build_create_from_name_and_number = MagicMock(return_value='fake_jenkins_build') |
402 | - ci_jenkins_build = MagicMock() |
403 | - ci_extractor_build = MagicMock() |
404 | - ci_extractor_build.url = 'http://s-jenkins:8080/job/fake_jenkins_build/3' |
405 | - with patch('ci.util.extractor.get_downstream_builds_from_build', get_downstream_builds_from_build), \ |
406 | - patch('ci.util.extractor.JenkinsBuild', jenkins_build_mock), \ |
407 | - patch('ci.models.JenkinsJob.objects.get', jenkins_job_get), \ |
408 | - patch('ci.models.JenkinsBuild.objects.get', jenkins_build_get), \ |
409 | - patch.object(ci_jenkins_build, 'save') as ci_jenkins_build_save, \ |
410 | - patch.object(ci_jenkins_build, 'downstream_builds') as ci_jenkins_build_downstream_builds, \ |
411 | - patch('ci.models.JenkinsBuild.objects.create_from_name_and_number', |
412 | - jenkins_build_create_from_name_and_number): |
413 | - ci_jenkins_build_downstream_builds.add = MagicMock() |
414 | - result = self.jenkins_build_manager._create_downstream_builds( |
415 | - ci_jenkins_build, ci_extractor_build) |
416 | - jenkins_build_create_from_name_and_number.assert_called_with( |
417 | - 'http://s-jenkins:8080', 'mir-raring-i386-autolanding', 3) |
418 | - ci_jenkins_build_downstream_builds.add.assert_called_with( |
419 | - "fake_jenkins_build") |
420 | - ci_jenkins_build_save.assert_called() |
421 | - |
422 | - |
423 | -class TestCreateFromNameAndNumber(JenkinsBuildManagerTestCase): |
424 | - |
425 | - @skip |
426 | - def test_vanilla(self): |
427 | - jenkins_build_url = 'http://fake.jenkins.build.url/uhhuh/' |
428 | - jenkins_job_get = MagicMock(return_value=self.dummy_jenkins_job) |
429 | - extractor_get_build_url = MagicMock(return_value=jenkins_build_url) |
430 | - with patch('ci.models.JenkinsJob.objects.get', jenkins_job_get), \ |
431 | - patch('ci.models.JenkinsBuildManager.create_from_url') as jenkins_build_manager_create_from_url, \ |
432 | - patch('ci.util.extractor.get_build_url', |
433 | - extractor_get_build_url): |
434 | - result = self.jenkins_build_manager.create_from_name_and_number( |
435 | - 'http://s-jenkins:8080', 'louis-autolanding', 14) |
436 | - jenkins_build_manager_create_from_url.assert_called_with( |
437 | - jenkins_build_url, self.dummy_jenkins_job) |
438 | - |
439 | - |
440 | - @skip |
441 | - def test_blacklisted(self): |
442 | - blacklist_jobs = ['louis',] |
443 | - with patch('ci.models.BLACKLIST_JOBS', blacklist_jobs): |
444 | - result = self.jenkins_build_manager.create_from_name_and_number( |
445 | - 'http://s-jenkins:8080', 'louis-autolanding', 14) |
446 | - self.assertIsNone(result) |
447 | |
448 | === removed file 'tests/unit/test_jenkins_utilities.py' |
449 | --- tests/unit/test_jenkins_utilities.py 2013-07-16 17:11:09 +0000 |
450 | +++ tests/unit/test_jenkins_utilities.py 1970-01-01 00:00:00 +0000 |
451 | @@ -1,74 +0,0 @@ |
452 | -# QA Dashboard |
453 | -# Copyright 2012-2013 Canonical Ltd. |
454 | - |
455 | -# This program is free software: you can redistribute it and/or modify it |
456 | -# under the terms of the GNU Affero General Public License version 3, as |
457 | -# published by the Free Software Foundation. |
458 | - |
459 | -# This program is distributed in the hope that it will be useful, but |
460 | -# WITHOUT ANY WARRANTY; without even the implied warranties of |
461 | -# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
462 | -# PURPOSE. See the GNU Affero General Public License for more details. |
463 | - |
464 | -# You should have received a copy of the GNU Affero General Public License |
465 | -# along with this program. If not, see <http://www.gnu.org/licenses/>. |
466 | - |
467 | -from mock import call, MagicMock, patch |
468 | -import json |
469 | -import os.path |
470 | -import unittest |
471 | -from ci.util.extractor import get_json_from_url, get_text_from_url |
472 | - |
473 | -"""Tests for module JenkinsUtilites""" |
474 | - |
475 | -DATA_PATH = "tests/data" |
476 | - |
477 | - |
478 | -class JenkinsUtilitiesTestCase(unittest.TestCase): |
479 | - """Unit tests for JenkinsUtilities methods""" |
480 | - |
481 | - def setUp(self): |
482 | - self.get_mock = MagicMock(return_value=type('fake_request', |
483 | - (object,), |
484 | - {'status_code': 200, |
485 | - 'text': '{"value": 42}'})) |
486 | - |
487 | - def test_get_json_from_url(self): |
488 | - url = "http://localhost/foo/" |
489 | - data = None |
490 | - with patch('requests.get', self.get_mock): |
491 | - data = get_json_from_url(url) |
492 | - self.assertEqual(data['value'], 42) |
493 | - self.assertEqual(self.get_mock.call_args, call(url + "/api/json")) |
494 | - |
495 | - def test_get_json_from_url_none(self): |
496 | - url = "http://localhost/foo/" |
497 | - mock = MagicMock(return_value=type('fake_request', |
498 | - (object,), |
499 | - {'status_code': 404, |
500 | - 'text': 'null'})) |
501 | - with patch('requests.get', mock): |
502 | - with self.assertRaises(EnvironmentError) as err: |
503 | - get_json_from_url(url) |
504 | - self.assertEqual("No json data at http://localhost/foo//api/json", |
505 | - "%s" % (err.exception)) |
506 | - |
507 | - def test_get_text_from_url(self): |
508 | - url = "http://localhost/foo/" |
509 | - data = None |
510 | - with patch('requests.get', self.get_mock): |
511 | - data = get_text_from_url(url) |
512 | - self.assertEqual(data, '{"value": 42}') |
513 | - self.assertEqual(self.get_mock.call_args, call(url)) |
514 | - |
515 | - def test_get_text_from_url_none(self): |
516 | - url = "http://localhost/foo/" |
517 | - mock = MagicMock(return_value=type('fake_request', |
518 | - (object,), |
519 | - {'status_code': 404, |
520 | - 'text': 'null'})) |
521 | - with patch('requests.get', mock): |
522 | - with self.assertRaises(EnvironmentError) as err: |
523 | - get_text_from_url(url) |
524 | - self.assertEqual("No data at http://localhost/foo/", |
525 | - "%s" % (err.exception)) |
526 | |
527 | === modified file 'tests/unit/test_launchpad_project_import.py' |
528 | --- tests/unit/test_launchpad_project_import.py 2013-07-16 17:11:09 +0000 |
529 | +++ tests/unit/test_launchpad_project_import.py 2013-07-26 16:05:52 +0000 |
530 | @@ -13,8 +13,6 @@ |
531 | # You should have received a copy of the GNU Affero General Public License |
532 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
533 | |
534 | - |
535 | -from unittest import skip |
536 | from mock import MagicMock, patch, call |
537 | from django.test import TestCase |
538 | from ci.models import LaunchpadProject |
539 | @@ -31,23 +29,23 @@ |
540 | self.logger_patch.stop() |
541 | |
542 | # TODO restore this when we're really dealing with Launchpad |
543 | - @skip |
544 | def test_vanilla(self): |
545 | dummy_launchpad_project_name = 'fake-ci-project' |
546 | dummy_launchpad_project_url = 'http://this.is.an.official.lp.url/really/' |
547 | + launchpad_project_get_or_create = MagicMock( |
548 | + return_value=(MagicMock(), False)) |
549 | # TODO this could be miraculously clearer :) |
550 | lp = MagicMock( |
551 | return_value=MagicMock( |
552 | projects={dummy_launchpad_project_name: |
553 | MagicMock(web_link=dummy_launchpad_project_url)})) |
554 | with patch('launchpadlib.launchpad.Launchpad.login_with', lp), \ |
555 | - patch('ci.models.LaunchpadProject.objects.create') as launchpad_project_create: |
556 | + patch('ci.models.LaunchpadProject.objects.get_or_create', |
557 | + launchpad_project_get_or_create): |
558 | result = util_launchpad_project.create_launchpad_project_from_name( |
559 | name=dummy_launchpad_project_name) |
560 | - launchpad_project_create.assert_called_with( |
561 | - name=dummy_launchpad_project_name, |
562 | - url=dummy_launchpad_project_url) |
563 | - # TODO need to actually check for the url attribute |
564 | + launchpad_project_get_or_create.assert_called_with( |
565 | + name=dummy_launchpad_project_name) |
566 | |
567 | def test_naming(self): |
568 | launchpad_project_get_or_create = MagicMock( |
I'm seeing:
======= ======= ======= ======= ======= ======= ======= ======= ======= ======= integration_ status_ fail_build (ci.tests. unit.test_ heuristics. TestHeuristics) ------- ------- ------- ------- ------- ------- ------- ------- ------- chris/dashboard /some-ci- reviews/ ci/tests/ unit/test_ heuristics. py", line 67, in test_get_ integration_ status_ fail_build assertEqual( ret, 'Failed build')
FAIL: test_get_
-------
Traceback (most recent call last):
File "/home/
self.
AssertionError: 'Build failed' != 'Failed build'
======= ======= ======= ======= ======= ======= ======= ======= ======= ======= integration_ status_ fail_check (ci.tests. unit.test_ heuristics. TestHeuristics) ------- ------- ------- ------- ------- ------- ------- ------- ------- chris/dashboard /some-ci- reviews/ ci/tests/ unit/test_ heuristics. py", line 74, in test_get_ integration_ status_ fail_check assertEqual( ret, 'Failed check')
FAIL: test_get_
-------
Traceback (most recent call last):
File "/home/
self.
AssertionError: 'Testing failed' != 'Failed check'
======= ======= ======= ======= ======= ======= ======= ======= ======= ======= integration_ status_ fail_prepare (ci.tests. unit.test_ heuristics. TestHeuristics) ------- ------- ------- ------- ------- ------- ------- ------- ------- chris/dashboard /some-ci- reviews/ ci/tests/ unit/test_ heuristics. py", line 60, in test_get_ integration_ status_ fail_prepare assertEqual( ret, 'Failed prepare')
FAIL: test_get_
-------
Traceback (most recent call last):
File "/home/
self.
AssertionError: 'Prepare failed' != 'Failed prepare'