~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/tests/test_simple.py

  • Committer: Danilo Segan
  • Date: 2011-09-02 09:43:57 UTC
  • mto: This revision was merged to the branch mainline in revision 456.
  • Revision ID: danilo@canonical.com-20110902094357-a7lfkzns3gllv9hi
Make sure RevisionUI does not crash for non-existent files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
import cgi
19
19
import logging
20
20
import re
 
21
import simplejson
 
22
from cStringIO import StringIO
21
23
 
22
24
from bzrlib.tests import TestCaseWithTransport
23
25
try:
47
49
        branch_app = BranchWSGIApp(self.tree.branch, '', **kw).app
48
50
        return TestApp(HTTPExceptionHandler(branch_app))
49
51
 
 
52
    def assertOkJsonResponse(self, app, env):
 
53
        start, content = consume_app(app, env)
 
54
        self.assertEqual('200 OK', start[0])
 
55
        self.assertEqual('application/json', dict(start[1])['Content-Type'])
 
56
        self.assertEqual(None, start[2])
 
57
        simplejson.loads(content)
 
58
 
 
59
    def make_branch_app(self, branch):
 
60
        branch_app = BranchWSGIApp(branch, friendly_name='friendly-name')
 
61
        branch_app._environ = {
 
62
            'wsgi.url_scheme':'',
 
63
            'SERVER_NAME':'',
 
64
            'SERVER_PORT':'80',
 
65
            }
 
66
        branch_app._url_base = ''
 
67
        return branch_app
 
68
 
50
69
 
51
70
class TestWithSimpleTree(BasicTests):
52
71
 
228
247
        self.assertEqualDiff('', res.body)
229
248
 
230
249
 
 
250
def consume_app(app, env):
 
251
    body = StringIO()
 
252
    start = []
 
253
    def start_response(status, headers, exc_info=None):
 
254
        start.append((status, headers, exc_info))
 
255
        return body.write
 
256
    extra_content = list(app(env, start_response))
 
257
    body.writelines(extra_content)
 
258
    return start[0], body.getvalue()
 
259
 
 
260
 
 
261
 
231
262
#class TestGlobalConfig(BasicTests):
232
263
#    """
233
264
#    Test that global config settings are respected