~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/services/txlongpoll/server.py

  • Committer: Raphael Badin
  • Date: 2011-09-27 07:58:30 UTC
  • mto: (14032.1.8 longpoll-uri-request)
  • mto: This revision was merged to the branch mainline in revision 14084.
  • Revision ID: raphael.badin@canonical.com-20110927075830-184lvmuqhab58jw5
Add TxLongPollServer.

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
"""TxLongPoll server fixture."""
 
5
 
 
6
__metaclass__ = type
 
7
__all__ = [
 
8
    'TxLongPollServer',
 
9
    ]
 
10
 
 
11
from textwrap import dedent
 
12
 
 
13
from txlongpollfixture.server import TxLongPollFixture
 
14
from rabbitfixture.server import RabbitServer
 
15
 
 
16
 
 
17
class TxLongPollServer(TxLongPollFixture):
 
18
    """A TxLongPoll server fixture with Launchpad-specific config.
 
19
 
 
20
    :ivar service_config: A snippet of .ini that describes the `txlongpoll`
 
21
        configuration.
 
22
    """
 
23
 
 
24
    def setUp(self):
 
25
        super(TxLongPollServer, self).setUp()
 
26
        self.rabbitserver = RabbitServer()
 
27
        self.useFixture(self.rabbitserver)
 
28
        self.config['service_config'] = dedent("""\
 
29
            [rabbitmq]
 
30
            host: localhost:%d
 
31
            userid: guest
 
32
            password: guest
 
33
            virtual_host: /
 
34
 
 
35
            [txlongpoll]
 
36
            frontend_port: %d
 
37
            """ % (
 
38
                self.rabbitserver.config.port,
 
39
                self.config['frontend_port']))