~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/testfetch.py

  • Committer: Martin Pool
  • Date: 2005-10-06 04:09:55 UTC
  • mfrom: (1413)
  • mto: (1185.13.3)
  • mto: This revision was merged to the branch mainline in revision 1417.
  • Revision ID: mbp@sourcefrog.net-20051006040955-36f27e5a8d5c977b
[merge] from robert

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
from bzrlib.fetch import greedy_fetch
25
25
 
26
26
from bzrlib.selftest import TestCaseInTempDir
 
27
from bzrlib.selftest.HTTPTestUtil import TestCaseWithWebserver
27
28
 
28
29
 
29
30
def has_revision(branch, revision_id):
98
99
class TestFetch(TestCaseInTempDir):
99
100
 
100
101
    def test_fetch(self):
101
 
        
102
102
        #highest indices a: 5, b: 7
103
103
        br_a, br_b = make_branches()
104
104
        fetch_steps(self, br_a, br_b, br_a)
 
105
 
 
106
 
 
107
class TestHttpFetch(TestCaseWithWebserver):
 
108
 
 
109
    def setUp(self):
 
110
        super(TestHttpFetch, self).setUp()
 
111
        self.weblogs = []
 
112
 
 
113
    def test_fetch(self):
 
114
        #highest indices a: 5, b: 7
 
115
        br_a, br_b = make_branches()
 
116
        br_rem_a = Branch.open(self.get_remote_url(br_a._transport.base))
 
117
        fetch_steps(self, br_rem_a, br_b, br_a)
 
118
 
 
119
    def log(self, *args):
 
120
        """Capture web server log messages for introspection."""
 
121
        super(TestHttpFetch, self).log(*args)
 
122
        if args[0].startswith("webserver"):
 
123
            self.weblogs.append(args[0])
 
124
 
 
125
    def test_weaves_are_retrieved_once(self):
 
126
        self.build_tree(("source/", "source/file", "target/"))
 
127
        branch = Branch.initialize("source")
 
128
        branch.add(["file"], ["id"])
 
129
        branch.commit("added file")
 
130
        print >>open("source/file", 'w'), "blah"
 
131
        branch.commit("changed file")
 
132
        target = Branch.initialize("target/")
 
133
        source = Branch.open(self.get_remote_url("source/"))
 
134
        source.weave_store.enable_cache = False
 
135
        self.assertEqual(greedy_fetch(target, source), (2, []))
 
136
        weave_suffix = 'weaves/id.weave HTTP/1.1" 200 -'
 
137
        self.assertEqual(1,
 
138
            len([log for log in self.weblogs if log.endswith(weave_suffix)]))