Merge lp:~jml/pkgme-service/juju-integration-tests into lp:pkgme-service
- juju-integration-tests
- Merge into trunk
Status: | Work in progress |
---|---|
Proposed branch: | lp:~jml/pkgme-service/juju-integration-tests |
Merge into: | lp:pkgme-service |
Diff against target: |
678 lines (+304/-150) 13 files modified
fabtasks/django.py (+8/-0) src/djpkgme/bigtests/__init__.py (+6/-0) src/djpkgme/bigtests/test_integration.py (+136/-7) src/djpkgme/bigtests/test_tasks.py (+121/-0) src/djpkgme/tasks.py (+6/-1) src/djpkgme/testing/__init__.py (+1/-0) src/djpkgme/testing/factory.py (+6/-6) src/djpkgme/testing/helpers.py (+11/-27) src/djpkgme/tests/__init__.py (+0/-1) src/djpkgme/tests/test_handlers.py (+2/-2) src/djpkgme/tests/test_tasks.py (+2/-106) tarmac_tests.sh (+1/-0) test-dependencies.txt (+4/-0) |
To merge this branch: | bzr merge lp:~jml/pkgme-service/juju-integration-tests |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Canonical Consumer Applications Hackers | Pending | ||
Review via email: mp+114606@code.launchpad.net |
Commit message
Move testing helpers to new testing package.
Description of the change
Move testing helpers to new testing package.
- 102. By Jonathan Lange
-
Move the big & slow tests to a different package so they are not run by default.
- 103. By Jonathan Lange
-
Make sure we run all the tests when we land branches.
- 104. By Jonathan Lange
-
Need this to land things
- 105. By Jonathan Lange
-
Initial (broken) attempt at running the integration tests with juju
- 106. By Jonathan Lange
-
disable commits
- 107. By Jonathan Lange
-
Test that deploys a service and then destroys service.
- 108. By Jonathan Lange
-
RED: Add a test that starts to actually use the juju charm.
Point out errors and how to fix them.
Make a get_ip_address thing on the Juju fixture.
Unmerged revisions
- 108. By Jonathan Lange
-
RED: Add a test that starts to actually use the juju charm.
Point out errors and how to fix them.
Make a get_ip_address thing on the Juju fixture. - 107. By Jonathan Lange
-
Test that deploys a service and then destroys service.
- 106. By Jonathan Lange
-
disable commits
- 105. By Jonathan Lange
-
Initial (broken) attempt at running the integration tests with juju
- 104. By Jonathan Lange
-
Need this to land things
- 103. By Jonathan Lange
-
Make sure we run all the tests when we land branches.
- 102. By Jonathan Lange
-
Move the big & slow tests to a different package so they are not run by default.
- 101. By Jonathan Lange
-
Don't import Django by default.
- 100. By Jonathan Lange
-
Replace cargo culted settings patch with monkey patch helper.
- 99. By Jonathan Lange
-
Move test helpers to separate package.
Preview Diff
1 | === modified file 'fabtasks/django.py' |
2 | --- fabtasks/django.py 2012-04-12 18:58:30 +0000 |
3 | +++ fabtasks/django.py 2012-07-13 08:21:21 +0000 |
4 | @@ -12,6 +12,14 @@ |
5 | spec = "djpkgme" |
6 | manage("test", spec) |
7 | |
8 | + |
9 | +def bigtests(): |
10 | + """Run the big tests.""" |
11 | + local( |
12 | + "DJANGO_SETTINGS_MODULE=django_project.settings " |
13 | + "virtualenv/bin/python -m testtools.run discover djpkgme.bigtests") |
14 | + |
15 | + |
16 | def runserver(port=8001): |
17 | manage("runserver", str(port)) |
18 | |
19 | |
20 | === added directory 'src/djpkgme/bigtests' |
21 | === added file 'src/djpkgme/bigtests/__init__.py' |
22 | --- src/djpkgme/bigtests/__init__.py 1970-01-01 00:00:00 +0000 |
23 | +++ src/djpkgme/bigtests/__init__.py 2012-07-13 08:21:21 +0000 |
24 | @@ -0,0 +1,6 @@ |
25 | +"""Big tests. Or medium tests. |
26 | + |
27 | +http://googletesting.blogspot.co.uk/2010/12/test-sizes.html |
28 | +""" |
29 | + |
30 | +from .test_integration import * |
31 | |
32 | === renamed file 'src/djpkgme/tests/test_integration.py' => 'src/djpkgme/bigtests/test_integration.py' |
33 | --- src/djpkgme/tests/test_integration.py 2012-03-26 17:44:03 +0000 |
34 | +++ src/djpkgme/bigtests/test_integration.py 2012-07-13 08:21:21 +0000 |
35 | @@ -8,6 +8,7 @@ |
36 | URLError, |
37 | urlopen, |
38 | ) |
39 | +import uuid |
40 | |
41 | from fixtures import ( |
42 | EnvironmentVariableFixture, |
43 | @@ -26,11 +27,12 @@ |
44 | Contains, |
45 | Equals, |
46 | ) |
47 | +from testtools import TestCase |
48 | from twisted.internet.error import TimeoutError |
49 | |
50 | from devportalbinary.testing import DatabaseFixture |
51 | from djpkgme.harness import WebServer |
52 | -from djpkgme.tests.factory import ( |
53 | +from djpkgme.testing.factory import ( |
54 | get_acceptance_data_path, |
55 | TestCaseWithFactory, |
56 | ) |
57 | @@ -191,6 +193,101 @@ |
58 | self.poll_until_running(self.port) |
59 | |
60 | |
61 | +class CommandFailed(Exception): |
62 | + |
63 | + def __init__(self, command, returncode, output, error): |
64 | + super(CommandFailed, self).__init__(command, returncode, output, error) |
65 | + self.command = command |
66 | + self.returncode = returncode |
67 | + self.output = output |
68 | + self.error = error |
69 | + |
70 | + def __str__(self): |
71 | + return "%s failed with returncode %s. Output:\n%s\nError:\n%s" % ( |
72 | + ' '.join(self.command), |
73 | + self.returncode, |
74 | + '\n'.join(' | %s' % (line,) |
75 | + for line in self.output.splitlines()), |
76 | + '\n'.join(' | %s' % (line,) |
77 | + for line in self.error.splitlines()), |
78 | + ) |
79 | + |
80 | + |
81 | +def run_script(*command): |
82 | + p = subprocess.Popen( |
83 | + command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
84 | + out, err = p.communicate() |
85 | + if p.returncode: |
86 | + raise CommandFailed(command, p.returncode, out, err) |
87 | + return out |
88 | + |
89 | + |
90 | +class JujuService(Fixture): |
91 | + |
92 | + # XXX: Need to handle charms from the store also. |
93 | + |
94 | + # XXX: Maybe the parameters should be a path to a charm? |
95 | + def __init__(self, charm_name, repository, service_name=None): |
96 | + super(JujuService, self) |
97 | + self.charm_name = charm_name |
98 | + self.repository = repository |
99 | + if service_name is None: |
100 | + service_name = '-'.join([charm_name, str(uuid.uuid4())]) |
101 | + self.service_name = service_name |
102 | + |
103 | + def get_ip_address(self): |
104 | + out = run_script('juju', 'status', self.service_name) |
105 | + for line in out.splitlines(): |
106 | + if 'public-address' in line: |
107 | + return line.split(':')[1].strip() |
108 | + raise ValueError("Could not find public address") |
109 | + |
110 | + def setUp(self): |
111 | + super(JujuService, self).setUp() |
112 | + # XXX: Block until actually running. Use jitsu. |
113 | + # jitsu watch pkgme-service --x-state=pending --num-units=1 |
114 | + # |
115 | + # XXX: Somehow get the debug log (and maybe the machine-agent.log?) |
116 | + # and attach as details. |
117 | + run_script( |
118 | + 'juju', 'deploy', '--repository', self.repository, |
119 | + 'local:%s' % (self.charm_name,), self.service_name) |
120 | + # XXX: Test this. |
121 | + self.addCleanup(run_script, 'juju', 'destroy-service', self.service_name) |
122 | + run_script( |
123 | + 'jitsu', 'watch', self.service_name, '--x-state=pending', |
124 | + '--num-units=1') |
125 | + # XXX: Extract into function |
126 | + status = run_script('juju', 'status', self.service_name) |
127 | + if 'agent-state: started' not in status: |
128 | + raise ValueError(status) |
129 | + |
130 | + |
131 | +class TestJuju(TestCase): |
132 | + |
133 | + def test_before_setup(self): |
134 | + pass |
135 | + |
136 | + def disabled_test_service(self): |
137 | + charm_name = 'pkgme-service' |
138 | + up = os.path.dirname |
139 | + charm_path = os.path.join(up(up(up(up(__file__)))), 'charms') |
140 | + s = JujuService(charm_name, charm_path) |
141 | + try: |
142 | + s.setUp() |
143 | + out = run_script('juju', 'status', s.service_name) |
144 | + # XXX: Terrible assertion. Fragile, as we are going to be sharing |
145 | + # this environment with other things. |
146 | + self.assertIn(charm_name, out) |
147 | + self.assertIn('agent-state: started', out) |
148 | + finally: |
149 | + s.cleanUp() |
150 | + out = run_script('juju', 'status', s.service_name) |
151 | + # XXX: Terrible assertion. Fragile, as we are going to be sharing |
152 | + # this environment with other things. |
153 | + self.assertNotIn(s.service_name, out) |
154 | + |
155 | + |
156 | class TestEndToEnd(TestCaseWithFactory): |
157 | """Full end-to-end tests. |
158 | |
159 | @@ -216,7 +313,7 @@ |
160 | return AfterPreprocessing( |
161 | lambda x: x['packaged_app_url'], Equals(url)) |
162 | |
163 | - def expect_success(self, metadata, file_path, body_matcher): |
164 | + def expect_success(self, pkgme_url, metadata, file_path, body_matcher): |
165 | """Package 'file_path' with 'metadata' and expect success. |
166 | |
167 | :param metadata: A dict of metadata, such as would be submitted from a |
168 | @@ -224,8 +321,7 @@ |
169 | :param file_path: A path to a file on disk to upload for packaging. |
170 | :param body_matcher: A Matcher that the parsed JSON body must match. |
171 | """ |
172 | - self.set_up_pkgme_service() |
173 | - harness = WebServer(file_path) |
174 | + harness = WebServer(file_path, pkgme_url) |
175 | d = harness.run(metadata) |
176 | def callback_received((method, json_body)): |
177 | body = json.loads(json_body) |
178 | @@ -259,7 +355,7 @@ |
179 | d.addBoth(harness.shut_down_web_server) |
180 | return d |
181 | |
182 | - def test_gtk(self): |
183 | + def disable_test_gtk(self): |
184 | package_name = self.factory.get_unique_string('package-name') |
185 | metadata = { |
186 | 'package_name': package_name, |
187 | @@ -278,13 +374,46 @@ |
188 | self.packaged_app_url_equals( |
189 | get_url_for_file('%s.tar.gz' % (package_name,)))) |
190 | |
191 | - def test_error_when_packaging(self): |
192 | + def test_juju(self): |
193 | + package_name = self.factory.get_unique_string('package-name') |
194 | + metadata = { |
195 | + 'package_name': package_name, |
196 | + 'description': self.factory.get_unique_string('description'), |
197 | + 'tagline': self.factory.get_unique_string('tagline'), |
198 | + 'myapps_id': self.factory.get_unique_integer(), |
199 | + } |
200 | + tarball_path = self.factory.make_tarball( |
201 | + get_acceptance_data_path('gtk')) |
202 | + |
203 | + charm_name = 'pkgme-service' |
204 | + up = os.path.dirname |
205 | + charm_path = os.path.join(up(up(up(up(__file__)))), 'charms') |
206 | + pkgme_service = self.useFixture(JujuService(charm_name, charm_path)) |
207 | + |
208 | + pkgme_url = 'http://%s/pkgme/api/1.0' % (pkgme_service.get_ip_address(),) |
209 | + |
210 | + # Sets the home dir. Yuck. |
211 | + pkg_db = self.useFixture(DatabaseFixture()) |
212 | + |
213 | + self.factory.add_dependencies_for_test_data(pkg_db) |
214 | + |
215 | + # XXX: This fails because pkgme-service isn't actually actually |
216 | + # running. It needs a postgresql instance to be up and running and to |
217 | + # have the postgresql:db relation hooked up to it. To do this, we |
218 | + # need a fixture that will fire up charms from the store, rather than |
219 | + # simply local charms and a way to add interfaces. |
220 | + return self.expect_success( |
221 | + pkgme_url, metadata, tarball_path, |
222 | + self.packaged_app_url_equals( |
223 | + get_url_for_file('%s.tar.gz' % (package_name,)))) |
224 | + |
225 | + def disable_test_error_when_packaging(self): |
226 | metadata = self.factory.make_metadata() |
227 | tarball_path = self.factory.make_tarball( |
228 | get_acceptance_data_path('python')) |
229 | return self.expect_error(metadata, tarball_path, Contains('error')) |
230 | |
231 | - def test_pdf(self): |
232 | + def disable_test_pdf(self): |
233 | metadata = { |
234 | 'package_name': "jabberwocky", |
235 | 'description': "The Jabberwocky", |
236 | |
237 | === added file 'src/djpkgme/bigtests/test_tasks.py' |
238 | --- src/djpkgme/bigtests/test_tasks.py 1970-01-01 00:00:00 +0000 |
239 | +++ src/djpkgme/bigtests/test_tasks.py 2012-07-13 08:21:21 +0000 |
240 | @@ -0,0 +1,121 @@ |
241 | +import os |
242 | +import tarfile |
243 | + |
244 | +from fixtures import TempDir |
245 | +from pkgme.info_elements import PackageName |
246 | +from pkgme.testing import ( |
247 | + DirContains, |
248 | + DirExists, |
249 | + ) |
250 | +# In lucid, python-debian exports its package as 'debian_bundle'. |
251 | +from testtools import try_imports |
252 | +changelog = try_imports(['debian.changelog', 'debian_bundle.changelog']) |
253 | + |
254 | +from devportalbinary.metadata import MetadataBackend |
255 | +from devportalbinary.testing import DatabaseFixture |
256 | + |
257 | +# XXX: This will probably require us to use the django runner for bigtests. |
258 | +from django.conf import settings |
259 | + |
260 | +from djpkgme import tasks |
261 | +from djpkgme.tasks import BuildPackageTask |
262 | +from djpkgme.testing.factory import TestCaseWithFactory |
263 | +from djpkgme.testing.helpers import patch_settings |
264 | + |
265 | + |
266 | +class TestBuildPackageTaskIntegration(TestCaseWithFactory): |
267 | + """Tests that actually build the package.""" |
268 | + |
269 | + def run_task(self, metadata, file_path): |
270 | + task = BuildPackageTask() |
271 | + def download_file(url, output_dir): |
272 | + # Create a tarball and stick it in 'output_dir'. |
273 | + proper_location = os.path.join( |
274 | + output_dir, os.path.basename(file_path)) |
275 | + os.rename(file_path, proper_location) |
276 | + return proper_location |
277 | + self.patch(tasks, 'download_file', download_file) |
278 | + pkg_db = self.useFixture(DatabaseFixture()) |
279 | + self.factory.add_dependencies_for_test_data(pkg_db) |
280 | + temp_dir = self.useFixture(TempDir()).path |
281 | + self.patch(settings, 'PKGME_OUTPUT_DIRECTORY', temp_dir) |
282 | + return task.build_package(metadata, {}) |
283 | + |
284 | + def disable_test_writes_packaging_for_tarball(self): |
285 | + # BuildPackageTask.build_package runs pkgme to build the package and |
286 | + # outputs a tarball to the given path. Here we're testing the happy |
287 | + # case. |
288 | + metadata = self.factory.make_metadata() |
289 | + package_name = metadata['package_name'] |
290 | + unpack_dir = self.useFixture(TempDir()).path |
291 | + output_tar_path = self.run_task( |
292 | + metadata, self.factory.make_packagable_tarball()) |
293 | + output_tar = tarfile.open(output_tar_path, 'r:gz') |
294 | + try: |
295 | + output_tar.extractall(unpack_dir) |
296 | + finally: |
297 | + output_tar.close() |
298 | + self.assertThat( |
299 | + unpack_dir, |
300 | + DirContains( |
301 | + ['%s_0.dsc' % (package_name,), |
302 | + '%s_0.tar.gz' % (package_name,), |
303 | + '%s_0_source.build' % (package_name,), |
304 | + '%s_0_source.changes' % (package_name,), |
305 | + MetadataBackend.METADATA_FILE, |
306 | + ])) |
307 | + package_tarball_path = os.path.join( |
308 | + unpack_dir, '%s_0.tar.gz' % (package_name,)) |
309 | + t = tarfile.open(package_tarball_path) |
310 | + try: |
311 | + t.extractall(unpack_dir) |
312 | + finally: |
313 | + t.close() |
314 | + debian_dir = os.path.join(unpack_dir, package_name, 'debian') |
315 | + self.assertThat(debian_dir, DirExists()) |
316 | + # Assert that it has some packaging, but not all of the details about |
317 | + |
318 | + |
319 | + # exactly what packaging it creates. |
320 | + self.assertIn('control', os.listdir(debian_dir)) |
321 | + |
322 | + def disable_test_uses_cleaned_package_name_for_tarball_name(self): |
323 | + # BuildPackageTask.build_package uses the cleaned version of the |
324 | + # package name as the tarball name. |
325 | + # Set up the metadata with no package_name and no |
326 | + # suggested_package_name so that it will use 'name' instead. |
327 | + name = 'hopefully unique application name' |
328 | + metadata = self.factory.make_metadata(application_name=name) |
329 | + del metadata['package_name'] |
330 | + del metadata['suggested_package_name'] |
331 | + output_tar_path = self.run_task( |
332 | + metadata, self.factory.make_packagable_tarball()) |
333 | + basename = os.path.basename(output_tar_path) |
334 | + cleaned_package_name = PackageName.clean(name) |
335 | + self.assertEqual("%s.tar.gz" % cleaned_package_name, basename) |
336 | + |
337 | + def disable_test_uses_pkgme_maintainer_email(self): |
338 | + unpack_dir = self.useFixture(TempDir()).path |
339 | + metadata = self.factory.make_metadata() |
340 | + debemail = 'Dude <dude@example.com>' |
341 | + with patch_settings(PKGME_MAINTAINER_EMAIL=debemail): |
342 | + output_tar_path = self.run_task( |
343 | + metadata, self.factory.make_packagable_tarball()) |
344 | + output_tar = tarfile.open(output_tar_path, 'r:gz') |
345 | + try: |
346 | + output_tar.extractall(unpack_dir) |
347 | + finally: |
348 | + output_tar.close() |
349 | + package_name = metadata['package_name'] |
350 | + package_tarball_path = os.path.join( |
351 | + unpack_dir, '%s_0.tar.gz' % (package_name,)) |
352 | + t = tarfile.open(package_tarball_path) |
353 | + try: |
354 | + t.extractall(unpack_dir) |
355 | + finally: |
356 | + t.close() |
357 | + debian_dir = os.path.join(unpack_dir, package_name, 'debian') |
358 | + changelog_path = os.path.join(debian_dir, 'changelog') |
359 | + cl = changelog.Changelog(open(changelog_path).read()) |
360 | + [change_block] = list(cl) |
361 | + self.assertEqual(debemail, change_block.author) |
362 | |
363 | === modified file 'src/djpkgme/tasks.py' |
364 | --- src/djpkgme/tasks.py 2012-06-14 15:23:26 +0000 |
365 | +++ src/djpkgme/tasks.py 2012-07-13 08:21:21 +0000 |
366 | @@ -10,6 +10,7 @@ |
367 | |
368 | from bzrlib.urlutils import join as urljoin |
369 | from celery.registry import tasks |
370 | +from celery.signals import worker_process_init |
371 | from celery.task import Task |
372 | from django.conf import settings |
373 | from httplib2 import Http |
374 | @@ -532,4 +533,8 @@ |
375 | tasks.register(CauseOopsTask) |
376 | |
377 | |
378 | -setup_oops_reporter(config_from_dict(settings.OOPSES)) |
379 | +def connect_to_oops(*args, **kwargs): |
380 | + setup_oops_reporter(config_from_dict(settings.OOPSES)) |
381 | + |
382 | + |
383 | +worker_process_init.connect(connect_to_oops) |
384 | |
385 | === added directory 'src/djpkgme/testing' |
386 | === added file 'src/djpkgme/testing/__init__.py' |
387 | --- src/djpkgme/testing/__init__.py 1970-01-01 00:00:00 +0000 |
388 | +++ src/djpkgme/testing/__init__.py 2012-07-13 08:21:21 +0000 |
389 | @@ -0,0 +1,1 @@ |
390 | +"""Things to aid testing.""" |
391 | |
392 | === renamed file 'src/djpkgme/tests/factory.py' => 'src/djpkgme/testing/factory.py' |
393 | --- src/djpkgme/tests/factory.py 2012-03-04 15:05:47 +0000 |
394 | +++ src/djpkgme/testing/factory.py 2012-07-13 08:21:21 +0000 |
395 | @@ -3,7 +3,6 @@ |
396 | import tarfile |
397 | |
398 | from devportalbinary.metadata import MetadataBackend |
399 | -from django.test import TestCase as DjangoTestCase |
400 | from fixtures import ( |
401 | Fixture, |
402 | TempDir, |
403 | @@ -12,6 +11,7 @@ |
404 | RunTest, |
405 | TestCase, |
406 | ) |
407 | +from .helpers import patch_settings |
408 | |
409 | __all__ = [ |
410 | 'TestCaseWithFactory', |
411 | @@ -121,13 +121,13 @@ |
412 | Use this runner to get that same effect with testtools. |
413 | """ |
414 | |
415 | - class MyDjangoTestCase(DjangoTestCase): |
416 | - def test_foo(self): |
417 | - pass |
418 | - |
419 | def __init__(self, case, handlers=None): |
420 | super(DjangoRunner, self).__init__(case, handlers=handlers) |
421 | - self._django_case = self.MyDjangoTestCase('test_foo') |
422 | + from django.test import TestCase as DjangoTestCase |
423 | + class MyDjangoTestCase(DjangoTestCase): |
424 | + def test_foo(self): |
425 | + pass |
426 | + self._django_case = MyDjangoTestCase('test_foo') |
427 | |
428 | def _run_core(self): |
429 | self._run_user(self._django_case._pre_setup) |
430 | |
431 | === renamed file 'src/djpkgme/tests/helpers.py' => 'src/djpkgme/testing/helpers.py' |
432 | --- src/djpkgme/tests/helpers.py 2012-02-28 13:49:09 +0000 |
433 | +++ src/djpkgme/testing/helpers.py 2012-07-13 08:21:21 +0000 |
434 | @@ -1,5 +1,8 @@ |
435 | -from django.conf import settings |
436 | -from contextlib import contextmanager |
437 | +from contextlib import ( |
438 | + contextmanager, |
439 | + nested, |
440 | + ) |
441 | +from fixtures import MonkeyPatch |
442 | |
443 | |
444 | class FakeResponse(dict): |
445 | @@ -14,29 +17,10 @@ |
446 | self.previous = previous |
447 | |
448 | |
449 | -# Original snippet from http://djangosnippets.org/snippets/2156/ |
450 | -class SettingDoesNotExist: |
451 | - pass |
452 | - |
453 | - |
454 | -def switch_settings(**kwargs): |
455 | - """Helper method that updates settings and returns old settings.""" |
456 | - old_settings = {} |
457 | - for key, new_value in kwargs.items(): |
458 | - old_value = getattr(settings, key, SettingDoesNotExist) |
459 | - old_settings[key] = old_value |
460 | - |
461 | - if new_value is SettingDoesNotExist: |
462 | - delattr(settings, key) |
463 | - else: |
464 | - setattr(settings, key, new_value) |
465 | - |
466 | - return old_settings |
467 | - |
468 | - |
469 | @contextmanager |
470 | -def patch_settings(**kwargs): |
471 | - old_settings = switch_settings(**kwargs) |
472 | - yield |
473 | - switch_settings(**old_settings) |
474 | -# end snippet |
475 | +def patch_settings(**settings): |
476 | + fixtures = [ |
477 | + MonkeyPatch('django.conf.settings.%s' % (name,), value) |
478 | + for name, value in settings.items()] |
479 | + with nested(*fixtures): |
480 | + yield |
481 | |
482 | === modified file 'src/djpkgme/tests/__init__.py' |
483 | --- src/djpkgme/tests/__init__.py 2012-02-29 21:33:25 +0000 |
484 | +++ src/djpkgme/tests/__init__.py 2012-07-13 08:21:21 +0000 |
485 | @@ -1,5 +1,4 @@ |
486 | from .test_handlers import * |
487 | from .test_harness import * |
488 | -from .test_integration import * |
489 | from .test_preflight import * |
490 | from .test_tasks import * |
491 | |
492 | === modified file 'src/djpkgme/tests/test_handlers.py' |
493 | --- src/djpkgme/tests/test_handlers.py 2012-03-12 14:10:27 +0000 |
494 | +++ src/djpkgme/tests/test_handlers.py 2012-07-13 08:21:21 +0000 |
495 | @@ -8,8 +8,8 @@ |
496 | PackageHandler, |
497 | VersionHandler, |
498 | ) |
499 | -from djpkgme.tests.factory import TestCaseWithFactory |
500 | -from djpkgme.tests.helpers import FakeResponse |
501 | +from djpkgme.testing.factory import TestCaseWithFactory |
502 | +from djpkgme.testing.helpers import FakeResponse |
503 | |
504 | |
505 | test_metadata = { |
506 | |
507 | === modified file 'src/djpkgme/tests/test_tasks.py' |
508 | --- src/djpkgme/tests/test_tasks.py 2012-07-10 11:30:50 +0000 |
509 | +++ src/djpkgme/tests/test_tasks.py 2012-07-13 08:21:21 +0000 |
510 | @@ -9,19 +9,13 @@ |
511 | import traceback |
512 | import zipfile |
513 | |
514 | -# In lucid, python-debian exports its package as 'debian_bundle'. |
515 | -from testtools import try_imports |
516 | -changelog = try_imports(['debian.changelog', 'debian_bundle.changelog']) |
517 | - |
518 | from devportalbinary.metadata import MetadataBackend |
519 | from django.conf import settings |
520 | from fixtures import TempDir |
521 | import mock |
522 | from mock import patch |
523 | from pkgme.errors import PkgmeError |
524 | -from pkgme.info_elements import PackageName |
525 | from pkgme.testing import ( |
526 | - DirContains, |
527 | DirExists, |
528 | FileContains, |
529 | ) |
530 | @@ -33,7 +27,6 @@ |
531 | ) |
532 | from testtools import TestCase |
533 | |
534 | -from devportalbinary.testing import DatabaseFixture |
535 | from djpkgme import tasks |
536 | from djpkgme.tasks import ( |
537 | as_pkgme_dict, |
538 | @@ -44,10 +37,10 @@ |
539 | submit_to_myapps, |
540 | translate_dict, |
541 | ) |
542 | -from djpkgme.tests.factory import ( |
543 | +from djpkgme.testing.factory import ( |
544 | TestCaseWithFactory, |
545 | ) |
546 | -from djpkgme.tests.helpers import ( |
547 | +from djpkgme.testing.helpers import ( |
548 | FakeResponse, |
549 | patch_settings, |
550 | ) |
551 | @@ -641,100 +634,3 @@ |
552 | task = BuildPackageTask() |
553 | prepared = task.prepare_metadata(path, metadata) |
554 | self.assertEqual(expected, prepared) |
555 | - |
556 | - |
557 | - |
558 | -class TestBuildPackageTaskIntegration(TestCaseWithFactory): |
559 | - """Tests that actually build the package.""" |
560 | - |
561 | - def run_task(self, metadata, file_path): |
562 | - task = BuildPackageTask() |
563 | - def download_file(url, output_dir): |
564 | - # Create a tarball and stick it in 'output_dir'. |
565 | - proper_location = os.path.join( |
566 | - output_dir, os.path.basename(file_path)) |
567 | - os.rename(file_path, proper_location) |
568 | - return proper_location |
569 | - self.patch(tasks, 'download_file', download_file) |
570 | - pkg_db = self.useFixture(DatabaseFixture()) |
571 | - self.factory.add_dependencies_for_test_data(pkg_db) |
572 | - temp_dir = self.useFixture(TempDir()).path |
573 | - self.patch(settings, 'PKGME_OUTPUT_DIRECTORY', temp_dir) |
574 | - return task.build_package(metadata, {}) |
575 | - |
576 | - def test_writes_packaging_for_tarball(self): |
577 | - # BuildPackageTask.build_package runs pkgme to build the package and |
578 | - # outputs a tarball to the given path. Here we're testing the happy |
579 | - # case. |
580 | - metadata = self.factory.make_metadata() |
581 | - package_name = metadata['package_name'] |
582 | - unpack_dir = self.useFixture(TempDir()).path |
583 | - output_tar_path = self.run_task( |
584 | - metadata, self.factory.make_packagable_tarball()) |
585 | - output_tar = tarfile.open(output_tar_path, 'r:gz') |
586 | - try: |
587 | - output_tar.extractall(unpack_dir) |
588 | - finally: |
589 | - output_tar.close() |
590 | - self.assertThat( |
591 | - unpack_dir, |
592 | - DirContains( |
593 | - ['%s_0.dsc' % (package_name,), |
594 | - '%s_0.tar.gz' % (package_name,), |
595 | - '%s_0_source.build' % (package_name,), |
596 | - '%s_0_source.changes' % (package_name,), |
597 | - MetadataBackend.METADATA_FILE, |
598 | - ])) |
599 | - package_tarball_path = os.path.join( |
600 | - unpack_dir, '%s_0.tar.gz' % (package_name,)) |
601 | - t = tarfile.open(package_tarball_path) |
602 | - try: |
603 | - t.extractall(unpack_dir) |
604 | - finally: |
605 | - t.close() |
606 | - debian_dir = os.path.join(unpack_dir, package_name, 'debian') |
607 | - self.assertThat(debian_dir, DirExists()) |
608 | - # Assert that it has some packaging, but not all of the details about |
609 | - # exactly what packaging it creates. |
610 | - self.assertIn('control', os.listdir(debian_dir)) |
611 | - |
612 | - def test_uses_cleaned_package_name_for_tarball_name(self): |
613 | - # BuildPackageTask.build_package uses the cleaned version of the |
614 | - # package name as the tarball name. |
615 | - # Set up the metadata with no package_name and no |
616 | - # suggested_package_name so that it will use 'name' instead. |
617 | - name = 'hopefully unique application name' |
618 | - metadata = self.factory.make_metadata(application_name=name) |
619 | - del metadata['package_name'] |
620 | - del metadata['suggested_package_name'] |
621 | - output_tar_path = self.run_task( |
622 | - metadata, self.factory.make_packagable_tarball()) |
623 | - basename = os.path.basename(output_tar_path) |
624 | - cleaned_package_name = PackageName.clean(name) |
625 | - self.assertEqual("%s.tar.gz" % cleaned_package_name, basename) |
626 | - |
627 | - def test_uses_pkgme_maintainer_email(self): |
628 | - unpack_dir = self.useFixture(TempDir()).path |
629 | - metadata = self.factory.make_metadata() |
630 | - debemail = 'Dude <dude@example.com>' |
631 | - with patch_settings(PKGME_MAINTAINER_EMAIL=debemail): |
632 | - output_tar_path = self.run_task( |
633 | - metadata, self.factory.make_packagable_tarball()) |
634 | - output_tar = tarfile.open(output_tar_path, 'r:gz') |
635 | - try: |
636 | - output_tar.extractall(unpack_dir) |
637 | - finally: |
638 | - output_tar.close() |
639 | - package_name = metadata['package_name'] |
640 | - package_tarball_path = os.path.join( |
641 | - unpack_dir, '%s_0.tar.gz' % (package_name,)) |
642 | - t = tarfile.open(package_tarball_path) |
643 | - try: |
644 | - t.extractall(unpack_dir) |
645 | - finally: |
646 | - t.close() |
647 | - debian_dir = os.path.join(unpack_dir, package_name, 'debian') |
648 | - changelog_path = os.path.join(debian_dir, 'changelog') |
649 | - cl = changelog.Changelog(open(changelog_path).read()) |
650 | - [change_block] = list(cl) |
651 | - self.assertEqual(debemail, change_block.author) |
652 | |
653 | === modified file 'tarmac_tests.sh' |
654 | --- tarmac_tests.sh 2012-01-23 22:20:10 +0000 |
655 | +++ tarmac_tests.sh 2012-07-13 08:21:21 +0000 |
656 | @@ -5,3 +5,4 @@ |
657 | fab bootstrap > log |
658 | . ./virtualenv/bin/activate >> log |
659 | fab test |
660 | +fab bigtests |
661 | |
662 | === modified file 'test-dependencies.txt' |
663 | --- test-dependencies.txt 2012-04-26 12:02:00 +0000 |
664 | +++ test-dependencies.txt 2012-07-13 08:21:21 +0000 |
665 | @@ -1,9 +1,13 @@ |
666 | coverage |
667 | +discover |
668 | django-kombu |
669 | mock==0.8 |
670 | piston-mini-client==0.3 |
671 | testtools |
672 | twisted |
673 | +juju |
674 | +zc-zookeeper-static |
675 | +pyyaml |
676 | # These aren't test requirements, but we want to fetch these dependencies from |
677 | # bzr and this is the only way I can figure out how to do this -- jml |
678 | -e bzr+ssh://bazaar.launchpad.net/+branch/pkgme#egg=pkgme |
The attempt to merge lp:~jml/pkgme-service/juju-integration-tests into lp:pkgme-service failed. Below is the output from the failed tests.
error: Could not find suitable distribution for Requirement. parse(' bzr==2. 4.2')
Fatal error: local() encountered an error (return code 1) while executing 'virtualenv/ bin/python setup.py develop'
Aborting.