~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_url_policy_open.py

  • Committer: Patch Queue Manager
  • Date: 2016-02-01 19:13:13 UTC
  • mfrom: (6614.2.2 trunk)
  • Revision ID: pqm@pqm.ubuntu.com-20160201191313-wdfvmfff1djde6oq
(vila) Release 2.7.0 (Vincent Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2011 Canonical Ltd
 
1
# Copyright (C) 2011, 2012, 2016 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
89
89
        # When branch references are forbidden, check_and_follow_branch_reference
90
90
        # does not raise on non-references.
91
91
        opener = self.make_branch_opener(False, ['a', None])
92
 
        self.assertEquals(
 
92
        self.assertEqual(
93
93
            'a', opener.check_and_follow_branch_reference('a'))
94
 
        self.assertEquals(['a'], opener.follow_reference_calls)
 
94
        self.assertEqual(['a'], opener.follow_reference_calls)
95
95
 
96
96
    def test_branch_reference_forbidden(self):
97
97
        # check_and_follow_branch_reference raises BranchReferenceForbidden if
101
101
        self.assertRaises(
102
102
            BranchReferenceForbidden,
103
103
            opener.check_and_follow_branch_reference, 'a')
104
 
        self.assertEquals(['a'], opener.follow_reference_calls)
 
104
        self.assertEqual(['a'], opener.follow_reference_calls)
105
105
 
106
106
    def test_allowed_reference(self):
107
107
        # check_and_follow_branch_reference does not raise if following references
108
108
        # is allowed and the source URL points to a branch reference to a
109
109
        # permitted location.
110
110
        opener = self.make_branch_opener(True, ['a', 'b', None])
111
 
        self.assertEquals(
 
111
        self.assertEqual(
112
112
            'b', opener.check_and_follow_branch_reference('a'))
113
 
        self.assertEquals(['a', 'b'], opener.follow_reference_calls)
 
113
        self.assertEqual(['a', 'b'], opener.follow_reference_calls)
114
114
 
115
115
    def test_check_referenced_urls(self):
116
116
        # check_and_follow_branch_reference checks if the URL a reference points
119
119
            True, ['a', 'b', None], unsafe_urls=set('b'))
120
120
        self.assertRaises(
121
121
            BadUrl, opener.check_and_follow_branch_reference, 'a')
122
 
        self.assertEquals(['a'], opener.follow_reference_calls)
 
122
        self.assertEqual(['a'], opener.follow_reference_calls)
123
123
 
124
124
    def test_self_referencing_branch(self):
125
125
        # check_and_follow_branch_reference raises BranchReferenceLoopError if
128
128
        opener = self.make_branch_opener(True, ['a', 'a'])
129
129
        self.assertRaises(
130
130
            BranchLoopError, opener.check_and_follow_branch_reference, 'a')
131
 
        self.assertEquals(['a'], opener.follow_reference_calls)
 
131
        self.assertEqual(['a'], opener.follow_reference_calls)
132
132
 
133
133
    def test_branch_reference_loop(self):
134
134
        # check_and_follow_branch_reference raises BranchReferenceLoopError if
138
138
        opener = self.make_branch_opener(True, references)
139
139
        self.assertRaises(
140
140
            BranchLoopError, opener.check_and_follow_branch_reference, 'a')
141
 
        self.assertEquals(['a', 'b'], opener.follow_reference_calls)
 
141
        self.assertEqual(['a', 'b'], opener.follow_reference_calls)
142
142
 
143
143
 
144
144
class TrackingProber(BzrProber):
168
168
        opener = self.make_branch_opener([b.base], probers=[])
169
169
        self.assertRaises(NotBranchError, opener.open, b.base)
170
170
        opener = self.make_branch_opener([b.base], probers=[BzrProber])
171
 
        self.assertEquals(b.base, opener.open(b.base).base)
 
171
        self.assertEqual(b.base, opener.open(b.base).base)
172
172
 
173
173
    def test_default_probers(self):
174
174
        # If no probers are specified to the constructor
182
182
        TrackingProber.seen_urls = []
183
183
        opener = self.make_branch_opener(["."], probers=[TrackingProber])
184
184
        self.assertRaises(NotBranchError, opener.open, ".")
185
 
        self.assertEquals(1, len(TrackingProber.seen_urls))
 
185
        self.assertEqual(1, len(TrackingProber.seen_urls))
186
186
        TrackingProber.seen_urls = []
187
187
        # And make sure it's registered in such a way that ControlDir.open would
188
188
        # use it.
189
189
        self.assertRaises(NotBranchError, ControlDir.open, ".")
190
 
        self.assertEquals(1, len(TrackingProber.seen_urls))
 
190
        self.assertEqual(1, len(TrackingProber.seen_urls))
191
191
 
192
192
    def test_allowed_url(self):
193
193
        # the opener does not raise an exception for branches stacked on
287
287
        opener = self.make_branch_opener(
288
288
            [a.base, b.base], probers=[TrackingProber])
289
289
        opener.open(b.base)
290
 
        self.assertEquals(
 
290
        self.assertEqual(
291
291
            set(TrackingProber.seen_urls), set([b.base, a.base]))
292
292
 
293
293
    def test_custom_opener_with_branch_reference(self):
299
299
        opener = self.make_branch_opener(
300
300
            [a.base, b.base], probers=[TrackingProber])
301
301
        opener.open(b.base)
302
 
        self.assertEquals(
 
302
        self.assertEqual(
303
303
            set(TrackingProber.seen_urls), set([b.base, a.base]))
304
304
 
305
305