~richies/+junk/standalone_auth

« back to all changes in this revision

Viewing changes to loggerhead/tests/test_simple.py

  • Committer: John Arbash Meinel
  • Date: 2011-03-19 08:35:57 UTC
  • mfrom: (422.3.2 head_middleware)
  • Revision ID: john@arbash-meinel.com-20110319083557-k8mbbkr3bzisz3ob
include HeadMiddleware so that we can be sure HEAD requests never return BODY content.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
from bzrlib import config
28
28
 
29
29
from loggerhead.apps.branch import BranchWSGIApp
 
30
from loggerhead.apps.http_head import HeadMiddleware
30
31
from paste.fixture import TestApp
31
32
from paste.httpexceptions import HTTPExceptionHandler, HTTPMovedPermanently
32
33
 
197
198
        e = self.assertRaises(HTTPMovedPermanently, app.get, '/files/head:/file')
198
199
        self.assertEqual(e.location(), '/view/head:/file')
199
200
 
 
201
 
 
202
class TestHeadMiddleware(BasicTests):
 
203
 
 
204
    def setUp(self):
 
205
        BasicTests.setUp(self)
 
206
        self.createBranch()
 
207
        self.msg = 'trivial commit message'
 
208
        self.revid = self.tree.commit(message=self.msg)
 
209
 
 
210
    def setUpLoggerhead(self, **kw):
 
211
        branch_app = BranchWSGIApp(self.tree.branch, '', **kw).app
 
212
        return TestApp(HTTPExceptionHandler(HeadMiddleware(branch_app)))
 
213
 
 
214
    def test_get(self):
 
215
        app = self.setUpLoggerhead()
 
216
        res = app.get('/changes')
 
217
        res.mustcontain(self.msg)
 
218
        self.assertEqual('text/html', res.header('Content-Type'))
 
219
 
 
220
    def test_head(self):
 
221
        app = self.setUpLoggerhead()
 
222
        res = app.get('/changes', extra_environ={'REQUEST_METHOD': 'HEAD'})
 
223
        self.assertEqual('text/html', res.header('Content-Type'))
 
224
        self.assertEqualDiff('', res.body)
 
225
 
 
226
 
200
227
#class TestGlobalConfig(BasicTests):
201
228
#    """
202
229
#    Test that global config settings are respected