~bzr/loggerhead/daily-ppa

« back to all changes in this revision

Viewing changes to loggerhead/tests/test_simple.py

  • Committer: Max Bowsher
  • Date: 2011-03-17 08:33:16 UTC
  • mfrom: (182.150.20 trunk-rich)
  • Revision ID: maxb@f2s.com-20110317083316-n5nq18tsaaxkskut
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007-2011 Canonical Ltd.
 
1
# Copyright (C) 2007, 2008, 2009, 2011 Canonical Ltd.
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
28
28
 
29
29
from loggerhead.apps.branch import BranchWSGIApp
30
30
from paste.fixture import TestApp
31
 
from paste.httpexceptions import HTTPExceptionHandler
 
31
from paste.httpexceptions import HTTPExceptionHandler, HTTPMovedPermanently
32
32
 
33
33
 
34
34
 
170
170
        res = app.get('/changes', status=404)
171
171
 
172
172
 
 
173
class TestControllerRedirects(BasicTests):
 
174
    """
 
175
    Test that a file under /files redirects to /view,
 
176
    and a directory under /view redirects to /files.
 
177
    """
 
178
 
 
179
    def setUp(self):
 
180
        BasicTests.setUp(self)
 
181
        self.createBranch()
 
182
        self.build_tree(('file', 'folder/', 'folder/file'))
 
183
        self.tree.smart_add([])
 
184
        self.tree.commit('')
 
185
 
 
186
    def test_view_folder(self):
 
187
        app = TestApp(BranchWSGIApp(self.tree.branch, '').app)
 
188
 
 
189
        e = self.assertRaises(HTTPMovedPermanently, app.get, '/view/head:/folder')
 
190
        self.assertEqual(e.location(), '/files/head:/folder')
 
191
 
 
192
    def test_files_file(self):
 
193
        app = TestApp(BranchWSGIApp(self.tree.branch, '').app)
 
194
 
 
195
        e = self.assertRaises(HTTPMovedPermanently, app.get, '/files/head:/folder/file')
 
196
        self.assertEqual(e.location(), '/view/head:/folder/file')
 
197
        e = self.assertRaises(HTTPMovedPermanently, app.get, '/files/head:/file')
 
198
        self.assertEqual(e.location(), '/view/head:/file')
 
199
 
173
200
#class TestGlobalConfig(BasicTests):
174
201
#    """
175
202
#    Test that global config settings are respected