~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/testing/tests/test_fixture.py

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

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 
6
6
__metaclass__ = type
7
7
 
 
8
from textwrap import dedent
 
9
 
 
10
from fixtures import EnvironmentVariableFixture
8
11
from zope.component import (
9
12
    adapts,
10
13
    queryAdapter,
16
19
 
17
20
from canonical.testing.layers import BaseLayer
18
21
from lp.testing import TestCase
19
 
from lp.testing.fixture import ZopeAdapterFixture
 
22
from lp.testing.fixture import (
 
23
    RabbitServer,
 
24
    ZopeAdapterFixture,
 
25
    )
 
26
 
 
27
 
 
28
class 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)
20
48
 
21
49
 
22
50
class IFoo(Interface):