Merge lp:~allenap/launchpad/add-rabbit-service-config-bug-803043 into lp:launchpad

Proposed by Gavin Panella
Status: Merged
Approved by: Gavin Panella
Approved revision: no longer in the source branch.
Merged at revision: 13379
Proposed branch: lp:~allenap/launchpad/add-rabbit-service-config-bug-803043
Merge into: lp:launchpad
Prerequisite: lp:~allenap/launchpad/lp-app-longpoll
Diff against target: 163 lines (+55/-9)
4 files modified
lib/canonical/testing/layers.py (+3/-7)
lib/lp/testing/fixture.py (+22/-0)
lib/lp/testing/tests/test_fixture.py (+29/-1)
versions.cfg (+1/-1)
To merge this branch: bzr merge lp:~allenap/launchpad/add-rabbit-service-config-bug-803043
Reviewer Review Type Date Requested Status
Gavin Panella (community) Approve
Review via email: mp+66930@code.launchpad.net

Commit message

[r=allenap][bug=803043] Move the Launchpad-specific parts of the RabbitServer fixture back from rabbitfixture into Launchpad.

Description of the change

Adds a RabbitServer subclass to the Launchpad tree, based on rabbitfixture's. It creates a service_config object in the same place as rabbitfixture did before version 0.2.

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
=== modified file 'lib/canonical/testing/layers.py'
--- lib/canonical/testing/layers.py 2011-07-04 03:10:41 +0000
+++ lib/canonical/testing/layers.py 2011-07-05 16:44:58 +0000
@@ -61,7 +61,6 @@
61import socket61import socket
62import subprocess62import subprocess
63import sys63import sys
64import tempfile
65from textwrap import dedent64from textwrap import dedent
66import threading65import threading
67import time66import time
@@ -75,9 +74,7 @@
75 Fixture,74 Fixture,
76 MonkeyPatch,75 MonkeyPatch,
77 )76 )
78from lazr.restful.utils import safe_hasattr
79import psycopg277import psycopg2
80from rabbitfixture.server import RabbitServer
81from storm.zope.interfaces import IZStorm78from storm.zope.interfaces import IZStorm
82import transaction79import transaction
83import wsgi_intercept80import wsgi_intercept
@@ -98,7 +95,6 @@
98from zope.security.management import getSecurityPolicy95from zope.security.management import getSecurityPolicy
99from zope.security.simplepolicies import PermissiveSecurityPolicy96from zope.security.simplepolicies import PermissiveSecurityPolicy
100from zope.server.logger.pythonlogger import PythonLogger97from zope.server.logger.pythonlogger import PythonLogger
101from zope.testing.testrunner.runner import FakeInputContinueGenerator
10298
103from canonical.config import (99from canonical.config import (
104 CanonicalConfig,100 CanonicalConfig,
@@ -131,7 +127,6 @@
131 register_launchpad_request_publication_factories,127 register_launchpad_request_publication_factories,
132 )128 )
133import canonical.launchpad.webapp.session129import canonical.launchpad.webapp.session
134from canonical.launchpad.webapp.vhosts import allvhosts
135from canonical.lazr import pidfile130from canonical.lazr import pidfile
136from canonical.lazr.testing.layers import MockRootFolder131from canonical.lazr.testing.layers import MockRootFolder
137from canonical.lazr.timeout import (132from canonical.lazr.timeout import (
@@ -156,6 +151,7 @@
156 login,151 login,
157 logout,152 logout,
158 )153 )
154from lp.testing.fixture import RabbitServer
159from lp.testing.pgsql import PgTestSetup155from lp.testing.pgsql import PgTestSetup
160156
161157
@@ -733,8 +729,8 @@
733 if os.environ.get('LP_TEST_INSTANCE'):729 if os.environ.get('LP_TEST_INSTANCE'):
734 template_name = '_'.join([LaunchpadTestSetup.template,730 template_name = '_'.join([LaunchpadTestSetup.template,
735 os.environ.get('LP_TEST_INSTANCE')])731 os.environ.get('LP_TEST_INSTANCE')])
736 cls._db_template_fixture = LaunchpadTestSetup(dbname=template_name,732 cls._db_template_fixture = LaunchpadTestSetup(
737 reset_sequences_sql=reset_sequences_sql)733 dbname=template_name, reset_sequences_sql=reset_sequences_sql)
738 cls._db_template_fixture.setUp()734 cls._db_template_fixture.setUp()
739 else:735 else:
740 template_name = LaunchpadTestSetup.template736 template_name = LaunchpadTestSetup.template
741737
=== modified file 'lib/lp/testing/fixture.py'
--- lib/lp/testing/fixture.py 2011-07-05 16:44:57 +0000
+++ lib/lp/testing/fixture.py 2011-07-05 16:44:58 +0000
@@ -5,12 +5,16 @@
55
6__metaclass__ = type6__metaclass__ = type
7__all__ = [7__all__ = [
8 'RabbitServer',
8 'ZopeAdapterFixture',9 'ZopeAdapterFixture',
9 'ZopeEventHandlerFixture',10 'ZopeEventHandlerFixture',
10 'ZopeViewReplacementFixture',11 'ZopeViewReplacementFixture',
11 ]12 ]
1213
14from textwrap import dedent
15
13from fixtures import Fixture16from fixtures import Fixture
17import rabbitfixture.server
14from zope.component import (18from zope.component import (
15 getGlobalSiteManager,19 getGlobalSiteManager,
16 provideHandler,20 provideHandler,
@@ -24,6 +28,24 @@
24 )28 )
2529
2630
31class RabbitServer(rabbitfixture.server.RabbitServer):
32 """A RabbitMQ server fixture with Launchpad-specific config.
33
34 :ivar service_config: A snippet of .ini that describes the `rabbitmq`
35 configuration.
36 """
37
38 def setUp(self):
39 super(RabbitServer, self).setUp()
40 self.config.service_config = dedent("""\
41 [rabbitmq]
42 host: localhost:%d
43 userid: guest
44 password: guest
45 virtual_host: /
46 """ % self.config.port)
47
48
27class ZopeAdapterFixture(Fixture):49class ZopeAdapterFixture(Fixture):
28 """A fixture to register and unregister an adapter."""50 """A fixture to register and unregister an adapter."""
2951
3052
=== modified file 'lib/lp/testing/tests/test_fixture.py'
--- lib/lp/testing/tests/test_fixture.py 2011-07-05 16:44:57 +0000
+++ lib/lp/testing/tests/test_fixture.py 2011-07-05 16:44:58 +0000
@@ -5,6 +5,9 @@
55
6__metaclass__ = type6__metaclass__ = type
77
8from textwrap import dedent
9
10from fixtures import EnvironmentVariableFixture
8from zope.component import (11from zope.component import (
9 adapts,12 adapts,
10 queryAdapter,13 queryAdapter,
@@ -16,7 +19,32 @@
1619
17from canonical.testing.layers import BaseLayer20from canonical.testing.layers import BaseLayer
18from lp.testing import TestCase21from lp.testing import TestCase
19from lp.testing.fixture import ZopeAdapterFixture22from lp.testing.fixture import (
23 RabbitServer,
24 ZopeAdapterFixture,
25 )
26
27
28class TestRabbitServer(TestCase):
29
30 layer = BaseLayer
31
32 def test_service_config(self):
33 # Rabbit needs to fully isolate itself: an existing per user
34 # .erlange.cookie has to be ignored, and ditto bogus HOME if other
35 # tests fail to cleanup.
36 self.useFixture(EnvironmentVariableFixture('HOME', '/nonsense/value'))
37
38 # RabbitServer pokes some .ini configuration into its config.
39 with RabbitServer() as fixture:
40 expected = dedent("""\
41 [rabbitmq]
42 host: localhost:%d
43 userid: guest
44 password: guest
45 virtual_host: /
46 """ % fixture.config.port)
47 self.assertEqual(expected, fixture.config.service_config)
2048
2149
22class IFoo(Interface):50class IFoo(Interface):
2351
=== modified file 'versions.cfg'
--- versions.cfg 2011-07-04 10:48:28 +0000
+++ versions.cfg 2011-07-05 16:44:58 +0000
@@ -65,7 +65,7 @@
65pytz = 2010o65pytz = 2010o
66rdflib = 3.1.066rdflib = 3.1.0
67RestrictedPython = 3.5.167RestrictedPython = 3.5.1
68rabbitfixture = 0.168rabbitfixture = 0.2.1
69roman = 1.4.069roman = 1.4.0
70# See http://code.google.com/p/selenium/issues/detail?id=1935 .70# See http://code.google.com/p/selenium/issues/detail?id=1935 .
71selenium = 2.0rc3-lp-distribute-fix71selenium = 2.0rc3-lp-distribute-fix