~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_fetch.py

Merged mailine

Show diffs side-by-side

added added

removed removed

Lines of Context:
86
86
        self.assertFalse(has_revision(br_a3, br_a.revision_history()[revno]))
87
87
    self.assertEqual(greedy_fetch(br_a3, br_a2, br_a.revision_history()[2])[0], 3)
88
88
    fetched = greedy_fetch(br_a3, br_a2, br_a.revision_history()[3])[0]
89
 
    self.assertEquals(fetched, 3, "fetched %d instead of 3" % fetched)
 
89
    self.assertEquals(fetched, 6, "fetched %d instead of 6" % fetched)
90
90
    # InstallFailed should be raised if the branch is missing the revision
91
91
    # that was requested.
92
92
    self.assertRaises(bzrlib.errors.InstallFailed, greedy_fetch, br_a3,
181
181
 
182
182
class TestHttpFetch(TestCaseWithWebserver):
183
183
 
184
 
    def setUp(self):
185
 
        super(TestHttpFetch, self).setUp()
186
 
        self.weblogs = []
187
 
 
188
184
    def test_fetch(self):
189
185
        #highest indices a: 5, b: 7
190
186
        br_a, br_b = make_branches(self)
191
187
        br_rem_a = Branch.open(self.get_remote_url(br_a._transport.base))
192
188
        fetch_steps(self, br_rem_a, br_b, br_a)
193
189
 
194
 
    def log(self, *args):
195
 
        """Capture web server log messages for introspection."""
196
 
        super(TestHttpFetch, self).log(*args)
197
 
        # if this call indicates a url being fetched, save it specially
198
 
        if args[0].startswith("webserver"):
199
 
            self.weblogs.append(args[3])
200
 
 
201
190
    def test_weaves_are_retrieved_once(self):
202
191
        self.build_tree(("source/", "source/file", "target/"))
203
192
        branch = Branch.initialize("source")
213
202
        # path.
214
203
        weave_suffix = 'weaves/ce/id.weave HTTP/1.1" 200 -'
215
204
        self.assertEqual(1,
216
 
            len([log for log in self.weblogs if log.endswith(weave_suffix)]))
 
205
            len([log for log in self.server.logs if log.endswith(weave_suffix)]))
217
206
        inventory_weave_suffix = 'inventory.weave HTTP/1.1" 200 -'
218
207
        self.assertEqual(1,
219
 
            len([log for log in self.weblogs if log.endswith(
 
208
            len([log for log in self.server.logs if log.endswith(
220
209
                inventory_weave_suffix)]))
221
210
        # this r-h check test will prevent regressions, but it currently already 
222
211
        # passes, before the patch to cache-rh is applied :[
223
212
        revision_history_suffix = 'revision-history HTTP/1.1" 200 -'
224
213
        self.assertEqual(1,
225
 
            len([log for log in self.weblogs if log.endswith(
 
214
            len([log for log in self.server.logs if log.endswith(
226
215
                revision_history_suffix)]))
227
 
        self.weblogs = []
 
216
        # FIXME naughty poking in there.
 
217
        self.server.logs = []
228
218
        # check there is nothing more to fetch
229
219
        source = Branch.open(self.get_remote_url("source/"))
230
220
        self.assertEqual(greedy_fetch(target, source), (0, []))
231
 
        self.failUnless(self.weblogs[0].endswith('branch-format HTTP/1.1" 200 -'))
232
 
        self.failUnless(self.weblogs[1].endswith('revision-history HTTP/1.1" 200 -'))
233
 
        self.assertEqual(2, len(self.weblogs))
 
221
        self.failUnless(self.server.logs[0].endswith('branch-format HTTP/1.1" 200 -'))
 
222
        self.failUnless(self.server.logs[1].endswith('revision-history HTTP/1.1" 200 -'))
 
223
        self.assertEqual(2, len(self.server.logs))