~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/services/rabbit/tests/test_server.py

  • Committer: Jelmer Vernooij
  • Date: 2011-09-21 14:28:02 UTC
  • mfrom: (14006 devel)
  • mto: This revision was merged to the branch mainline in revision 14010.
  • Revision ID: jelmer@canonical.com-20110921142802-7ggkc204igsy532w
MergeĀ lp:launchpad

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright 2011 Canonical Ltd.  This software is licensed under the
 
2
# GNU Affero General Public License version 3 (see the file LICENSE).
 
3
 
 
4
"""Tests for lp.testing.fixture."""
 
5
 
 
6
__metaclass__ = type
 
7
 
 
8
from ConfigParser import SafeConfigParser
 
9
from StringIO import StringIO
 
10
 
 
11
from fixtures import EnvironmentVariableFixture
 
12
 
 
13
from canonical.testing.layers import BaseLayer
 
14
from lp.services.rabbit.server import RabbitServer
 
15
from lp.testing import TestCase
 
16
 
 
17
 
 
18
class TestRabbitServer(TestCase):
 
19
 
 
20
    layer = BaseLayer
 
21
 
 
22
    def test_service_config(self):
 
23
        # Rabbit needs to fully isolate itself: an existing per user
 
24
        # .erlang.cookie has to be ignored, and ditto bogus HOME if other
 
25
        # tests fail to cleanup.
 
26
        self.useFixture(EnvironmentVariableFixture('HOME', '/nonsense/value'))
 
27
 
 
28
        # RabbitServer pokes some .ini configuration into its config.
 
29
        fixture = self.useFixture(RabbitServer())
 
30
        service_config = SafeConfigParser()
 
31
        service_config.readfp(StringIO(fixture.config.service_config))
 
32
        self.assertEqual(["rabbitmq"], service_config.sections())
 
33
        expected = {
 
34
            "host": "localhost:%d" % fixture.config.port,
 
35
            "userid": "guest",
 
36
            "password": "guest",
 
37
            "virtual_host": "/",
 
38
            }
 
39
        observed = dict(service_config.items("rabbitmq"))
 
40
        self.assertEqual(expected, observed)