~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_smart_request.py

  • Committer: Martin Pool
  • Date: 2010-01-29 14:09:05 UTC
  • mto: This revision was merged to the branch mainline in revision 4992.
  • Revision ID: mbp@sourcefrog.net-20100129140905-2uiarb6p8di1ywsr
Correction to url

from review: https://code.edge.launchpad.net/~mbp/bzr/doc/+merge/18250

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2009 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
18
18
 
19
19
import threading
20
20
 
21
 
from bzrlib import (
22
 
    errors,
23
 
    transport,
24
 
    )
 
21
from bzrlib import errors
25
22
from bzrlib.bzrdir import BzrDir
26
23
from bzrlib.smart import request
27
24
from bzrlib.tests import TestCase, TestCaseWithMemoryTransport
 
25
from bzrlib.transport import get_transport
28
26
 
29
27
 
30
28
class NoBodyRequest(request.SmartServerRequest):
36
34
 
37
35
class DoErrorRequest(request.SmartServerRequest):
38
36
    """A request that raises an error from self.do()."""
39
 
 
 
37
    
40
38
    def do(self):
41
39
        raise errors.NoSuchFile('xyzzy')
42
40
 
174
172
 
175
173
 
176
174
class TestRequestJail(TestCaseWithMemoryTransport):
177
 
 
 
175
    
178
176
    def test_jail(self):
179
177
        transport = self.get_transport('blah')
180
178
        req = request.SmartServerRequest(transport)
205
203
        # A parent is not allowed
206
204
        self.assertRaises(errors.JailBreak, _pre_open_hook, t.clone('..'))
207
205
        # A completely unrelated transport is not allowed
208
 
        self.assertRaises(errors.JailBreak, _pre_open_hook,
209
 
                          transport.get_transport('http://host/'))
 
206
        self.assertRaises(
 
207
            errors.JailBreak, _pre_open_hook, get_transport('http://host/'))
210
208
 
211
209
    def test_open_bzrdir_in_non_main_thread(self):
212
210
        """Opening a bzrdir in a non-main thread should work ok.