36
36
except bzrlib.errors.NoSuchRevision:
39
40
def fetch_steps(self, br_a, br_b, writable_a):
40
41
"""A foreign test method for testing fetch locally and remotely."""
41
42
def new_branch(name):
182
183
class TestHttpFetch(TestCaseWithWebserver):
185
super(TestHttpFetch, self).setUp()
188
185
def test_fetch(self):
189
186
#highest indices a: 5, b: 7
190
187
br_a, br_b = make_branches(self)
191
188
br_rem_a = Branch.open(self.get_remote_url(br_a._transport.base))
192
189
fetch_steps(self, br_rem_a, br_b, br_a)
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])
201
191
def test_weaves_are_retrieved_once(self):
202
192
self.build_tree(("source/", "source/file", "target/"))
203
193
branch = Branch.initialize("source")
214
204
weave_suffix = 'weaves/ce/id.weave HTTP/1.1" 200 -'
215
205
self.assertEqual(1,
216
len([log for log in self.weblogs if log.endswith(weave_suffix)]))
206
len([log for log in self.server.logs if log.endswith(weave_suffix)]))
217
207
inventory_weave_suffix = 'inventory.weave HTTP/1.1" 200 -'
218
208
self.assertEqual(1,
219
len([log for log in self.weblogs if log.endswith(
209
len([log for log in self.server.logs if log.endswith(
220
210
inventory_weave_suffix)]))
221
211
# this r-h check test will prevent regressions, but it currently already
222
212
# passes, before the patch to cache-rh is applied :[
223
213
revision_history_suffix = 'revision-history HTTP/1.1" 200 -'
224
214
self.assertEqual(1,
225
len([log for log in self.weblogs if log.endswith(
215
len([log for log in self.server.logs if log.endswith(
226
216
revision_history_suffix)]))
217
# FIXME naughty poking in there.
218
self.server.logs = []
228
219
# check there is nothing more to fetch
229
220
source = Branch.open(self.get_remote_url("source/"))
230
221
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))
222
self.failUnless(self.server.logs[0].endswith('branch-format HTTP/1.1" 200 -'))
223
self.failUnless(self.server.logs[1].endswith('revision-history HTTP/1.1" 200 -'))
224
self.assertEqual(2, len(self.server.logs))