182
182
class TestHttpFetch(TestCaseWithWebserver):
185
super(TestHttpFetch, self).setUp()
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)
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
190
def test_weaves_are_retrieved_once(self):
202
191
self.build_tree(("source/", "source/file", "target/"))
203
192
branch = Branch.initialize("source")
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)]))
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))