1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# Copyright 2011 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Tests for lp.services.rabbit.TxLongPollServer."""
__metaclass__ = type
from ConfigParser import SafeConfigParser
import os
from StringIO import StringIO
from canonical.config import config
from canonical.testing.layers import RabbitMQLayer
from lp.services.txlongpoll.server import TxLongPollServer
from lp.testing import TestCase
class TestTxLongPollServer(TestCase):
layer = RabbitMQLayer
def test_service_config(self):
# TxLongPollServer pokes some .ini configuration into its
# service_config attributes.
twistd_bin = os.path.join(
config.root, 'bin', 'twistd-for-txlongpoll')
fixture = self.useFixture(TxLongPollServer(
broker_user='guest', broker_password='guest', broker_vhost='/',
broker_port=123, frontend_port=None,
twistd_bin=twistd_bin))
service_config = SafeConfigParser()
service_config.readfp(StringIO(getattr(fixture, 'service_config')))
self.assertEqual(["txlongpoll"], service_config.sections())
# txlongpoll section
expected = {
"frontend_port": "%d" % fixture.config.frontend_port,
}
observed = dict(service_config.items("txlongpoll"))
self.assertEqual(expected, observed)
|