~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_wsgi.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-02-23 17:00:36 UTC
  • mfrom: (4032.1.4 jam-integration)
  • Revision ID: pqm@pqm.ubuntu.com-20090223170036-3q1v68ewdt8i0to5
(Marius Kruger) Remove all trailing whitespace and add tests to
        enforce this.

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
 
34
34
    def build_environ(self, updates=None):
35
35
        """Builds an environ dict with all fields required by PEP 333.
36
 
        
 
36
 
37
37
        :param updates: a dict to that will be incorporated into the returned
38
38
            dict using dict.update(updates).
39
39
        """
58
58
        if updates is not None:
59
59
            environ.update(updates)
60
60
        return environ
61
 
        
 
61
 
62
62
    def read_response(self, iterable):
63
63
        response = ''
64
64
        for string in iterable:
82
82
        self.read_response(iterable)
83
83
        self.assertEqual('405 Method not allowed', self.status)
84
84
        self.assertTrue(('Allow', 'POST') in self.headers)
85
 
        
 
85
 
86
86
    def _fake_make_request(self, transport, write_func, bytes, rcp):
87
87
        request = FakeRequest(transport, write_func)
88
88
        request.accept_bytes(bytes)
89
89
        self.request = request
90
90
        return request
91
 
    
 
91
 
92
92
    def test_smart_wsgi_app_uses_given_relpath(self):
93
93
        # The SmartWSGIApp should use the "bzrlib.relpath" field from the
94
94
        # WSGI environ to clone from its backing transport to get a specific
138
138
            fake_app, prefix='/abc/', path_var='FOO')
139
139
        wrapped_app({'FOO': '/abc/xyz/.bzr/smart'}, None)
140
140
        self.assertEqual(['xyz'], calls)
141
 
       
 
141
 
142
142
    def test_relpath_setter_bad_path_prefix(self):
143
143
        # wsgi.RelpathSetter will reject paths with that don't match the prefix
144
144
        # with a 404.  This is probably a sign of misconfiguration; a server
151
151
            {'FOO': 'AAA/abc/xyz/.bzr/smart'}, self.start_response)
152
152
        self.read_response(iterable)
153
153
        self.assertTrue(self.status.startswith('404'))
154
 
        
 
154
 
155
155
    def test_relpath_setter_bad_path_suffix(self):
156
156
        # Similar to test_relpath_setter_bad_path_prefix: wsgi.RelpathSetter
157
157
        # will reject paths with that don't match the suffix '.bzr/smart' with a
165
165
            {'FOO': '/abc/xyz/.bzr/AAA'}, self.start_response)
166
166
        self.read_response(iterable)
167
167
        self.assertTrue(self.status.startswith('404'))
168
 
        
 
168
 
169
169
    def test_make_app(self):
170
170
        # The make_app helper constructs a SmartWSGIApp wrapped in a
171
171
        # RelpathSetter.
243
243
 
244
244
 
245
245
class FakeRequest(object):
246
 
    
 
246
 
247
247
    def __init__(self, transport, write_func):
248
248
        self.transport = transport
249
249
        self.write_func = write_func