~unity-2d-team/unity-2d/Shell-MultiMonitor

« back to all changes in this revision

Viewing changes to grackle/tests/test_client.py

  • Committer: Aaron Bentley
  • Date: 2012-01-16 16:29:12 UTC
  • mto: (6.1.30 trunk)
  • mto: This revision was merged to the branch mainline in revision 45.
  • Revision ID: aaron@canonical.com-20120116162912-cc760p6gn7q5qdwr
Switch test HTTP server to standard Python logging.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
    BaseHTTPRequestHandler,
4
4
    )
5
5
import httplib
 
6
import logging
6
7
import os
7
8
from signal import SIGKILL
8
9
import simplejson
9
10
from StringIO import StringIO
 
11
import sys
10
12
from unittest import TestCase
11
13
from urlparse import urlparse
12
14
from urlparse import parse_qs
142
144
            for message in messages:
143
145
                message.setdefault('headers', {})
144
146
        self.is_ready()
 
147
#        logging.basicConfig(
 
148
#            stream=sys.stderr, level=logging.INFO)
145
149
        service.serve_forever()
146
150
 
147
151
    def __exit__(self, exc_type, exc_val, traceback):
155
159
 
156
160
class FakeGrackleRequestHandler(BaseHTTPRequestHandler):
157
161
 
 
162
    def __init__(self, *args, **kwargs):
 
163
        self.logger = logging.getLogger('http')
 
164
        BaseHTTPRequestHandler.__init__(self, *args, **kwargs)
 
165
 
158
166
    def do_POST(self):
159
167
        message = self.rfile.read(int(self.headers['content-length']))
160
168
        if message == 'This is a message':
180
188
                self.wfile.write('Unsupported order')
181
189
                return
182
190
 
 
191
    def log_message(self, format, *args):
 
192
        message = "%s - - [%s] %s\n" % (
 
193
            self.address_string(), self.log_date_time_string(), format%args)
 
194
        self.logger.info(message)
 
195
 
183
196
 
184
197
class TestPutMessage(TestCase):
185
198