~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/codehosting/tests/test_safe_open.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-08-18 22:05:32 UTC
  • mfrom: (13677.5.8 safe-opener-threading)
  • Revision ID: launchpad@pqm.canonical.com-20110818220532-zxyairkgkd3v2fa8
[r=gmb][bug=826082,826136] Make SafeBranchOpener threadsafe.

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
class TestSafeBranchOpenerCheckAndFollowBranchReference(TestCase):
38
38
    """Unit tests for `SafeBranchOpener.checkAndFollowBranchReference`."""
39
39
 
 
40
    def setUp(self):
 
41
        super(TestSafeBranchOpenerCheckAndFollowBranchReference, self).setUp()
 
42
        SafeBranchOpener.install_hook()
 
43
 
40
44
    class StubbedSafeBranchOpener(SafeBranchOpener):
41
45
        """SafeBranchOpener that provides canned answers.
42
46
 
123
127
 
124
128
class TestSafeBranchOpenerStacking(TestCaseWithTransport):
125
129
 
 
130
    def setUp(self):
 
131
        super(TestSafeBranchOpenerStacking, self).setUp()
 
132
        SafeBranchOpener.install_hook()
 
133
 
126
134
    def makeBranchOpener(self, allowed_urls):
127
135
        policy = WhitelistPolicy(True, allowed_urls, True)
128
136
        return SafeBranchOpener(policy)
228
236
class TestSafeOpen(TestCaseWithTransport):
229
237
    """Tests for `safe_open`."""
230
238
 
 
239
    def setUp(self):
 
240
        super(TestSafeOpen, self).setUp()
 
241
        SafeBranchOpener.install_hook()
 
242
 
 
243
    def test_hook_does_not_interfere(self):
 
244
        # The transform_fallback_location hook does not interfere with regular
 
245
        # stacked branch access outside of safe_open.
 
246
        self.make_branch('stacked')
 
247
        self.make_branch('stacked-on')
 
248
        Branch.open('stacked').set_stacked_on_url('../stacked-on')
 
249
        Branch.open('stacked')
 
250
 
231
251
    def get_chrooted_scheme(self, relpath):
232
252
        """Create a server that is chrooted to `relpath`.
233
253